diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml new file mode 100644 index 000000000..846aa9bb5 --- /dev/null +++ b/.github/workflows/snapshot.yml @@ -0,0 +1,51 @@ +name: publish +run-name: "${{ format('release {0}', inputs.bump) }}" + +on: + push: + branches: + - dev + - opentui + +concurrency: ${{ github.workflow }}-${{ github.ref }} + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - run: git fetch --force --tags + + - uses: actions/setup-go@v5 + with: + go-version: ">=1.24.0" + cache: true + cache-dependency-path: go.sum + + - uses: oven-sh/setup-bun@v2 + with: + bun-version: 1.2.21 + + - name: Cache ~/.bun + id: cache-bun + uses: actions/cache@v3 + with: + path: ~/.bun + key: ${{ runner.os }}-bun-1-2-21-${{ hashFiles('bun.lock') }} + restore-keys: | + ${{ runner.os }}-bun-1-2-21- + + - name: Install dependencies + run: bun install + + - name: Publish + run: | + ./packages/opencode/script/publish.ts + env: + OPENCODE_SNAPSHOT: true + OPENCODE_TAG: ${{ github.ref_name }} + GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }} + NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/packages/opencode/script/build.ts b/packages/opencode/script/build.ts index 3cf3370de..26c61382a 100755 --- a/packages/opencode/script/build.ts +++ b/packages/opencode/script/build.ts @@ -38,7 +38,7 @@ for (const [os, arch] of targets) { ) const opentui = `@opentui/core-${os === "windows" ? "win32" : os}-${arch.replace("-baseline", "")}` await $`mkdir -p ../../node_modules/${opentui}` - await $`npm pack npm pack ${opentui}`.cwd(path.join(dir, "../../node_modules")) + await $`npm pack npm pack ${opentui}`.cwd(path.join(dir, "../../node_modules")).quiet() await $`tar -xf ../../node_modules/${opentui.replace("@opentui/", "opentui-")}-*.tgz -C ../../node_modules/${opentui} --strip-components=1` await Bun.build({ conditions: ["browser"], diff --git a/packages/opencode/script/publish.ts b/packages/opencode/script/publish.ts index 83f889778..8c0eb65f0 100755 --- a/packages/opencode/script/publish.ts +++ b/packages/opencode/script/publish.ts @@ -7,9 +7,12 @@ import pkg from "../package.json" const snapshot = process.env["OPENCODE_SNAPSHOT"] === "true" let version = process.env["OPENCODE_VERSION"] -if (!version && snapshot) version = `0.0.0-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}` +if (!version && snapshot) { + version = `0.0.0-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}` + process.env["OPENCODE_VERSION"] = version +} if (!version) throw new Error("OPENCODE_VERSION is required") -const npmTag = snapshot ? "snapshot" : "latest" +const tag = process.env["OPENCODE_TAG"] ?? (snapshot ? "snapshot" : "latest") console.log(`publishing ${version}`) @@ -43,9 +46,9 @@ await Bun.file(`./dist/${pkg.name}/package.json`).write( ), ) for (const [name] of Object.entries(binaries)) { - await $`cd dist/${name} && chmod 777 -R . && bun publish --access public --tag ${npmTag}` + await $`cd dist/${name} && chmod 777 -R . && bun publish --access public --tag ${tag}` } -await $`cd ./dist/${pkg.name} && bun publish --access public --tag ${npmTag}` +await $`cd ./dist/${pkg.name} && bun publish --access public --tag ${tag}` if (!snapshot) { for (const key of Object.keys(binaries)) {