feat(release): publish package binaries through Cloudflare

Move files deployments to Wrangler, make CLI and desktop own their publishing destinations, add direct-download update metadata and desktop feeds, and refresh installation docs.
This commit is contained in:
Dax Raad
2026-09-07 19:17:25 -04:00
Unverified
parent 0ab661a9cc
commit d1d1c6f890
24 changed files with 528 additions and 419 deletions
+3 -2
View File
@@ -17,7 +17,8 @@ if (!(beta ? /^\d+\.\d+\.\d+-beta[.-]\d+(?:\.\d+)?$/ : /^\d+\.\d+\.\d+$/).test(S
}
const dir = fileURLToPath(new URL("..", import.meta.url))
const outdir = path.join(dir, "dist", `aur-${name}`)
const root = path.resolve(process.env.OPENCODE_CLI_DIST ?? path.join(dir, "dist"))
const outdir = path.join(root, `aur-${name}`)
const dryRun = process.argv.includes("--dry-run")
const pkgver = Script.version.replaceAll("-", ".")
const license = Bun.file(path.join(dir, "..", "..", "LICENSE"))
@@ -35,7 +36,7 @@ const sources = await Promise.all(
{ arch: "x86_64", target: "linux-x64-baseline" },
{ arch: "aarch64", target: "linux-arm64" },
].map(async (item) => {
const directory = path.join(dir, "dist", `cli-${item.target}`)
const directory = path.join(root, `cli-${item.target}`)
const pkg: { name: string; version: string } = await Bun.file(path.join(directory, "package.json")).json()
if (pkg.version !== Script.version) throw new Error(`Unexpected version for ${pkg.name}: ${pkg.version}`)
const archive = Bun.file(path.join(directory, `${pkg.name.replace("@", "").replace("/", "-")}-${pkg.version}.tgz`))
+54 -4
View File
@@ -4,9 +4,12 @@ import pkg from "../package.json"
import { Script } from "@opencode/script"
import { fileURLToPath } from "url"
import { existsSync } from "fs"
import { chmod, rm, utimes } from "node:fs/promises"
import path from "node:path"
import { UpdateArtifact } from "../../../script/update-artifact"
const dir = fileURLToPath(new URL("..", import.meta.url))
const root = path.resolve(process.env.OPENCODE_CLI_DIST ?? path.join(dir, "dist"))
process.chdir(dir)
const dryRun = process.argv.includes("--dry-run")
@@ -41,6 +44,7 @@ async function publishDistribution(input: {
if (versions.size > 1) throw new Error(`Binary package versions do not match for ${input.name}`)
const version = versions.values().next().value
if (!version) throw new Error(`No binary packages found for ${input.name}`)
if (version !== Script.version) throw new Error(`Expected ${Script.version}, got ${version} for ${input.name}`)
await $`mkdir -p ${input.root}/${input.name}/bin`
await $`cp ./script/postinstall.mjs ${input.root}/${input.name}/postinstall.mjs`
@@ -78,7 +82,31 @@ async function publishDistribution(input: {
),
)
await publish(`${input.root}/${input.name}`, input.name, version)
if (dryRun) return
const files = await UpdateArtifact.upload({
version,
files: await Promise.all(
Object.keys(binaries).map((name) =>
archive(
path.join(input.root, name.replace("@opencode/", ""), "bin"),
name.slice(input.packagePrefix.length),
input.binary,
input.root,
),
),
),
dryRun,
})
const artifact = {
channel: Script.channel,
name: input.artifact,
distribution: "opencode",
version,
metadata: { files },
}
if (dryRun) {
console.log(`dry-run artifact: ${JSON.stringify(artifact)}`)
return
}
await UpdateArtifact.publish({
channel: Script.channel,
name: input.artifact,
@@ -86,21 +114,43 @@ async function publishDistribution(input: {
version,
metadata: { package: input.name },
})
await UpdateArtifact.publish(artifact)
}
await publishDistribution({
root: "./dist",
root,
name: pkg.name,
binary: "opencode2",
packagePrefix: "@opencode/cli-",
artifact: "cli",
})
if (existsSync("./dist/node")) {
if (existsSync(path.join(root, "node"))) {
await publishDistribution({
root: "./dist/node",
root: path.join(root, "node"),
name: "@opencode/cli-node",
binary: "opencode2-node",
packagePrefix: "@opencode/cli-node-",
artifact: "cli-node",
})
}
if ((Script.channel === "beta" || Script.channel === "latest") && Script.release) {
await $`bun ./script/publish-aur.ts ${dryRun ? ["--dry-run"] : []}`.env({ ...process.env, OPENCODE_CLI_DIST: root })
}
async function archive(bin: string, target: string, binary: string, directory: string) {
const executable = `${binary}${target.startsWith("windows-") ? ".exe" : ""}`
const source = path.join(bin, executable)
if (!(await Bun.file(source).exists()) || !Bun.file(source).size) throw new Error(`Missing binary: ${source}`)
// GitHub artifact downloads lose execute bits. Fixed timestamps make retries reproducible.
await chmod(source, 0o755)
await utimes(source, new Date("1980-01-01T00:00:00Z"), new Date("1980-01-01T00:00:00Z"))
const extension = target.startsWith("linux-") ? "tar.gz" : "zip"
const output = path.join(directory, `${binary}-${target}.${extension}`)
await rm(output, { force: true })
if (extension === "tar.gz") {
await $`tar --mtime=@0 --owner=0 --group=0 --numeric-owner -czf ${output} -C ${bin} ${executable}`
}
if (extension === "zip") await $`zip -X -q ${output} ${executable}`.cwd(bin)
return output
}