summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-10-14 14:51:35 -0400
committerDax Raad <[email protected]>2025-10-14 14:52:05 -0400
commit289783f627c30074341938d8422cd9c9ef91bca8 (patch)
treec364bba9b2721dfab42806f060eedf75a21f1b73
parent4c464cf4c01ed6120b16e201cf232255a10d3c8c (diff)
downloadopencode-289783f627c30074341938d8422cd9c9ef91bca8.tar.gz
opencode-289783f627c30074341938d8422cd9c9ef91bca8.zip
ci: version stuff
-rw-r--r--.github/workflows/publish.yml2
-rwxr-xr-xpackages/opencode/script/build.ts1
-rwxr-xr-xpackages/opencode/script/publish.ts4
-rw-r--r--packages/opencode/src/cli/cmd/tui.ts2
-rw-r--r--packages/opencode/src/installation/index.ts19
-rw-r--r--packages/opencode/src/share/share.ts2
-rw-r--r--packages/script/src/index.ts8
7 files changed, 19 insertions, 19 deletions
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 57f3abb93..c88860a0f 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -58,7 +58,7 @@ jobs:
./script/publish.ts
env:
OPENCODE_BUMP: ${{ inputs.bump }}
- OPENCODE_TAG: latest
+ OPENCODE_CHANNEL: latest
GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }}
AUR_KEY: ${{ secrets.AUR_KEY }}
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
diff --git a/packages/opencode/script/build.ts b/packages/opencode/script/build.ts
index 860147f06..544fc8c06 100755
--- a/packages/opencode/script/build.ts
+++ b/packages/opencode/script/build.ts
@@ -49,6 +49,7 @@ for (const [os, arch] of targets) {
entrypoints: ["./src/index.ts"],
define: {
OPENCODE_VERSION: `'${Script.version}'`,
+ OPENCODE_CHANNEL: `'${Script.channel}'`,
OPENCODE_TUI_PATH: `'../../../dist/${name}/bin/tui'`,
},
})
diff --git a/packages/opencode/script/publish.ts b/packages/opencode/script/publish.ts
index e58956350..3bdf6a49d 100755
--- a/packages/opencode/script/publish.ts
+++ b/packages/opencode/script/publish.ts
@@ -36,9 +36,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 ${Script.tag}`
+ await $`cd dist/${name} && chmod 777 -R . && bun publish --access public --tag ${Script.channel}`
}
-await $`cd ./dist/${pkg.name} && bun publish --access public --tag ${Script.tag}`
+await $`cd ./dist/${pkg.name} && bun publish --access public --tag ${Script.channel}`
if (!Script.preview) {
for (const key of Object.keys(binaries)) {
diff --git a/packages/opencode/src/cli/cmd/tui.ts b/packages/opencode/src/cli/cmd/tui.ts
index 119a8c789..f111aec89 100644
--- a/packages/opencode/src/cli/cmd/tui.ts
+++ b/packages/opencode/src/cli/cmd/tui.ts
@@ -157,7 +157,7 @@ export const TuiCommand = cmd({
;(async () => {
if (Installation.isDev()) return
- if (Installation.isSnapshot()) return
+ if (Installation.isPreview()) return
const config = await Config.global()
if (config.autoupdate === false || Flag.OPENCODE_DISABLE_AUTOUPDATE) return
const latest = await Installation.latest().catch(() => {})
diff --git a/packages/opencode/src/installation/index.ts b/packages/opencode/src/installation/index.ts
index 95b431ecd..193c22328 100644
--- a/packages/opencode/src/installation/index.ts
+++ b/packages/opencode/src/installation/index.ts
@@ -7,6 +7,7 @@ import { Log } from "../util/log"
declare global {
const OPENCODE_VERSION: string
+ const OPENCODE_CHANNEL: string
}
export namespace Installation {
@@ -40,7 +41,7 @@ export namespace Installation {
}
}
- export function isSnapshot() {
+ export function isPreview() {
return VERSION.startsWith("0.0.0")
}
@@ -137,17 +138,15 @@ export namespace Installation {
}
export const VERSION = typeof OPENCODE_VERSION === "string" ? OPENCODE_VERSION : "dev"
- export const USER_AGENT = `opencode/${VERSION}`
+ export const CHANNEL = typeof OPENCODE_CHANNEL === "string" ? OPENCODE_CHANNEL : "dev"
+ export const USER_AGENT = `opencode/${CHANNEL}/${VERSION}`
export async function latest() {
- return fetch("https://api.github.com/repos/sst/opencode/releases/latest")
- .then((res) => res.json())
- .then((data) => {
- if (typeof data.tag_name !== "string") {
- log.error("GitHub API error", data)
- throw new Error("failed to fetch latest version")
- }
- return data.tag_name.slice(1) as string
+ return fetch(`https://registry.npmjs.org/opencode-ai/${CHANNEL}`)
+ .then((res) => {
+ if (!res.ok) throw new Error(res.statusText)
+ return res.json()
})
+ .then((data: any) => data.version)
}
}
diff --git a/packages/opencode/src/share/share.ts b/packages/opencode/src/share/share.ts
index 9df862d59..be9292cee 100644
--- a/packages/opencode/src/share/share.ts
+++ b/packages/opencode/src/share/share.ts
@@ -67,7 +67,7 @@ export namespace Share {
export const URL =
process.env["OPENCODE_API"] ??
- (Installation.isSnapshot() || Installation.isDev() ? "https://api.dev.opencode.ai" : "https://api.opencode.ai")
+ (Installation.isPreview() || Installation.isDev() ? "https://api.dev.opencode.ai" : "https://api.opencode.ai")
export async function create(sessionID: string) {
return fetch(`${URL}/share_create`, {
diff --git a/packages/script/src/index.ts b/packages/script/src/index.ts
index 4237a76a2..70232d3ab 100644
--- a/packages/script/src/index.ts
+++ b/packages/script/src/index.ts
@@ -4,8 +4,8 @@ if (process.versions.bun !== "1.3.0") {
throw new Error("This script requires [email protected]")
}
-const TAG = process.env["OPENCODE_TAG"] ?? (await $`git branch --show-current`.text().then((x) => x.trim()))
-const IS_PREVIEW = TAG !== "latest"
+const CHANNEL = process.env["OPENCODE_CHANNEL"] ?? (await $`git branch --show-current`.text().then((x) => x.trim()))
+const IS_PREVIEW = CHANNEL !== "latest"
const VERSION = await (async () => {
if (IS_PREVIEW) return `0.0.0-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}`
const version = await fetch("https://registry.npmjs.org/opencode-ai/latest")
@@ -22,8 +22,8 @@ const VERSION = await (async () => {
})()
export const Script = {
- get tag() {
- return TAG
+ get channel() {
+ return CHANNEL
},
get version() {
return VERSION