mirror of
https://github.com/modelstudioai/cli.git
synced 2026-09-14 19:49:23 +08:00
3693f7dacb
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.
44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
import { mkdtempSync, renameSync, rmSync } from "fs";
|
|
import { tmpdir } from "os";
|
|
import { join } from "path";
|
|
|
|
import { PACKAGES, readPackageJson } from "./packages.mjs";
|
|
import { pnpmPack } from "./npm.mjs";
|
|
import { run } from "./proc.mjs";
|
|
|
|
function extractTarball(tarball, tempDir, key) {
|
|
run("tar", ["-xzf", tarball, "-C", tempDir], { stdio: "pipe" });
|
|
const extractDir = join(tempDir, `extract-${key}`);
|
|
renameSync(join(tempDir, "package"), extractDir);
|
|
return extractDir;
|
|
}
|
|
|
|
/**
|
|
* pnpm pack each package, then run publint / attw / gitleaks on the tarball
|
|
* or the extracted directory. attw only runs on packages that declare types.
|
|
*/
|
|
export function packAndScan({ log }) {
|
|
const tempDir = mkdtempSync(join(tmpdir(), "bailian-release-"));
|
|
try {
|
|
for (const pkg of PACKAGES) {
|
|
const json = readPackageJson(pkg);
|
|
log(`packing ${pkg.name}@${json.version}`);
|
|
const tarball = pnpmPack(pkg, tempDir, json);
|
|
const extractDir = extractTarball(tarball, tempDir, pkg.key);
|
|
|
|
log(`publint ${pkg.name}`);
|
|
run("npx", ["--yes", "publint", extractDir]);
|
|
|
|
if (json.types) {
|
|
log(`attw ${pkg.name}`);
|
|
run("npx", ["--yes", "@arethetypeswrong/cli", "--pack", extractDir]);
|
|
}
|
|
|
|
log(`gitleaks ${pkg.name}`);
|
|
run("gitleaks", ["detect", "--source", extractDir, "--no-git", "--redact"]);
|
|
}
|
|
} finally {
|
|
rmSync(tempDir, { recursive: true, force: true });
|
|
}
|
|
}
|