Repository navigation
feat(release): validate AlphaCode versions and tagged release lifecycle #255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0e31860
b38adf1
bb6986c
b179b7a
2a25ae6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,22 @@ | ||
| declare global { | ||
| const ALPHACODE_VERSION: string | ||
| const ALPHACODE_CHANNEL: string | ||
| const OPENCODE_VERSION: string | ||
| const OPENCODE_CHANNEL: string | ||
| } | ||
|
|
||
| export const InstallationVersion = typeof OPENCODE_VERSION === "string" ? OPENCODE_VERSION : "local" | ||
| export const InstallationChannel = typeof OPENCODE_CHANNEL === "string" ? OPENCODE_CHANNEL : "local" | ||
| // The AlphaCode build injects ALPHACODE_*; OPENCODE_* is the inherited alias and | ||
| // stays as a fallback so unchanged OpenCode code keeps resolving its globals. | ||
| export const InstallationVersion = | ||
| typeof ALPHACODE_VERSION === "string" | ||
| ? ALPHACODE_VERSION | ||
| : typeof OPENCODE_VERSION === "string" | ||
| ? OPENCODE_VERSION | ||
| : "local" | ||
| export const InstallationChannel = | ||
| typeof ALPHACODE_CHANNEL === "string" | ||
| ? ALPHACODE_CHANNEL | ||
| : typeof OPENCODE_CHANNEL === "string" | ||
| ? OPENCODE_CHANNEL | ||
| : "local" | ||
| export const InstallationLocal = InstallationChannel === "local" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,11 +11,28 @@ const dir = path.resolve(__dirname, "..") | |
|
|
||
| process.chdir(dir) | ||
|
|
||
| const generated = await import("./generate.ts") | ||
|
|
||
| import { Script } from "@opencode-ai/script" | ||
| import { archiveName, assertReleaseGate, assertReleaseVersions, Script, tagForVersion, uploadReleaseArchives } from "@opencode-ai/script" | ||
| import pkg from "../package.json" | ||
|
|
||
| // A published build must be an exact, stable, committed version built from the | ||
| // release tag on a clean tree - never a dev build and never an untagged tree. | ||
| if (Script.release) { | ||
| if (Script.preview) { | ||
| throw new Error( | ||
| `Refusing to publish a preview build (channel "${Script.channel}"). Build from the release tag or set ALPHACODE_CHANNEL=latest.`, | ||
| ) | ||
| } | ||
| const packageVersion = Script.packageVersion | ||
| assertReleaseVersions({ packageVersion, runtimeVersion: Script.version }) | ||
| assertReleaseGate({ | ||
| expectedTag: tagForVersion(packageVersion), | ||
| tagAtHead: await Script.tagAtHead, | ||
| dirty: await Script.dirty, | ||
| }) | ||
| } | ||
|
|
||
| const generated = await import("./generate.ts") | ||
|
|
||
| const singleFlag = process.argv.includes("--single") | ||
| const baselineFlag = process.argv.includes("--baseline") | ||
| const skipInstall = process.argv.includes("--skip-install") | ||
|
|
@@ -111,6 +128,7 @@ const targets = singleFlag | |
| await $`rm -rf dist` | ||
|
|
||
| const binaries: Record<string, string> = {} | ||
| const releaseTargets: { name: string; os: string }[] = [] | ||
| if (!skipInstall) { | ||
| await $`bun install --os="*" --cpu="*" @opentui/core@${pkg.dependencies["@opentui/core"]}` | ||
| await $`bun install --os="*" --cpu="*" @parcel/watcher@${pkg.dependencies["@parcel/watcher"]}` | ||
|
|
@@ -159,12 +177,17 @@ for (const item of targets) { | |
| entrypoints: ["./src/index.ts", workerPath, treeSitterWorkerPath], | ||
| define: { | ||
| FFF_LIBC: JSON.stringify(item.abi === "musl" ? "musl" : "gnu"), | ||
| // ALPHACODE_* is the AlphaCode runtime version; OPENCODE_* stays as the | ||
| // inherited alias so unchanged OpenCode code keeps resolving its globals. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SUGGESTION: OPENCODE_LIBC set to empty string for non-Linux (nearby) The define block sets Reply with |
||
| ALPHACODE_VERSION: `'${Script.version}'`, | ||
| ALPHACODE_CHANNEL: `'${Script.channel}'`, | ||
| OPENCODE_VERSION: `'${Script.version}'`, | ||
| OPENCODE_MODELS_DEV: generated.modelsData, | ||
| OTUI_TREE_SITTER_WORKER_PATH: bunfsRoot + treeSitterWorkerPath, | ||
| OPENCODE_WORKER_PATH: workerPath, | ||
| OPENCODE_CHANNEL: `'${Script.channel}'`, | ||
| OPENCODE_LIBC: item.os === "linux" ? `'${item.abi ?? "glibc"}'` : "", | ||
| // "undefined" (not "") so the watcher fallback reads it as unset. | ||
| OPENCODE_LIBC: item.os === "linux" ? `'${item.abi ?? "glibc"}'` : "undefined", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SUGGESTION: OPENCODE_LIBC set to string "undefined" could be confusing Setting Reply with |
||
| ...(item.os === "linux" ? { "process.env.OPENTUI_LIBC": JSON.stringify(item.abi ?? "glibc") } : {}), | ||
| }, | ||
| }) | ||
|
|
@@ -201,17 +224,24 @@ for (const item of targets) { | |
| ), | ||
| ) | ||
| binaries[name] = Script.version | ||
| releaseTargets.push({ name, os: item.os }) | ||
| } | ||
|
|
||
| if (Script.release) { | ||
| for (const key of Object.keys(binaries)) { | ||
| if (key.includes("linux")) { | ||
| await $`tar -czf ../../${key}.tar.gz *`.cwd(`dist/${key}/bin`) | ||
| // Upload exactly the archives this build produced. Globbing both extensions | ||
| // breaks a single-target build: one of the two globs matches nothing and the | ||
| // shell fails with "no matches". | ||
| const archives: string[] = [] | ||
| for (const target of releaseTargets) { | ||
| const archive = archiveName(target) | ||
| if (target.os === "linux") { | ||
| await $`tar -czf ../../${archive} *`.cwd(`dist/${target.name}/bin`) | ||
| } else { | ||
| await $`zip -r ../../${key}.zip *`.cwd(`dist/${key}/bin`) | ||
| await $`zip -r ../../${archive} *`.cwd(`dist/${target.name}/bin`) | ||
| } | ||
| archives.push(`./dist/${archive}`) | ||
| } | ||
| await $`gh release upload v${Script.version} ./dist/*.zip ./dist/*.tar.gz --clobber --repo ${process.env.GH_REPO}` | ||
| await uploadReleaseArchives(tagForVersion(Script.version), archives) | ||
| } | ||
|
|
||
| export { binaries } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WARNING: Version job restricted to main repo only (nearby)
The condition
github.repository == 'mdev34-lab/alphacode'(line 26 in the full file) prevents the workflow from running in forks. This blocks contributors from testing the release pipeline in their own forks. Consider using a different mechanism (e.g., environment protection rules, required approvals) if the concern is preventing unauthorized releases.Reply with
@kilocode-bot fix itto have Kilo Code address this issue.