summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authorKit Langton <[email protected]>2026-04-17 22:53:19 -0400
committerGitHub <[email protected]>2026-04-18 02:53:19 +0000
commit24fb9b1296d7bb5942ef5690ee3a806856b18dae (patch)
treec89c76683d0cdcb23cbae17bc08ff69b8b846319 /packages
parent357301991624ae6c361350c1c1aca222268a6d5d (diff)
downloadopencode-24fb9b1296d7bb5942ef5690ee3a806856b18dae.tar.gz
opencode-24fb9b1296d7bb5942ef5690ee3a806856b18dae.zip
fix: stop rewriting dev during release publish (#22982)
Diffstat (limited to 'packages')
-rwxr-xr-xpackages/opencode/script/publish.ts29
-rwxr-xr-xpackages/plugin/script/publish.ts12
-rwxr-xr-xpackages/sdk/js/script/publish.ts37
3 files changed, 56 insertions, 22 deletions
diff --git a/packages/opencode/script/publish.ts b/packages/opencode/script/publish.ts
index 9c4b8f187..b444106a1 100755
--- a/packages/opencode/script/publish.ts
+++ b/packages/opencode/script/publish.ts
@@ -7,6 +7,20 @@ import { fileURLToPath } from "url"
const dir = fileURLToPath(new URL("..", import.meta.url))
process.chdir(dir)
+async function published(name: string, version: string) {
+ return (await $`npm view ${name}@${version} version`.nothrow()).exitCode === 0
+}
+
+async function publish(dir: string, name: string, version: string) {
+ if (await published(name, version)) {
+ console.log(`already published ${name}@${version}`)
+ return
+ }
+ if (process.platform !== "win32") await $`chmod -R 755 .`.cwd(dir)
+ await $`bun pm pack`.cwd(dir)
+ await $`npm publish *.tgz --access public --tag ${Script.channel}`.cwd(dir)
+}
+
const binaries: Record<string, string> = {}
for (const filepath of new Bun.Glob("*/package.json").scanSync({ cwd: "./dist" })) {
const pkg = await Bun.file(`./dist/${filepath}`).json()
@@ -40,14 +54,10 @@ await Bun.file(`./dist/${pkg.name}/package.json`).write(
)
const tasks = Object.entries(binaries).map(async ([name]) => {
- if (process.platform !== "win32") {
- await $`chmod -R 755 .`.cwd(`./dist/${name}`)
- }
- await $`bun pm pack`.cwd(`./dist/${name}`)
- await $`npm publish *.tgz --access public --tag ${Script.channel}`.cwd(`./dist/${name}`)
+ await publish(`./dist/${name}`, name, binaries[name])
})
await Promise.all(tasks)
-await $`cd ./dist/${pkg.name} && bun pm pack && npm publish *.tgz --access public --tag ${Script.channel}`
+await publish(`./dist/${pkg.name}`, `${pkg.name}-ai`, version)
const image = "ghcr.io/anomalyco/opencode"
const platforms = "linux/amd64,linux/arm64"
@@ -104,6 +114,7 @@ if (!Script.preview) {
await Bun.file(`./dist/aur-${pkg}/PKGBUILD`).write(pkgbuild)
await $`cd ./dist/aur-${pkg} && makepkg --printsrcinfo > .SRCINFO`
await $`cd ./dist/aur-${pkg} && git add PKGBUILD .SRCINFO`
+ if ((await $`cd ./dist/aur-${pkg} && git diff --cached --quiet`.nothrow()).exitCode === 0) break
await $`cd ./dist/aur-${pkg} && git commit -m "Update to v${Script.version}"`
await $`cd ./dist/aur-${pkg} && git push`
break
@@ -176,6 +187,8 @@ if (!Script.preview) {
await $`git clone ${tap} ./dist/homebrew-tap`
await Bun.file("./dist/homebrew-tap/opencode.rb").write(homebrewFormula)
await $`cd ./dist/homebrew-tap && git add opencode.rb`
- await $`cd ./dist/homebrew-tap && git commit -m "Update to v${Script.version}"`
- await $`cd ./dist/homebrew-tap && git push`
+ if ((await $`cd ./dist/homebrew-tap && git diff --cached --quiet`.nothrow()).exitCode !== 0) {
+ await $`cd ./dist/homebrew-tap && git commit -m "Update to v${Script.version}"`
+ await $`cd ./dist/homebrew-tap && git push`
+ }
}
diff --git a/packages/plugin/script/publish.ts b/packages/plugin/script/publish.ts
index d2fe49f23..de129918c 100755
--- a/packages/plugin/script/publish.ts
+++ b/packages/plugin/script/publish.ts
@@ -6,9 +6,19 @@ import { fileURLToPath } from "url"
const dir = fileURLToPath(new URL("..", import.meta.url))
process.chdir(dir)
+async function published(name: string, version: string) {
+ return (await $`npm view ${name}@${version} version`.nothrow()).exitCode === 0
+}
+
await $`bun tsc`
-const pkg = await import("../package.json").then((m) => m.default)
+const pkg = await import("../package.json").then(
+ (m) => m.default as { name: string; version: string; exports: Record<string, string> },
+)
const original = JSON.parse(JSON.stringify(pkg))
+if (await published(pkg.name, pkg.version)) {
+ console.log(`already published ${pkg.name}@${pkg.version}`)
+ process.exit(0)
+}
for (const [key, value] of Object.entries(pkg.exports)) {
const file = value.replace("./src/", "./dist/").replace(".ts", "")
// @ts-ignore
diff --git a/packages/sdk/js/script/publish.ts b/packages/sdk/js/script/publish.ts
index ea5c5d634..b5e1211fc 100755
--- a/packages/sdk/js/script/publish.ts
+++ b/packages/sdk/js/script/publish.ts
@@ -7,24 +7,35 @@ import { fileURLToPath } from "url"
const dir = fileURLToPath(new URL("..", import.meta.url))
process.chdir(dir)
+async function published(name: string, version: string) {
+ return (await $`npm view ${name}@${version} version`.nothrow()).exitCode === 0
+}
+
const pkg = (await import("../package.json").then((m) => m.default)) as {
- exports: Record<string, string | object>
+ name: string
+ version: string
+ exports: Record<string, unknown>
}
const original = JSON.parse(JSON.stringify(pkg))
-function transformExports(exports: Record<string, string | object>) {
- for (const [key, value] of Object.entries(exports)) {
- if (typeof value === "object" && value !== null) {
- transformExports(value as Record<string, string | object>)
- } else if (typeof value === "string") {
- const file = value.replace("./src/", "./dist/").replace(".ts", "")
- exports[key] = {
- import: file + ".js",
- types: file + ".d.ts",
+function transformExports(exports: Record<string, unknown>) {
+ return Object.fromEntries(
+ Object.entries(exports).map(([key, value]) => {
+ if (typeof value === "string") {
+ const file = value.replace("./src/", "./dist/").replace(".ts", "")
+ return [key, { import: file + ".js", types: file + ".d.ts" }]
}
- }
- }
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
+ return [key, transformExports(value)]
+ }
+ return [key, value]
+ }),
+ )
+}
+if (await published(pkg.name, pkg.version)) {
+ console.log(`already published ${pkg.name}@${pkg.version}`)
+ process.exit(0)
}
-transformExports(pkg.exports)
+pkg.exports = transformExports(pkg.exports)
await Bun.write("package.json", JSON.stringify(pkg, null, 2))
await $`bun pm pack`
await $`npm publish *.tgz --tag ${Script.channel} --access public`