singularity-forge/scripts/bump-version.mjs
Tom Boucher a75167fab2 fix(ci): address 5 pipeline integrity issues from release audit (#4119)
- version-stamp.mjs: regenerate package-lock.json after dev version stamp
  (mirrors the same fix applied to bump-version.mjs in #4116)

- bump-version.mjs: regenerate root and web/package-lock.json after version
  bump so both lockfiles are always in sync at release time

- pipeline.yml: add post-bump validation step that verifies all package.json
  files parse as valid JSON before the release commit is made

- pipeline.yml: split "Commit, tag, and push" — commit+tag+rebase happen
  before build, but git push is deferred until after build and npm publish
  both succeed, preventing a broken tag from landing on main

- pipeline.yml: emit a :⚠️: annotation when live LLM tests fail so
  failures are visible in the Actions UI instead of silently swallowed

Closes #4118

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-13 08:56:12 -04:00

51 lines
2.2 KiB
JavaScript

#!/usr/bin/env node
/**
* Bump version in package.json, then sync platform packages and pkg/package.json.
* Usage: node scripts/bump-version.mjs <new-version>
*/
import { readFileSync, writeFileSync, existsSync } from "fs";
import { resolve, dirname } from "path";
import { execSync } from "child_process";
import { fileURLToPath } from "url";
const __dirname = dirname(fileURLToPath(import.meta.url));
const root = resolve(__dirname, "..");
const newVersion = process.argv[2];
if (!newVersion || !/^\d+\.\d+\.\d+$/.test(newVersion)) {
console.error("Usage: node scripts/bump-version.mjs <X.Y.Z>");
process.exit(1);
}
// 1. Update root package.json
const pkgPath = resolve(root, "package.json");
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
const oldVersion = pkg.version;
pkg.version = newVersion;
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
console.log(`[bump-version] package.json: ${oldVersion}${newVersion}`);
// 2. Update packages/pi-coding-agent/package.json (sync-pkg-version reads from here)
const piPkgPath = resolve(root, "packages", "pi-coding-agent", "package.json");
const piPkg = JSON.parse(readFileSync(piPkgPath, "utf-8"));
piPkg.version = newVersion;
writeFileSync(piPkgPath, JSON.stringify(piPkg, null, 2) + "\n");
console.log(`[bump-version] pi-coding-agent: ${oldVersion}${newVersion}`);
// 3. Sync platform package versions (reads from root package.json)
execSync("node native/scripts/sync-platform-versions.cjs", { cwd: root, stdio: "inherit" });
// 4. Sync pkg/package.json (reads from pi-coding-agent)
execSync("node scripts/sync-pkg-version.cjs", { cwd: root, stdio: "inherit" });
// 5. Regenerate root package-lock.json to match the new version.
// --package-lock-only updates the lockfile in-place without touching node_modules.
execSync("npm install --package-lock-only --ignore-scripts", { cwd: root, stdio: "inherit" });
console.log(`[bump-version] package-lock.json regenerated at ${newVersion}`);
// 6. Regenerate web/package-lock.json if the web app is present.
const webDir = resolve(root, "web");
if (existsSync(webDir)) {
execSync("npm install --package-lock-only --ignore-scripts", { cwd: webDir, stdio: "inherit" });
console.log(`[bump-version] web/package-lock.json regenerated`);
}