Pipelines: a built-in npm-publish step. It publishes the npm packages a job's kept .tgz files hold, and needs from: plus a packages list of the names it may publish; a name that isn't an npm package name is refused. Version 65 of shared· infra-pipeline· Oct 10 (2026-10-10 03:29 UTC) · Not checked
Version 64 · Files at version 65
2 files, 47 lines added, 1 removed.
--- a/src/pipeline/pipeline.ts
+++ b/src/pipeline/pipeline.ts
@@ -68,7 +68,7 @@
68 68 | { readonly ok: true; readonly file: PipelineFile } 69 69 | { readonly ok: false; readonly problems: readonly Problem[] }; 71 − export const BUILT_INS = ["deploy", "preview", "notify"] as const;
71 + export const BUILT_INS = ["deploy", "preview", "notify", "npm-publish"] as const; 72 72 export type BuiltIn = (typeof BUILT_INS)[number]; 74 74 /** Each built-in step's own settings, beside the keys every job has. */ @@ -76,8 +76,13 @@
76 76 deploy: ["worker", "staging", "live"], 79 + // The npm packages it may publish, from the .tgz files its from: job kept. 80 + "npm-publish": ["packages"], 83 + /** An npm package name: lower case, URL-safe, optionally under a @scope/. */ 84 + const NPM_NAME = /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/; 81 86 const TRIGGERS = ["publish", "draft", "green", "land", "hand"] as const; 82 87 const SIZES: readonly Size[] = ["small", "standard", "large"]; 83 88 const MACHINE_KEYS = ["image", "dockerfile", "size"] as const; @@ -277,6 +282,18 @@
277 282 for (const k of settings) if (j[k] !== undefined) withs[k] = j[k]; 278 283 if (uses === "deploy" && typeof j.worker !== "string") 279 284 say(`${at}.worker`, "names the Worker deploy ships, and is missing"); 285 + if (uses === "npm-publish") { 286 + if (j.from === undefined) 287 + say(`${at}.from`, "names the job whose kept .tgz files npm-publish publishes, and is missing"); 288 + const packages = j.packages; 289 + if (!Array.isArray(packages) || packages.length === 0) 290 + say(`${at}.packages`, "lists the npm packages npm-publish may publish, and is missing"); 292 + packages.forEach((p, i) => { 293 + if (typeof p !== "string" || p.length > 214 || !NPM_NAME.test(p)) 294 + say(`${at}.packages[${i}]`, `${q(p)} isn't an npm package name`); 282 299 needs: list(j.needs, `${at}.needs`, say, "a list of job names"), --- a/src/pipeline/test/pipeline.test.ts
+++ b/src/pipeline/test/pipeline.test.ts
@@ -216,6 +216,35 @@
216 216 ok(checkPipelines(one({ a: { run: "npm test" } }, { on: ["draft"] }))); 219 + it("npm-publish: the packages it may publish, from a job's kept files", () => { 220 + const pack = { run: "npm pack --pack-destination out", keep: ["out"] }; 221 + const read = checkPipelines( 224 + publish: { uses: "npm-publish", from: "p.pack", needs: ["pack"], packages: ["@scope/tool", "tool"] }, 228 + const job = read.ok ? read.file.pipelines[0]!.jobs.find((j) => j.name === "publish") : undefined; 229 + assert.equal(job?.uses, "npm-publish"); 230 + assert.deepEqual(job?.with, { packages: ["@scope/tool", "tool"] }); 231 + const ps = problems( 235 + a: { uses: "npm-publish", packages: ["tool"] }, 236 + b: { uses: "npm-publish", from: "p.pack" }, 237 + c: { uses: "npm-publish", from: "p.pack", packages: ["Tool", "@scope", 7] }, 241 + has(ps, "pipelines.p.jobs.a.from", /is missing/); 242 + has(ps, "pipelines.p.jobs.b.packages", /is missing/); 243 + has(ps, "pipelines.p.jobs.c.packages[0]", /isn't an npm package name/); 244 + has(ps, "pipelines.p.jobs.c.packages[1]", /isn't an npm package name/); 245 + has(ps, "pipelines.p.jobs.c.packages[2]", /isn't an npm package name/); 219 248 it("keys it doesn't know, at every level", () => { 220 249 const ps = problems(