summaryrefslogtreecommitdiffhomepage
path: root/script/publish.ts
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-10-14 14:34:19 -0400
committerDax Raad <[email protected]>2025-10-14 14:35:04 -0400
commit0c022ef39da2724255794484caf5090b2d30efc4 (patch)
treee2403be1972384b598cfdf6074ce5d09e5f17fcd /script/publish.ts
parent717b5446331f8ff3034c0d35b95b832e92ffef49 (diff)
downloadopencode-0c022ef39da2724255794484caf5090b2d30efc4.tar.gz
opencode-0c022ef39da2724255794484caf5090b2d30efc4.zip
ci: stuff
Diffstat (limited to 'script/publish.ts')
-rwxr-xr-xscript/publish.ts47
1 files changed, 13 insertions, 34 deletions
diff --git a/script/publish.ts b/script/publish.ts
index 05d6df222..a4296ec4b 100755
--- a/script/publish.ts
+++ b/script/publish.ts
@@ -2,34 +2,13 @@
import { $ } from "bun"
import { createOpencode } from "@opencode-ai/sdk"
-if (process.versions.bun !== "1.3.0") {
- throw new Error("This script requires [email protected]")
-}
+import { Script } from "@opencode-ai/script"
const notes = [] as string[]
console.log("=== publishing ===\n")
-const snapshot = process.env["OPENCODE_SNAPSHOT"] === "true"
-const version = await (async () => {
- if (snapshot) return `0.0.0-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}`
- if (process.env["OPENCODE_VERSION"]) return process.env["OPENCODE_VERSION"]
- const npmVersion = await fetch("https://registry.npmjs.org/opencode-ai/latest")
- .then((res) => {
- if (!res.ok) throw new Error(res.statusText)
- return res.json()
- })
- .then((data: any) => data.version)
- const [major, minor, patch] = npmVersion.split(".").map((x: string) => Number(x) || 0)
- const t = process.env["OPENCODE_BUMP"]?.toLowerCase()
- if (t === "major") return `${major + 1}.0.0`
- if (t === "minor") return `${major}.${minor + 1}.0`
- return `${major}.${minor}.${patch + 1}`
-})()
-process.env["OPENCODE_VERSION"] = version
-console.log("version:", version)
-
-if (!snapshot) {
+if (!Script.preview) {
const previous = await fetch("https://registry.npmjs.org/opencode-ai/latest")
.then((res) => {
if (!res.ok) throw new Error(res.statusText)
@@ -98,7 +77,7 @@ const pkgjsons = await Array.fromAsync(
const tree = await $`git add . && git write-tree`.text().then((x) => x.trim())
for (const file of pkgjsons) {
let pkg = await Bun.file(file).text()
- pkg = pkg.replaceAll(/"version": "[^"]+"/g, `"version": "${version}"`)
+ pkg = pkg.replaceAll(/"version": "[^"]+"/g, `"version": "${Script.version}"`)
console.log("updated:", file)
await Bun.file(file).write(pkg)
}
@@ -116,22 +95,22 @@ 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}`
+if (!Script.preview) {
+ await $`git commit -am "release: v${Script.version}"`
+ await $`git tag v${Script.version}`
await $`git fetch origin`
await $`git cherry-pick HEAD..origin/dev`.nothrow()
await $`git push origin HEAD --tags --no-verify --force`
- await $`gh release create v${version} --title "v${version}" --notes ${notes.join("\n") ?? "No notable changes"} ./packages/opencode/dist/*.zip`
+ await $`gh release create v${Script.version} --title "v${Script.version}" --notes ${notes.join("\n") ?? "No notable changes"} ./packages/opencode/dist/*.zip`
}
-if (snapshot) {
- await $`git checkout -b snapshot-${version}`
- await $`git commit --allow-empty -m "Snapshot release v${version}"`
- await $`git tag v${version}`
- await $`git push origin v${version} --no-verify`
+if (Script.preview) {
+ await $`git checkout -b snapshot-${Script.version}`
+ await $`git commit --allow-empty -m "Snapshot release v${Script.version}"`
+ await $`git tag v${Script.version}`
+ await $`git push origin v${Script.version} --no-verify`
await $`git checkout dev`
- await $`git branch -D snapshot-${version}`
+ await $`git branch -D snapshot-${Script.version}`
for (const file of pkgjsons) {
await $`git checkout ${tree} ${file}`
}