feat(release): CI-driven publish pipeline via GitHub Actions + npm OIDC

Replace tools/release.mjs with two workflow_dispatch flows:

- stable: production environment gate (Required Reviewers) + lightweight git tag. Trusted Publishing (OIDC) removes the need for an npm token.
- channel beta: disposable 0.0.0-beta-<sha>-<date> versions on the corresponding dist-tag, no tag, no commit. Any collaborator can dispatch without npm credentials.

Pack-time scans via publint, attw, gitleaks; weekly Dependabot for npm + actions.
This commit is contained in:
若麒
2026-06-04 23:02:38 +08:00
parent 14371a0647
commit 3693f7dacb
15 changed files with 625 additions and 372 deletions
+51
View File
@@ -0,0 +1,51 @@
#!/usr/bin/env node
import { fileURLToPath } from "url";
import { packAndScan } from "./lib/pack-scan.mjs";
import { run } from "./lib/proc.mjs";
import { assertReadmeSync, loadAndValidatePackages } from "./lib/validate.mjs";
function log(msg = "") {
process.stdout.write(`${msg}\n`);
}
function step(msg) {
log(`\n==> ${msg}`);
}
/**
* Pure-validation pipeline. Reusable from publish-stable / publish-channel.
* Returns { coreJson, cliJson } for callers that need the parsed package.jsons.
*/
export async function runCheck() {
step("pnpm install --frozen-lockfile");
run("pnpm", ["install", "--frozen-lockfile"]);
step("metadata: README sync, version consistency, workspace:* dep");
assertReadmeSync();
const { coreJson, cliJson } = loadAndValidatePackages();
log(`bailian-cli-core@${coreJson.version}`);
log(`bailian-cli@${cliJson.version}`);
step("build bailian-cli-core");
run("pnpm", ["--filter", "bailian-cli-core", "run", "build"]);
step("build bailian-cli");
run("pnpm", ["--filter", "bailian-cli", "run", "build"]);
step("pack + scan (publint, attw, gitleaks)");
packAndScan({ log });
log("\nrelease check passed.");
return { coreJson, cliJson };
}
const invokedDirectly = process.argv[1] === fileURLToPath(import.meta.url);
if (invokedDirectly) {
try {
await runCheck();
} catch (error) {
process.stderr.write(`\nrelease check failed: ${error.message}\n`);
process.exit(1);
}
}