Skip to content

Commit 6960408

Browse files
committed
ci: bump version
1 parent fa36195 commit 6960408

3 files changed

Lines changed: 25 additions & 19 deletions

File tree

.github/workflows/format.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ jobs:
2020
with:
2121
bun-version: 1.2.21
2222

23-
- name: Install dependencies
24-
run: bun install
25-
26-
- name: Run format
27-
run: ./script/format.ts
23+
- name: run
24+
run: |
25+
bun install
26+
./script/format.ts
2827
env:
2928
CI: true

.github/workflows/publish.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ run-name: "${{ format('v{0}', inputs.version) }}"
44
on:
55
workflow_dispatch:
66
inputs:
7-
version:
8-
description: "Version to publish"
7+
bump:
8+
description: "Bump major, minor, or patch"
99
required: true
10-
type: string
11-
title:
12-
description: "Custom title for this run"
13-
required: false
14-
type: string
10+
type: choice
11+
options:
12+
- major
13+
- minor
14+
- patch
1515

1616
concurrency: ${{ github.workflow }}-${{ github.ref }}
1717

@@ -65,8 +65,9 @@ jobs:
6565

6666
- name: Publish
6767
run: |
68-
OPENCODE_VERSION=${{ inputs.version }} ./script/publish.ts
68+
./script/publish.ts
6969
env:
70+
OPENCODE_BUMP: ${{ inputs.bump }}
7071
GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }}
7172
AUR_KEY: ${{ secrets.AUR_KEY }}
7273
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}

script/publish.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@ if (process.versions.bun !== "1.2.21") {
99
console.log("=== publishing ===\n")
1010

1111
const snapshot = process.env["OPENCODE_SNAPSHOT"] === "true"
12-
const version = snapshot
13-
? `0.0.0-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}`
14-
: process.env["OPENCODE_VERSION"]
15-
if (!version) {
16-
throw new Error("OPENCODE_VERSION is required")
17-
}
12+
const version = await (async () => {
13+
if (snapshot) return `0.0.0-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}`
14+
const [major, minor, patch] = (await $`gh release list --limit 1 --json tagName --jq '.[0].tagName'`.text())
15+
.trim()
16+
.replace(/^v/, "")
17+
.split(".")
18+
.map((x) => Number(x) || 0)
19+
const t = process.env["OPENCODE_BUMP"]?.toLowerCase()
20+
if (t === "major") return `${major + 1}.0.0`
21+
if (t === "minor") return `${major}.${minor + 1}.0`
22+
return `${major}.${minor}.${patch + 1}`
23+
})()
1824
process.env["OPENCODE_VERSION"] = version
1925
console.log("version:", version)
2026

0 commit comments

Comments
 (0)