From 81534ab387c9cf7d3e3c1e06d796554f2c81668c Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Sun, 10 Aug 2025 22:15:07 -0400 Subject: [PATCH] ci: tweaks --- packages/opencode/script/publish.ts | 39 +++-------------------------- script/publish.ts | 37 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 35 deletions(-) diff --git a/packages/opencode/script/publish.ts b/packages/opencode/script/publish.ts index cfb98fff..b0520fb5 100755 --- a/packages/opencode/script/publish.ts +++ b/packages/opencode/script/publish.ts @@ -40,7 +40,10 @@ for (const [os, arch] of targets) { ) await $`bun build --define OPENCODE_TUI_PATH="'../../../dist/${name}/bin/tui'" --define OPENCODE_VERSION="'${version}'" --compile --target=bun-${os}-${arch} --outfile=dist/${name}/bin/opencode ./src/index.ts` // Run the binary only if it matches current OS/arch - if ((process.platform === (os === "windows" ? "win32" : os)) && (process.arch === arch || (process.arch === "x64" && arch === "x64-baseline"))) { + if ( + process.platform === (os === "windows" ? "win32" : os) && + (process.arch === arch || (process.arch === "x64" && arch === "x64-baseline")) + ) { console.log(`smoke test: running dist/${name}/bin/opencode --version`) await $`./dist/${name}/bin/opencode --version` } @@ -84,44 +87,10 @@ await Bun.file(`./dist/${pkg.name}/package.json`).write( if (!dry) await $`cd ./dist/${pkg.name} && bun publish --access public --tag ${npmTag}` if (!snapshot) { - // Github Release for (const key of Object.keys(optionalDependencies)) { await $`cd dist/${key}/bin && zip -r ../../${key}.zip *` } - const previous = await fetch("https://api.github.com/repos/sst/opencode/releases/latest") - .then((res) => { - if (!res.ok) throw new Error(res.statusText) - return res.json() - }) - .then((data) => data.tag_name) - - console.log("finding commits between", previous, "and", "HEAD") - const commits = await fetch(`https://api.github.com/repos/sst/opencode/compare/${previous}...HEAD`) - .then((res) => res.json()) - .then((data) => data.commits || []) - - const raw = commits.map((commit: any) => `- ${commit.commit.message.split("\n").join(" ")}`) - console.log(raw) - - const notes = - raw - .filter((x: string) => { - const lower = x.toLowerCase() - return ( - !lower.includes("release:") && - !lower.includes("ignore:") && - !lower.includes("chore:") && - !lower.includes("ci:") && - !lower.includes("wip:") && - !lower.includes("docs:") && - !lower.includes("doc:") - ) - }) - .join("\n") || "No notable changes" - - if (!dry) await $`gh release create v${version} --title "v${version}" --notes ${notes} ./dist/*.zip` - // Calculate SHA values const arm64Sha = await $`sha256sum ./dist/opencode-linux-arm64.zip | cut -d' ' -f1`.text().then((x) => x.trim()) const x64Sha = await $`sha256sum ./dist/opencode-linux-x64.zip | cut -d' ' -f1`.text().then((x) => x.trim()) diff --git a/script/publish.ts b/script/publish.ts index 7a48749d..7a1ec060 100755 --- a/script/publish.ts +++ b/script/publish.ts @@ -1,6 +1,7 @@ #!/usr/bin/env bun import { $ } from "bun" +import path from "path" console.log("=== publishing ===\n") @@ -38,10 +39,46 @@ await import(`../packages/sdk/js/script/publish.ts`) console.log("\n=== plugin ===\n") await import(`../packages/plugin/script/publish.ts`) +const dir = new URL("..", import.meta.url).pathname +process.chdir(dir) + if (!snapshot) { await $`git commit -am "release: v${version}"` await $`git tag v${version}` await $`git push origin HEAD --tags --no-verify` + + const previous = await fetch("https://api.github.com/repos/sst/opencode/releases/latest") + .then((res) => { + if (!res.ok) throw new Error(res.statusText) + return res.json() + }) + .then((data) => data.tag_name) + + console.log("finding commits between", previous, "and", "HEAD") + const commits = await fetch(`https://api.github.com/repos/sst/opencode/compare/${previous}...HEAD`) + .then((res) => res.json()) + .then((data) => data.commits || []) + + const raw = commits.map((commit: any) => `- ${commit.commit.message.split("\n").join(" ")}`) + console.log(raw) + + const notes = + raw + .filter((x: string) => { + const lower = x.toLowerCase() + return ( + !lower.includes("release:") && + !lower.includes("ignore:") && + !lower.includes("chore:") && + !lower.includes("ci:") && + !lower.includes("wip:") && + !lower.includes("docs:") && + !lower.includes("doc:") + ) + }) + .join("\n") || "No notable changes" + + await $`gh release create v${version} --title "v${version}" --notes ${notes} ./packages/opencode/dist/*.zip` } if (snapshot) { await $`git checkout -b snapshot-${version}`