Skip to content

Don't rewrite it in Rust. Rewrite the 5% that's slow: profile your app, port the hot functions with your coding agent, prove they behave the same. Python, JS/TS, Ruby, Java, Kotlin, Go, PHP, C/C++, C#, R.

release: stage npm packages (the token may only stage)

EL4CTEOccf46b49daa0
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index b3d125a..25bd117 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -78,7 +78,8 @@ jobs:
pattern: bin-*
path: dist
- if: env.NODE_AUTH_TOKEN != ''
- run: node npm/publish.mjs "${GITHUB_REF_NAME#v}" dist
+ # the token may only stage: approve each version with 2FA on npmjs.com
+ run: node npm/publish.mjs "${GITHUB_REF_NAME#v}" dist --stage
crates:
needs: build
diff --git a/npm/publish.mjs b/npm/publish.mjs
index 613c578..1c739cc 100644
--- a/npm/publish.mjs
+++ b/npm/publish.mjs
@@ -1,14 +1,16 @@
// Publishes the npm packages from release binaries:
-// node npm/publish.mjs <version> <dir with bin-<rust target>/fast-anything[.exe]> [--dry-run]
+// node npm/publish.mjs <version> <dir with bin-<rust target>/fast-anything[.exe]> [--dry-run] [--stage]
+// --stage: npm stage publish, for tokens that may only stage (each version is then approved with 2FA on npmjs.com).
// One package per platform (@el4cteo/fast-anything-<os>-<cpu>) plus the @el4cteo/fast-anything launcher.
import { execFileSync } from "node:child_process";
import { chmodSync, copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
-const [version, dist, flag] = process.argv.slice(2);
-if (!version || !dist) throw new Error("usage: node npm/publish.mjs <version> <dist> [--dry-run]");
-const dry = flag === "--dry-run";
+const [version, dist, ...flags] = process.argv.slice(2);
+if (!version || !dist) throw new Error("usage: node npm/publish.mjs <version> <dist> [--dry-run] [--stage]");
+const dry = flags.includes("--dry-run");
+const stage = flags.includes("--stage");
const here = path.dirname(fileURLToPath(import.meta.url));
const root = path.resolve(here, "..");
const out = path.join(root, "target", "npm");
@@ -24,7 +26,7 @@ const TARGETS = {
const main = JSON.parse(readFileSync(path.join(here, "fast-anything", "package.json"), "utf8"));
const publish = (dir) => {
const provenance = process.env.GITHUB_ACTIONS ? ["--provenance"] : [];
- const args = ["publish", "--access", "public", ...(dry ? ["--dry-run"] : provenance)];
+ const args = [...(stage ? ["stage"] : []), "publish", "--access", "public", ...(dry ? ["--dry-run"] : provenance)];
execFileSync("npm", args, { cwd: dir, stdio: "inherit", shell: process.platform === "win32" });
};