diff --git a/DIVERGENCES.md b/DIVERGENCES.md index 572d5af759..e35c4bf82a 100644 --- a/DIVERGENCES.md +++ b/DIVERGENCES.md @@ -13,7 +13,7 @@ future `packages/codev-*`) never conflict and are not tracked here. | --- | --- | --- | --- | | `packages/core/src/global.ts` | `const app = "opencode"` → `"codev-code"` | Config/data/cache/state dirs under `~/.config/codev-code` etc. | Keep ours (the one constant); take upstream's surrounding changes. | | `packages/opencode/src/index.ts` | `scriptName("opencode")` → `"codev"`; `show()` prefix check `"opencode "` → `"codev "` | Help/usage text shows the real user-facing command (the `codev` hub forwards unknown commands to this binary). The `show()` check must always match the scriptName. | Keep our two strings; take upstream's surrounding changes. | -| `packages/opencode/package.json` | bin key `opencode` → `codev-code` (shim path `./bin/opencode` unchanged) | Installed binary is named `codev-code`. | Keep our bin key; take upstream's other fields. | +| `packages/opencode/package.json` | bin key `opencode` → `codev-code` (shim path `./bin/opencode` unchanged); added `release` script | Installed binary is named `codev-code`; `bun run release` wraps build+publish (script/release.ts is a fork-only file). | Keep our bin key + release line; take upstream's other fields. | | `bun.lock` | Mirrors the bin key rename above | Lockfile records workspace bin mappings. | Regenerate with `bun install`; never hand-merge. | | `packages/opencode/script/build.ts` | Platform packages' `package.json` name `codev-code-` (dist dir names unchanged — the bun compile target derives from them) | npm publishing under the fork's names. | Keep our `name:` line; take upstream's surrounding changes. | | `packages/opencode/script/publish.ts` | `PUBLISH_NAME = "codev-code"` const; published-name→dir map; main pkg name + bin key; env-guarded exit before the Docker/AUR/Homebrew section | npm-only publishing under the fork's names (unscoped, public on npmjs); upstream's other channels target anomalyco infra. | Keep our names + early exit; take upstream's npm-section changes above the exit. | @@ -32,8 +32,8 @@ future `packages/codev-*`) never conflict and are not tracked here. upgrade command before distributing outside the team. - **Publishing**: npm packages publish as `codev-code` / `codev-code-` — unscoped, therefore PUBLIC on npmjs (like `codev-ai`). Local-only for now (no CI workflow), run from - `packages/opencode` with npm publish auth in place: - `OPENCODE_VERSION= OPENCODE_CHANNEL=latest bun run script/build.ts && bun run script/publish.ts`. + `packages/opencode` with npm publish auth in place: `bun run release ` (wraps + build.ts + publish.ts; `--skip-build` publishes an existing same-version dist/). Docker/AUR/Homebrew/GitHub-release channels are upstream-only and disabled. The binary inside platform packages is still named `opencode` (cosmetic). - **UI branding**: TUI logo (`UI.logo()`), desktop/web app names and assets — all still diff --git a/packages/opencode/package.json b/packages/opencode/package.json index 3f0e2637e2..bca039295f 100644 --- a/packages/opencode/package.json +++ b/packages/opencode/package.json @@ -12,6 +12,7 @@ "bench:test": "bun run script/bench-test-suite.ts", "profile:test": "bun run script/profile-test-files.ts", "build": "bun run script/build.ts", + "release": "bun run script/release.ts", "dev": "bun run --conditions=browser ./src/index.ts", "dev:temporary": "bun run --conditions=browser ./src/temporary.ts" }, diff --git a/packages/opencode/script/release.ts b/packages/opencode/script/release.ts new file mode 100644 index 0000000000..3a4a50c0d5 --- /dev/null +++ b/packages/opencode/script/release.ts @@ -0,0 +1,36 @@ +#!/usr/bin/env bun +import { $ } from "bun" + +// Local release wrapper (fork-only file): `bun run release [channel]`. +// Equivalent to running build.ts then publish.ts with OPENCODE_VERSION and +// OPENCODE_CHANNEL set — one value flows into the compiled binaries' +// --version output and all generated package.json manifests. Channel is the +// npm dist-tag and defaults to `latest`; pass e.g. `beta` for pre-releases. +// +// `--skip-build` publishes an existing dist/. The build stamps the version +// into the binaries, so only skip when dist/ was built with the SAME version. +const skipBuild = process.argv.includes("--skip-build") +const args = process.argv.slice(2).filter((a) => a !== "--skip-build") +const version = args[0] +const channel = args[1] ?? "latest" + +if (!version || !/^\d+\.\d+\.\d+(-[\w.]+)?$/.test(version)) { + console.error("Usage: bun run release [channel] [--skip-build]") + console.error(" e.g. bun run release 0.1.0") + process.exit(1) +} + +// Fail fast on auth before a 15+ minute build. With 2FA-on-publish npm may +// still prompt per published package (13 of them); a granular token +// (`npm config set //registry.npmjs.org/:_authToken `) avoids that. +if ((await $`npm whoami`.nothrow().quiet()).exitCode !== 0) { + console.error("Not logged in to npm. Run `npm login` (or configure an auth token) first.") + process.exit(1) +} + +const env = { ...process.env, OPENCODE_VERSION: version, OPENCODE_CHANNEL: channel } +if (!skipBuild) await $`bun ${import.meta.dirname}/build.ts`.env(env) +await $`bun ${import.meta.dirname}/publish.ts`.env(env) + +console.log(`\nReleased codev-code@${version} (dist-tag: ${channel})`) +console.log(`Verify: npm view codev-code@${version} && npm install -g codev-code`)