mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
A new pack-npm job applies the release version rewrite and runs the 14 library publish scripts in a pack-only mode (OPENCODE_NPM_PACK_DIR), with their typecheck, ui tests and codemode smoke install, and uploads the tarballs. It has only contents: read and no secrets. publish downloads them and sets OPENCODE_NPM_TARBALLS. script/publish.ts checks that every tarball exists and holds the expected name and version before it publishes anything, and each library script keeps its npm view check and then publishes its carried tarball instead of building again. Without either variable the scripts behave as before. The version rewrite moves to script/release-files.ts so publish and pack-npm share it.
35 lines
1,014 B
TypeScript
35 lines
1,014 B
TypeScript
#!/usr/bin/env bun
|
|
|
|
import { NpmLibraries } from "@opencode/script/npm"
|
|
import { $ } from "bun"
|
|
import { rm } from "node:fs/promises"
|
|
import { fileURLToPath } from "node:url"
|
|
import { pack } from "./pack"
|
|
|
|
process.chdir(fileURLToPath(new URL("..", import.meta.url)))
|
|
|
|
// SAFETY: this is the package's own manifest, which always has a name and a version.
|
|
const pkg = (await Bun.file("package.json").json()) as { name: string; version: string }
|
|
|
|
const tarball = `${pkg.name.replace("@", "").replace("/", "-")}-${pkg.version}.tgz`
|
|
|
|
if (!NpmLibraries.packDir && (await $`npm view ${pkg.name}@${pkg.version} version`.nothrow()).exitCode === 0) {
|
|
console.log(`already published ${pkg.name}@${pkg.version}`)
|
|
process.exit(0)
|
|
}
|
|
|
|
const carried = await NpmLibraries.carried(tarball)
|
|
|
|
if (carried) {
|
|
await NpmLibraries.publish(carried)
|
|
process.exit(0)
|
|
}
|
|
|
|
try {
|
|
await $`bun run typecheck`
|
|
await $`bun run test`
|
|
await pack()
|
|
await NpmLibraries.publish(tarball)
|
|
} finally {
|
|
await rm(tarball, { force: true })
|
|
}
|