Files
Ryan Vogel 8ee61be65b ci: release OpenCode Browser with publish-browser-extension
cli/package.json is now the one release version: the store zip and the
extension bundled in the npm helper are stamped with it. Bumped to 0.0.2
(0.0.1 is on npm and in the store draft).

.github/workflows/publish-browser-extension.yml runs on a
browser-extension-v<version> tag (checked against cli/package.json) or by
hand: typecheck, build the helper and the store zip, smoke test the helper,
upload the zip as an artifact, then publish opencode-browser-cli to npm with
provenance (trusted publishing, or OPENCODE_BROWSER_NPM_TOKEN; skipped when the
version exists) and attach the zip to a GitHub release. Manual runs only
build unless `publish` is checked.

Verified: actionlint (only the repo's custom runner label is unknown to it);
locally, cli build + `bun run package` produced version 0.0.2 in both the zip
(no key) and the bundled extension, the built helper ran, and `npm pack
--dry-run` packs 0.0.2.
2026-10-03 19:25:25 -04:00

23 lines
1.2 KiB
TypeScript

// Builds the extension and zips it for the Chrome Web Store: release/opencode-browser-<version>.zip.
// The store assigns its own ID and rejects the `key` field, which only pins the ID of unpacked builds.
// The version comes from cli/package.json, the one release version for the zip and the npm helper.
import { $ } from "bun"
import { cp, mkdir, rm } from "node:fs/promises"
import path from "node:path"
const root = path.resolve(import.meta.dir, "..")
const staging = path.join(root, "release", "staging")
await $`bun run build`.cwd(root)
await rm(staging, { recursive: true, force: true })
await mkdir(staging, { recursive: true })
await cp(path.join(root, "dist"), staging, { recursive: true })
const manifest = await Bun.file(path.join(staging, "manifest.json")).json()
delete manifest.key
manifest.version = (await Bun.file(path.join(root, "cli", "package.json")).json()).version
await Bun.write(path.join(staging, "manifest.json"), JSON.stringify(manifest, null, 2) + "\n")
const zip = path.join(root, "release", `opencode-browser-${manifest.version}.zip`)
await rm(zip, { force: true })
await $`zip -qrX ${zip} . -x "*.map" -x ".DS_Store"`.cwd(staging)
await rm(staging, { recursive: true, force: true })
console.log(zip)