@intentius/chant 0.124.100 → 0.124.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action-pins.d.ts +2 -0
- package/dist/action-pins.js +3 -0
- package/dist/ci-detect.d.ts +13 -0
- package/dist/ci-detect.js +12 -0
- package/dist/ci-system.d.ts +66 -0
- package/dist/ci-system.js +61 -0
- package/dist/cli/handlers/build.js +27 -0
- package/dist/cli/handlers/release-doctor.d.ts +12 -0
- package/dist/cli/handlers/release-doctor.js +118 -0
- package/dist/cli/handlers/release-init.d.ts +10 -0
- package/dist/cli/handlers/release-init.js +342 -0
- package/dist/cli/handlers/release.d.ts +42 -1
- package/dist/cli/handlers/release.js +656 -31
- package/dist/cli/handlers/run-generate.js +11 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +44 -101
- package/dist/cli/parse-args.js +48 -0
- package/dist/cli/registry.d.ts +16 -0
- package/dist/cli/release-commands/artifacts.d.ts +3 -0
- package/dist/cli/release-commands/artifacts.js +14 -0
- package/dist/cli/release-commands/candidates.d.ts +3 -0
- package/dist/cli/release-commands/candidates.js +16 -0
- package/dist/cli/release-commands/changed.d.ts +3 -0
- package/dist/cli/release-commands/changed.js +14 -0
- package/dist/cli/release-commands/compose.d.ts +3 -0
- package/dist/cli/release-commands/compose.js +16 -0
- package/dist/cli/release-commands/cut.d.ts +3 -0
- package/dist/cli/release-commands/cut.js +49 -0
- package/dist/cli/release-commands/doctor.d.ts +3 -0
- package/dist/cli/release-commands/doctor.js +14 -0
- package/dist/cli/release-commands/export.d.ts +3 -0
- package/dist/cli/release-commands/export.js +12 -0
- package/dist/cli/release-commands/images.d.ts +3 -0
- package/dist/cli/release-commands/images.js +13 -0
- package/dist/cli/release-commands/index.d.ts +8 -0
- package/dist/cli/release-commands/index.js +52 -0
- package/dist/cli/release-commands/init.d.ts +3 -0
- package/dist/cli/release-commands/init.js +16 -0
- package/dist/cli/release-commands/list.d.ts +3 -0
- package/dist/cli/release-commands/list.js +10 -0
- package/dist/cli/release-commands/next.d.ts +3 -0
- package/dist/cli/release-commands/next.js +13 -0
- package/dist/cli/release-commands/publish.d.ts +3 -0
- package/dist/cli/release-commands/publish.js +22 -0
- package/dist/cli/release-commands/stamp.d.ts +3 -0
- package/dist/cli/release-commands/stamp.js +15 -0
- package/dist/cli/release-commands/status.d.ts +3 -0
- package/dist/cli/release-commands/status.js +17 -0
- package/dist/cli/release-commands/tag.d.ts +3 -0
- package/dist/cli/release-commands/tag.js +12 -0
- package/dist/cli/release-commands/types.d.ts +20 -0
- package/dist/cli/release-commands/types.js +1 -0
- package/dist/cli/release-commands/verify.d.ts +3 -0
- package/dist/cli/release-commands/verify.js +15 -0
- package/dist/cli/release-commands/workflow.d.ts +3 -0
- package/dist/cli/release-commands/workflow.js +13 -0
- package/dist/components/cli-support.d.ts +1 -1
- package/dist/components/cli-support.js +1 -1
- package/dist/config-environments.d.ts +8 -1
- package/dist/config-environments.js +2 -0
- package/dist/config.d.ts +294 -9
- package/dist/config.js +100 -5
- package/dist/floor-table.data.js +15 -1
- package/dist/forge-remote.d.ts +13 -0
- package/dist/forge-remote.js +15 -0
- package/dist/lexicon.d.ts +41 -2
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +62 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.js +270 -3
- package/dist/lifecycle/publish-attachments.d.ts +2 -1
- package/dist/lifecycle/publish-attachments.js +19 -2
- package/dist/lifecycle/publish-cargo.d.ts +99 -0
- package/dist/lifecycle/publish-cargo.js +412 -0
- package/dist/lifecycle/publish-credentials.d.ts +1 -1
- package/dist/lifecycle/publish-credentials.js +8 -0
- package/dist/lifecycle/publish-declaration.d.ts +199 -4
- package/dist/lifecycle/publish-declaration.js +200 -9
- package/dist/lifecycle/publish-forge.d.ts +45 -2
- package/dist/lifecycle/publish-forge.js +434 -34
- package/dist/lifecycle/publish-git-ssh.d.ts +15 -0
- package/dist/lifecycle/publish-git-ssh.js +30 -4
- package/dist/lifecycle/publish-github.d.ts +40 -2
- package/dist/lifecycle/publish-github.js +100 -3
- package/dist/lifecycle/publish-homebrew.d.ts +7 -9
- package/dist/lifecycle/publish-homebrew.js +34 -197
- package/dist/lifecycle/publish-index.d.ts +141 -0
- package/dist/lifecycle/publish-index.js +719 -0
- package/dist/lifecycle/publish-marketplace.js +77 -0
- package/dist/lifecycle/publish-mcp-registry.d.ts +66 -0
- package/dist/lifecycle/publish-mcp-registry.js +306 -0
- package/dist/lifecycle/publish-npm.js +165 -2
- package/dist/lifecycle/publish-oci.d.ts +34 -1
- package/dist/lifecycle/publish-oci.js +246 -7
- package/dist/lifecycle/publish-pypi.d.ts +136 -0
- package/dist/lifecycle/publish-pypi.js +657 -0
- package/dist/lifecycle/publish-record.d.ts +6 -3
- package/dist/lifecycle/publish-record.js +6 -3
- package/dist/lifecycle/publish-signing.d.ts +147 -0
- package/dist/lifecycle/publish-signing.js +257 -0
- package/dist/lifecycle/publish-targets.d.ts +27 -1
- package/dist/lifecycle/publish-targets.js +80 -0
- package/dist/lifecycle/publish-tauri.js +43 -0
- package/dist/lifecycle/publish-train-names.d.ts +54 -0
- package/dist/lifecycle/publish-train-names.js +118 -0
- package/dist/lifecycle/publish-verify.d.ts +121 -0
- package/dist/lifecycle/publish-verify.js +130 -0
- package/dist/lifecycle/query.js +8 -0
- package/dist/lifecycle/release-artifacts.d.ts +212 -0
- package/dist/lifecycle/release-artifacts.js +571 -0
- package/dist/lifecycle/release-changelog.d.ts +13 -1
- package/dist/lifecycle/release-changelog.js +35 -2
- package/dist/lifecycle/release-cut.d.ts +58 -3
- package/dist/lifecycle/release-cut.js +132 -34
- package/dist/lifecycle/release-doctor.d.ts +113 -0
- package/dist/lifecycle/release-doctor.js +996 -0
- package/dist/lifecycle/release-green.d.ts +86 -0
- package/dist/lifecycle/release-green.js +286 -0
- package/dist/lifecycle/release-init.d.ts +255 -0
- package/dist/lifecycle/release-init.js +859 -0
- package/dist/lifecycle/release-intents.d.ts +73 -0
- package/dist/lifecycle/release-intents.js +128 -0
- package/dist/lifecycle/release-next.d.ts +111 -0
- package/dist/lifecycle/release-next.js +252 -0
- package/dist/lifecycle/release-prerelease.d.ts +19 -0
- package/dist/lifecycle/release-prerelease.js +30 -0
- package/dist/lifecycle/release-publish.d.ts +256 -10
- package/dist/lifecycle/release-publish.js +246 -34
- package/dist/lifecycle/release-status-change.d.ts +226 -0
- package/dist/lifecycle/release-status-change.js +478 -0
- package/dist/lifecycle/release-status.d.ts +11 -0
- package/dist/lifecycle/release-status.js +1 -1
- package/dist/lifecycle/release-store.d.ts +73 -2
- package/dist/lifecycle/release-store.js +32 -1
- package/dist/lifecycle/release-tag.d.ts +142 -0
- package/dist/lifecycle/release-tag.js +323 -0
- package/dist/lifecycle/release-verify.d.ts +73 -1
- package/dist/lifecycle/release-verify.js +117 -2
- package/dist/lifecycle/release-version-formats.d.ts +73 -0
- package/dist/lifecycle/release-version-formats.js +570 -0
- package/dist/lifecycle/release-version.d.ts +58 -10
- package/dist/lifecycle/release-version.js +164 -36
- package/dist/lifecycle/release-workstation.d.ts +3 -2
- package/dist/lifecycle/release-workstation.js +3 -2
- package/dist/op/generate-pipeline.js +1 -1
- package/dist/pr-forge-base.js +4 -2
- package/dist/pr-forge.d.ts +20 -2
- package/dist/pr-forge.js +46 -10
- package/dist/release-floors.d.ts +8 -1
- package/dist/release-floors.js +9 -2
- package/dist/tool-pins.d.ts +38 -0
- package/dist/tool-pins.js +54 -0
- package/dist/wave-runtime.mjs +337 -334
- package/dist/workspace/ci-forge.d.ts +17 -0
- package/dist/workspace/ci-forge.js +17 -0
- package/dist/workspace/ci-init.js +1 -1
- package/dist/workspace/composites.schema.json +1 -0
- package/dist/workspace/declaration.d.ts +8 -0
- package/dist/workspace/declaration.js +12 -0
- package/dist/workspace/declaration.schema.json +8 -0
- package/dist/workspace/environments.d.ts +2 -0
- package/dist/workspace/environments.js +1 -1
- package/dist/workspace/identity-gate-rule.d.ts +61 -5
- package/dist/workspace/identity-gate-rule.js +81 -12
- package/dist/workspace/member-pipeline.d.ts +2 -1
- package/dist/workspace/member-pipeline.js +5 -2
- package/dist/workspace/reason-codes.d.ts +2 -0
- package/dist/workspace/reason-codes.js +3 -1
- package/dist/workspace/release-changed.d.ts +75 -4
- package/dist/workspace/release-changed.js +205 -34
- package/dist/workspace/release-changed.schema.json +20 -2
- package/dist/workspace/release-steps/artifacts.d.ts +7 -0
- package/dist/workspace/release-steps/artifacts.js +45 -0
- package/dist/workspace/release-steps/builds.d.ts +12 -0
- package/dist/workspace/release-steps/builds.js +38 -0
- package/dist/workspace/release-steps/doctor.d.ts +8 -0
- package/dist/workspace/release-steps/doctor.js +14 -0
- package/dist/workspace/release-steps/goreleaser.d.ts +16 -0
- package/dist/workspace/release-steps/goreleaser.js +36 -0
- package/dist/workspace/release-steps/green.d.ts +3 -0
- package/dist/workspace/release-steps/green.js +6 -0
- package/dist/workspace/release-steps/images.d.ts +22 -0
- package/dist/workspace/release-steps/images.js +59 -0
- package/dist/workspace/release-steps/index.d.ts +9 -0
- package/dist/workspace/release-steps/index.js +46 -0
- package/dist/workspace/release-steps/pypi.d.ts +15 -0
- package/dist/workspace/release-steps/pypi.js +21 -0
- package/dist/workspace/release-steps/qemu.d.ts +21 -0
- package/dist/workspace/release-steps/qemu.js +35 -0
- package/dist/workspace/release-steps/signing.d.ts +18 -0
- package/dist/workspace/release-steps/signing.js +30 -0
- package/dist/workspace/release-steps/stamp.d.ts +3 -0
- package/dist/workspace/release-steps/stamp.js +4 -0
- package/dist/workspace/release-steps/targets.d.ts +31 -0
- package/dist/workspace/release-steps/targets.js +40 -0
- package/dist/workspace/release-steps/types.d.ts +104 -0
- package/dist/workspace/release-steps/types.js +2 -0
- package/dist/workspace/release-steps/verify.d.ts +3 -0
- package/dist/workspace/release-steps/verify.js +4 -0
- package/dist/workspace/release-toolchains.d.ts +59 -0
- package/dist/workspace/release-toolchains.js +133 -0
- package/dist/workspace/release-train-workflow.d.ts +29 -0
- package/dist/workspace/release-train-workflow.js +85 -0
- package/dist/workspace/release-train.d.ts +3 -1
- package/dist/workspace/release-train.js +20 -3
- package/dist/workspace/release-workflow.d.ts +160 -61
- package/dist/workspace/release-workflow.js +539 -193
- package/dist/workspace/releases.schema.json +70 -1
- package/dist/workspace/search-contract.d.ts +1 -1
- package/dist/workspace/security.js +9 -2
- package/dist/workspace/train-cut.d.ts +182 -0
- package/dist/workspace/train-cut.js +482 -0
- package/dist/workspace/train-prepare.d.ts +61 -0
- package/dist/workspace/train-prepare.js +267 -0
- package/dist/workspace/train-publish.d.ts +177 -0
- package/dist/workspace/train-publish.js +575 -0
- package/dist/workspace/train-range-labels.d.ts +33 -0
- package/dist/workspace/train-range-labels.js +109 -0
- package/dist/workspace/trust/seal.d.ts +13 -3
- package/dist/workspace/trust/seal.js +14 -4
- package/dist/workspace/work-cli.d.ts +3 -2
- package/dist/workspace/work-cli.js +3 -2
- package/dist/workspace/workspace-ledger.d.ts +14 -1
- package/dist/workspace/workspace-ledger.js +33 -7
- package/package.json +1 -1
|
@@ -57,8 +57,10 @@ import { tmpdir } from "node:os";
|
|
|
57
57
|
import { join, relative, resolve, sep } from "node:path";
|
|
58
58
|
import { packageSbom } from "./publish-attachments.js";
|
|
59
59
|
import { checkReleaseDigest, fileDigest, isDir, memberFile, publishTargetKey } from "./publish-targets.js";
|
|
60
|
+
import { trainName } from "./publish-train-names.js";
|
|
60
61
|
import { readPins, unknownPins } from "./release-images.js";
|
|
61
|
-
import { NPM_STAGE_TAG, PublishTargetError } from "./release-publish.js";
|
|
62
|
+
import { NPM_STAGE_TAG, PublishTargetError, statusMessage } from "./release-publish.js";
|
|
63
|
+
import { prereleaseOf } from "./release-prerelease.js";
|
|
62
64
|
/** npm's output when a publish could not authenticate, as publish-packages.sh matches it. */
|
|
63
65
|
const NPM_AUTH_FAILED = /ENEEDAUTH|E401|need auth/;
|
|
64
66
|
/** Read a package's name and version, from its directory or its packed `.tgz`, and find the SBOM it carries. */
|
|
@@ -101,6 +103,24 @@ function readPackage(ctx, path, sbom) {
|
|
|
101
103
|
const carried = packageSbom(abs, directory, path, pkg.name, sbom, ctx.requireSbom === true);
|
|
102
104
|
return { path, abs, name: pkg.name, version: pkg.version, ...(digest ? { digest } : {}), ...(carried ? { sbom: carried.file } : {}) };
|
|
103
105
|
}
|
|
106
|
+
/** A package's package.json, from its directory or its packed `.tgz`, or null when it can't be read. Checks no digest (#5136). */
|
|
107
|
+
function packageManifest(abs) {
|
|
108
|
+
try {
|
|
109
|
+
const text = isDir(abs)
|
|
110
|
+
? readFileSync(join(abs, "package.json"), "utf-8")
|
|
111
|
+
: execFileSync("tar", ["-xzOf", abs, "package/package.json"], { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] });
|
|
112
|
+
const pkg = JSON.parse(text);
|
|
113
|
+
return pkg !== null && typeof pkg === "object" ? pkg : null;
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/** `<name>@<version>` split at its last `@`, so a scoped name keeps its own. */
|
|
120
|
+
function splitSpec(spec) {
|
|
121
|
+
const at = spec.lastIndexOf("@");
|
|
122
|
+
return at > 0 ? [spec.slice(0, at), spec.slice(at + 1)] : [spec, ""];
|
|
123
|
+
}
|
|
104
124
|
/** The arguments of one `npm publish`, which stages under `tag`. */
|
|
105
125
|
export function npmPublishArgs(decl, abs, ctx, tag = NPM_STAGE_TAG) {
|
|
106
126
|
return [
|
|
@@ -251,7 +271,7 @@ export function npmTarget(decl, deps) {
|
|
|
251
271
|
const now = deps.now ?? Date.now;
|
|
252
272
|
const registry = decl.registry ?? "the registry npm's config names";
|
|
253
273
|
const shown = (tag) => `${registry}, dist-tag ${tag}`;
|
|
254
|
-
const revealTag = (ctx) => ctx.tag ?? "latest";
|
|
274
|
+
const revealTag = (ctx) => ctx.tag ?? prereleaseOf(ctx.label)?.distTag ?? "latest";
|
|
255
275
|
// Under `stage: false` a package goes straight to the reveal tag, and the reveal moves no tag (#4040).
|
|
256
276
|
const staging = decl.stage !== false;
|
|
257
277
|
const stageTag = (ctx) => (staging ? NPM_STAGE_TAG : revealTag(ctx));
|
|
@@ -392,8 +412,151 @@ export function npmTarget(decl, deps) {
|
|
|
392
412
|
rmSync(dir, { recursive: true, force: true });
|
|
393
413
|
}
|
|
394
414
|
};
|
|
415
|
+
/** Whether `dist-tags.<tag>` of `name` is `version` yet; a 404 is not yet, any other failure is the registry's error. */
|
|
416
|
+
const tagged = async (ctx, name, version, tag) => {
|
|
417
|
+
const r = await npm(ctx, ["view", name, `dist-tags.${tag}`, ...(decl.registry ? ["--registry", decl.registry] : [])]);
|
|
418
|
+
if (r.code === 0)
|
|
419
|
+
return r.output.some((l) => l.trim() === version || l.trim() === JSON.stringify(version));
|
|
420
|
+
if (r.output.some((l) => NPM_VIEW_NOT_YET.test(l)))
|
|
421
|
+
return false;
|
|
422
|
+
const said = r.output.filter((l) => /^npm (error|ERR!)/.test(l)).at(-1) ?? r.output.at(-1) ?? "npm printed nothing";
|
|
423
|
+
throw new PublishTargetError("publish-npm-registry-failed", `npm view ${name} dist-tags.${tag} exited ${r.code} while the train waited for ${name}@${version} to be ${tag}: ${said}`, "Each package was published. Once the registry answers, run the publish again: it publishes nothing twice.");
|
|
424
|
+
};
|
|
395
425
|
return {
|
|
396
426
|
kind: "npm",
|
|
427
|
+
stagesVisibly: !staging,
|
|
428
|
+
async names(ctx) {
|
|
429
|
+
const provides = [];
|
|
430
|
+
const needs = new Set();
|
|
431
|
+
for (const path of decl.packages) {
|
|
432
|
+
const pkg = packageManifest(memberFile(ctx.cwd, path));
|
|
433
|
+
if (!pkg)
|
|
434
|
+
continue;
|
|
435
|
+
if (typeof pkg.name === "string")
|
|
436
|
+
provides.push(trainName("npm", pkg.name));
|
|
437
|
+
for (const field of ["dependencies", "peerDependencies", "optionalDependencies"]) {
|
|
438
|
+
const deps = pkg[field];
|
|
439
|
+
if (deps && typeof deps === "object")
|
|
440
|
+
for (const n of Object.keys(deps))
|
|
441
|
+
needs.add(trainName("npm", n));
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
return { provides, needs: [...needs].filter((n) => !provides.includes(n)) };
|
|
445
|
+
},
|
|
446
|
+
async published(ctx) {
|
|
447
|
+
for (const path of decl.packages) {
|
|
448
|
+
const pkg = packageManifest(memberFile(ctx.cwd, path));
|
|
449
|
+
if (!pkg || typeof pkg.name !== "string")
|
|
450
|
+
return null;
|
|
451
|
+
const version = ctx.label ?? (typeof pkg.version === "string" ? pkg.version : null);
|
|
452
|
+
if (version === null)
|
|
453
|
+
return null;
|
|
454
|
+
if (!(await onRegistry(ctx, { path, abs: "", name: pkg.name, version })))
|
|
455
|
+
return false;
|
|
456
|
+
}
|
|
457
|
+
return true;
|
|
458
|
+
},
|
|
459
|
+
async visible(ctx, published) {
|
|
460
|
+
const tag = revealTag(ctx);
|
|
461
|
+
const cap = decl.registryWait === undefined ? undefined : decl.registryWait * 1000;
|
|
462
|
+
const start = now();
|
|
463
|
+
let logged;
|
|
464
|
+
let missing = published.items.filter((i) => !i.refused && i.attachment === undefined).map((i) => splitSpec(i.name));
|
|
465
|
+
for (;;) {
|
|
466
|
+
const still = [];
|
|
467
|
+
for (const [name, version] of missing)
|
|
468
|
+
if (!(await tagged(ctx, name, version, tag)))
|
|
469
|
+
still.push([name, version]);
|
|
470
|
+
missing = still;
|
|
471
|
+
if (missing.length === 0)
|
|
472
|
+
return;
|
|
473
|
+
const names = missing.map(([n, v]) => `${n}@${v}`).join(", ");
|
|
474
|
+
const waited = now() - start;
|
|
475
|
+
if (cap !== undefined && waited >= cap) {
|
|
476
|
+
throw new PublishTargetError("publish-npm-not-served", `the registry did not resolve ${tag} to ${names} within ${Math.round(cap / 1000)}s, so the packages that depend on them were not published`, "Once npm serves them, run the publish again: it publishes nothing twice and goes on from there. `registryWait` sets the wait.");
|
|
477
|
+
}
|
|
478
|
+
if (logged === undefined || now() - logged >= NPM_REGISTRY_PROGRESS_MS) {
|
|
479
|
+
ctx.log(`waiting for ${tag} to resolve to ${names}${waited > 0 ? ` (${Math.round(waited / 1000)}s so far)` : ""}`);
|
|
480
|
+
logged = now();
|
|
481
|
+
}
|
|
482
|
+
await sleep(NPM_REGISTRY_POLL_MS);
|
|
483
|
+
}
|
|
484
|
+
},
|
|
485
|
+
/**
|
|
486
|
+
* #5163: deprecate marks each version with `npm deprecate`; yank does
|
|
487
|
+
* that and moves the dist-tag off it to the head release's version;
|
|
488
|
+
* restore clears the message and moves the tag back when this release is
|
|
489
|
+
* the head. npm never unpublishes here: its policy allows that only for
|
|
490
|
+
* 72 hours and with no dependents, and a name and version can never be
|
|
491
|
+
* published again after it.
|
|
492
|
+
*/
|
|
493
|
+
async setStatus(ctx) {
|
|
494
|
+
const reg = decl.registry ? ["--registry", decl.registry] : [];
|
|
495
|
+
// The tag the publish moved: the channel, else a prerelease's dist-tag (#5166), else latest.
|
|
496
|
+
const tag = revealTag(ctx);
|
|
497
|
+
const pkgs = ctx.revealed.filter((i) => i.attachment === undefined && !i.refused).map((i) => splitSpec(i.name));
|
|
498
|
+
const actions = [];
|
|
499
|
+
const fail = (what, r, fix) => {
|
|
500
|
+
throw new PublishTargetError("release-status-npm-failed", `${what} exited ${r.code}: ${r.output.filter((l) => /^npm (error|ERR!)/.test(l)).at(-1) ?? r.output.at(-1) ?? "npm printed nothing"}`, fix);
|
|
501
|
+
};
|
|
502
|
+
const message = ctx.status === "active" ? "" : statusMessage(ctx);
|
|
503
|
+
for (const [name, version] of pkgs) {
|
|
504
|
+
const what = ctx.status === "active" ? `npm deprecate ${name}@${version} "" (clears the deprecation)` : `npm deprecate ${name}@${version} "${message}"`;
|
|
505
|
+
if (ctx.apply) {
|
|
506
|
+
const r = await npm(ctx, ["deprecate", `${name}@${version}`, message, ...reg]);
|
|
507
|
+
for (const line of r.output)
|
|
508
|
+
ctx.log(` ${line}`);
|
|
509
|
+
if (r.code !== 0)
|
|
510
|
+
fail(`npm deprecate ${name}@${version}`, r, "Deprecating needs npm credentials that may publish the package.");
|
|
511
|
+
}
|
|
512
|
+
actions.push({ what });
|
|
513
|
+
}
|
|
514
|
+
if (ctx.status === "yanked" && pkgs.length > 0) {
|
|
515
|
+
// npm's unpublish rules: within 72 hours and with no dependents, and the version can never be published again.
|
|
516
|
+
actions.push({ what: `not unpublished: ${pkgs.map(([n, v]) => `${n}@${v}`).join(", ")} stay on the registry, deprecated, since npm allows an unpublish only within 72 hours and with no dependents` });
|
|
517
|
+
}
|
|
518
|
+
if (ctx.status === "deprecated")
|
|
519
|
+
return actions;
|
|
520
|
+
// The dist-tag: off this release on a yank, back onto it on a restore when it is the head.
|
|
521
|
+
const headPkgs = new Map((ctx.head?.items ?? []).filter((i) => i.attachment === undefined && !i.refused).map((i) => splitSpec(i.name)));
|
|
522
|
+
const toHead = ctx.head !== null && ctx.head.releaseDigest !== ctx.release.releaseDigest;
|
|
523
|
+
if (ctx.status === "active" && !(ctx.head && ctx.head.releaseDigest === ctx.release.releaseDigest))
|
|
524
|
+
return actions;
|
|
525
|
+
for (const [name, version] of pkgs) {
|
|
526
|
+
const target = ctx.status === "active" ? version : headPkgs.get(name);
|
|
527
|
+
if (target === undefined) {
|
|
528
|
+
actions.push({
|
|
529
|
+
what: `${tag} of ${name} stays where it is`,
|
|
530
|
+
refused: {
|
|
531
|
+
code: "release-status-no-previous",
|
|
532
|
+
message: `no earlier active release published ${name} under ${tag}, and npm keeps ${tag} on some version, so it can't move off ${version}`,
|
|
533
|
+
fix: toHead ? undefined : "Cut and publish a release to move it to, or restore an earlier one.",
|
|
534
|
+
},
|
|
535
|
+
});
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
const what = ctx.status === "active" ? `npm dist-tag add ${name}@${version} ${tag}` : `npm dist-tag add ${name}@${target} ${tag}, if ${tag} is ${version}`;
|
|
539
|
+
if (!ctx.apply) {
|
|
540
|
+
actions.push({ what });
|
|
541
|
+
continue;
|
|
542
|
+
}
|
|
543
|
+
const view = await npm(ctx, ["view", name, `dist-tags.${tag}`, ...reg]);
|
|
544
|
+
if (view.code !== 0)
|
|
545
|
+
fail(`npm view ${name} dist-tags.${tag}`, view);
|
|
546
|
+
const now = view.output.map((l) => l.trim().replace(/^"|"$/g, "")).find((l) => l.length > 0 && !/^npm\s/.test(l)) ?? "";
|
|
547
|
+
if (now === target || (ctx.status === "yanked" && now !== version)) {
|
|
548
|
+
actions.push({ what: `${tag} of ${name} is ${now || "unset"}; not moved`, already: true });
|
|
549
|
+
continue;
|
|
550
|
+
}
|
|
551
|
+
const r = await npm(ctx, ["dist-tag", "add", `${name}@${target}`, tag, ...reg]);
|
|
552
|
+
for (const line of r.output)
|
|
553
|
+
ctx.log(` ${line}`);
|
|
554
|
+
if (r.code !== 0)
|
|
555
|
+
fail(`npm dist-tag add ${name}@${target} ${tag}`, r, `Moving a dist-tag needs npm credentials that may change dist-tags; over OIDC that is "Allow npm dist-tag" on the package's trusted-publisher record.`);
|
|
556
|
+
actions.push({ what: `npm dist-tag add ${name}@${target} ${tag}` });
|
|
557
|
+
}
|
|
558
|
+
return actions;
|
|
559
|
+
},
|
|
397
560
|
name: `npm (${decl.packages.length} package${decl.packages.length === 1 ? "" : "s"})`,
|
|
398
561
|
destination: `npm ${registry}`,
|
|
399
562
|
credentialEnv: [],
|
|
@@ -22,6 +22,13 @@
|
|
|
22
22
|
* discover` or `cosign tree` finds them. A referrer the registry already
|
|
23
23
|
* holds is not pushed again.
|
|
24
24
|
*
|
|
25
|
+
* When the publish signs (#5164, ./publish-signing.ts), the stage also
|
|
26
|
+
* pushes a cosign signature and SLSA provenance of the image, each a Sigstore
|
|
27
|
+
* bundle in an artifact manifest whose subject is the image. On a registry
|
|
28
|
+
* without the referrers API (GHCR, Docker Hub) they are listed under the
|
|
29
|
+
* referrers tag `sha256-<hex>`, as cosign does. An image that already has a
|
|
30
|
+
* bundle with the same predicate type is not signed again.
|
|
31
|
+
*
|
|
25
32
|
* Credentials come from `usernameEnv` and `passwordEnv` (default
|
|
26
33
|
* `OCI_USERNAME`, `OCI_PASSWORD`), or else from the `auths` entry for the
|
|
27
34
|
* registry in the docker config file (`$DOCKER_CONFIG/config.json` or
|
|
@@ -36,6 +43,7 @@
|
|
|
36
43
|
* and a one-part Docker Hub name is under `library/`.
|
|
37
44
|
*/
|
|
38
45
|
import { type Attachment } from "./publish-attachments.js";
|
|
46
|
+
import { type Credential } from "./publish-credentials.js";
|
|
39
47
|
import type { OciPublishDeclaration } from "./publish-declaration.js";
|
|
40
48
|
import { type PublishContext, type PublishDeps, type PublishTarget } from "./release-publish.js";
|
|
41
49
|
/** A repository reference split into where the registry is and the name in it. */
|
|
@@ -48,10 +56,28 @@ export interface OciRepository {
|
|
|
48
56
|
name: string;
|
|
49
57
|
}
|
|
50
58
|
export declare function parseRepository(repository: string): OciRepository;
|
|
59
|
+
/** The credential for `repo`: the declared variables, else the docker config's `auths` entry. */
|
|
60
|
+
export declare function ociCredential(decl: Pick<OciPublishDeclaration, "usernameEnv" | "passwordEnv">, repo: OciRepository, ctx: Pick<PublishContext, "env" | "redactor">): {
|
|
61
|
+
username: string;
|
|
62
|
+
password: Credential;
|
|
63
|
+
} | null;
|
|
51
64
|
/** How many times an upload or a manifest is tried before the target fails (#4877). */
|
|
52
65
|
export declare const OCI_PUSH_ATTEMPTS = 4;
|
|
53
66
|
/** The wait before the second try, doubled for each try after it. */
|
|
54
67
|
export declare const OCI_PUSH_RETRY_MS = 2000;
|
|
68
|
+
/** The tag the referrers tag schema keeps the referrers of `digest` under: `sha256-<hex>`. */
|
|
69
|
+
export declare function referrersTagOf(digest: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* The artifact manifest that attaches a Sigstore bundle to the image
|
|
72
|
+
* `subject` (#5164), as `cosign sign` and `cosign attest` push one: the
|
|
73
|
+
* bundle media type as the artifact type and the one layer, and the
|
|
74
|
+
* statement's predicate type in `dev.sigstore.bundle.predicateType`.
|
|
75
|
+
*/
|
|
76
|
+
export declare function bundleReferrerManifest(bundle: Attachment, predicateType: string, subject: {
|
|
77
|
+
mediaType: string;
|
|
78
|
+
digest: string;
|
|
79
|
+
size: number;
|
|
80
|
+
}): Uint8Array;
|
|
55
81
|
/**
|
|
56
82
|
* The artifact manifest that attaches `a` to the image `subject` (OCI image
|
|
57
83
|
* spec 1.1): `artifactType` is the file's media type, the config is the empty
|
|
@@ -62,8 +88,15 @@ export declare function referrerManifest(a: Attachment, subject: {
|
|
|
62
88
|
digest: string;
|
|
63
89
|
size: number;
|
|
64
90
|
}): Uint8Array;
|
|
65
|
-
/** The tags to point at the digest: the context's tag when set, else the declared ones with `{label}` filled in. */
|
|
91
|
+
/** The tags to point at the digest: the context's tag when set, else the declared ones with `{label}` filled in, without `latest` for a prerelease label. */
|
|
66
92
|
export declare function ociTags(decl: OciPublishDeclaration, ctx: Pick<PublishContext, "tag" | "label">): string[];
|
|
67
93
|
/** The digest an OCI archive (a layout directory or a tar file of one) is pushed under: its top manifest's (#4657). */
|
|
68
94
|
export declare function ociArchiveDigest(abs: string): string;
|
|
95
|
+
/**
|
|
96
|
+
* The tags a status change moves (#5163): the channel's tag when the release
|
|
97
|
+
* was cut to one, else the declared tags with no `{label}` in them, such as
|
|
98
|
+
* `latest`, without `latest` for a prerelease label, which never moved it
|
|
99
|
+
* (#5166). A tag that names the label belongs to that release and stays.
|
|
100
|
+
*/
|
|
101
|
+
export declare function ociMovingTags(decl: OciPublishDeclaration, channel: string | null, label?: string | null): string[];
|
|
69
102
|
export declare function ociTarget(decl: OciPublishDeclaration, deps: PublishDeps): PublishTarget;
|
|
@@ -22,6 +22,13 @@
|
|
|
22
22
|
* discover` or `cosign tree` finds them. A referrer the registry already
|
|
23
23
|
* holds is not pushed again.
|
|
24
24
|
*
|
|
25
|
+
* When the publish signs (#5164, ./publish-signing.ts), the stage also
|
|
26
|
+
* pushes a cosign signature and SLSA provenance of the image, each a Sigstore
|
|
27
|
+
* bundle in an artifact manifest whose subject is the image. On a registry
|
|
28
|
+
* without the referrers API (GHCR, Docker Hub) they are listed under the
|
|
29
|
+
* referrers tag `sha256-<hex>`, as cosign does. An image that already has a
|
|
30
|
+
* bundle with the same predicate type is not signed again.
|
|
31
|
+
*
|
|
25
32
|
* Credentials come from `usernameEnv` and `passwordEnv` (default
|
|
26
33
|
* `OCI_USERNAME`, `OCI_PASSWORD`), or else from the `auths` entry for the
|
|
27
34
|
* registry in the docker config file (`$DOCKER_CONFIG/config.json` or
|
|
@@ -40,9 +47,12 @@ import { existsSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
|
|
|
40
47
|
import { tmpdir } from "node:os";
|
|
41
48
|
import { join } from "node:path";
|
|
42
49
|
import { memberSbom, releaseProvenance } from "./publish-attachments.js";
|
|
50
|
+
import { BUNDLE_PREDICATE_ANNOTATION, COSIGN_SIGN_PREDICATE, SIGSTORE_BUNDLE_MEDIA_TYPE, SLSA_PROVENANCE_PREDICATE, cosignSignStatement, slsaProvenanceStatement } from "./publish-signing.js";
|
|
43
51
|
import { readCredential } from "./publish-credentials.js";
|
|
44
52
|
import { bytesDigest, checkReleaseDigest, fileDigest, isDir, memberFile, publishTargetKey } from "./publish-targets.js";
|
|
53
|
+
import { trainName, waitUntilServed } from "./publish-train-names.js";
|
|
45
54
|
import { PublishTargetError } from "./release-publish.js";
|
|
55
|
+
import { prereleaseOf } from "./release-prerelease.js";
|
|
46
56
|
const INDEX_TYPES = new Set(["application/vnd.oci.image.index.v1+json", "application/vnd.docker.distribution.manifest.list.v2+json"]);
|
|
47
57
|
export function parseRepository(repository) {
|
|
48
58
|
const parts = repository.split("/");
|
|
@@ -126,7 +136,7 @@ function readLayout(abs) {
|
|
|
126
136
|
}
|
|
127
137
|
}
|
|
128
138
|
/** The credential for `repo`: the declared variables, else the docker config's `auths` entry. */
|
|
129
|
-
function ociCredential(decl, repo, ctx) {
|
|
139
|
+
export function ociCredential(decl, repo, ctx) {
|
|
130
140
|
const password = readCredential(ctx.env, [decl.passwordEnv ?? "OCI_PASSWORD"], ctx.redactor);
|
|
131
141
|
if (password) {
|
|
132
142
|
const user = ctx.env[decl.usernameEnv ?? "OCI_USERNAME"];
|
|
@@ -301,13 +311,84 @@ class Registry {
|
|
|
301
311
|
const res = await this.request("HEAD", `/v2/${this.repo.name}/manifests/${digest}`, { accept: mediaType });
|
|
302
312
|
return res.status === 200;
|
|
303
313
|
}
|
|
314
|
+
/** The manifest `ref` (a tag or a digest) names, or null when the registry has none (#5163). */
|
|
315
|
+
async getManifest(ref) {
|
|
316
|
+
const accept = [...INDEX_TYPES, IMAGE_MANIFEST, "application/vnd.docker.distribution.manifest.v2+json"].join(", ");
|
|
317
|
+
const res = await this.request("GET", `/v2/${this.repo.name}/manifests/${ref}`, { accept });
|
|
318
|
+
if (res.status === 404)
|
|
319
|
+
return null;
|
|
320
|
+
if (res.status !== 200 || !res.arrayBuffer)
|
|
321
|
+
this.fail(`reading manifest ${ref}`, res.status, await res.text());
|
|
322
|
+
const bytes = new Uint8Array(await res.arrayBuffer());
|
|
323
|
+
const mediaType = res.headers.get("content-type")?.split(";")[0]?.trim() || (JSON.parse(Buffer.from(bytes).toString("utf-8")).mediaType ?? IMAGE_MANIFEST);
|
|
324
|
+
return { mediaType, bytes, digest: res.headers.get("docker-content-digest") ?? bytesDigest(bytes) };
|
|
325
|
+
}
|
|
326
|
+
/** Put a manifest. True when the registry answered with `OCI-Subject`, so its referrers API lists a manifest with a subject. */
|
|
304
327
|
async putManifest(ref, mediaType, bytes) {
|
|
305
|
-
|
|
328
|
+
return this.tries(`putting manifest ${ref}`, async () => {
|
|
306
329
|
const res = await this.request("PUT", `/v2/${this.repo.name}/manifests/${ref}`, { "content-type": mediaType }, bytes);
|
|
307
330
|
if (res.status !== 201)
|
|
308
331
|
throw new RegistryAnswer(`putting manifest ${ref}`, res.status, await res.text());
|
|
332
|
+
return res.headers.get("oci-subject") !== null;
|
|
309
333
|
});
|
|
310
334
|
}
|
|
335
|
+
/**
|
|
336
|
+
* The referrers of `digest` (#5164): the referrers API's index, else, on a
|
|
337
|
+
* registry without it (GHCR, Docker Hub), the index the referrers tag
|
|
338
|
+
* schema keeps at the tag `sha256-<hex>`. Empty when there is neither.
|
|
339
|
+
*/
|
|
340
|
+
async referrers(digest) {
|
|
341
|
+
const api = await this.request("GET", `/v2/${this.repo.name}/referrers/${digest}`, { accept: OCI_INDEX });
|
|
342
|
+
if (api.status === 200) {
|
|
343
|
+
const body = JSON.parse(await api.text());
|
|
344
|
+
return body.manifests ?? [];
|
|
345
|
+
}
|
|
346
|
+
return (await this.referrersTag(digest))?.manifests ?? [];
|
|
347
|
+
}
|
|
348
|
+
async referrersTag(digest) {
|
|
349
|
+
const res = await this.request("GET", `/v2/${this.repo.name}/manifests/${referrersTagOf(digest)}`, { accept: OCI_INDEX });
|
|
350
|
+
if (res.status !== 200)
|
|
351
|
+
return null;
|
|
352
|
+
try {
|
|
353
|
+
const body = JSON.parse(await res.text());
|
|
354
|
+
return { manifests: body.manifests ?? [] };
|
|
355
|
+
}
|
|
356
|
+
catch {
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
/** Add `descriptor` to the referrers tag of `subject` (the OCI distribution spec's fallback), unless it is listed there. */
|
|
361
|
+
async addToReferrersTag(subject, descriptor) {
|
|
362
|
+
const index = (await this.referrersTag(subject)) ?? { manifests: [] };
|
|
363
|
+
if (index.manifests.some((m) => m.digest === descriptor.digest))
|
|
364
|
+
return;
|
|
365
|
+
const bytes = new Uint8Array(Buffer.from(JSON.stringify({ schemaVersion: 2, mediaType: OCI_INDEX, manifests: [...index.manifests, descriptor] })));
|
|
366
|
+
await this.putManifest(referrersTagOf(subject), OCI_INDEX, bytes);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
const OCI_INDEX = "application/vnd.oci.image.index.v1+json";
|
|
370
|
+
/** The tag the referrers tag schema keeps the referrers of `digest` under: `sha256-<hex>`. */
|
|
371
|
+
export function referrersTagOf(digest) {
|
|
372
|
+
return digest.replace(":", "-");
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* The artifact manifest that attaches a Sigstore bundle to the image
|
|
376
|
+
* `subject` (#5164), as `cosign sign` and `cosign attest` push one: the
|
|
377
|
+
* bundle media type as the artifact type and the one layer, and the
|
|
378
|
+
* statement's predicate type in `dev.sigstore.bundle.predicateType`.
|
|
379
|
+
*/
|
|
380
|
+
export function bundleReferrerManifest(bundle, predicateType, subject) {
|
|
381
|
+
const annotations = { "dev.sigstore.bundle.content": "dsse-envelope", [BUNDLE_PREDICATE_ANNOTATION]: predicateType };
|
|
382
|
+
const manifest = {
|
|
383
|
+
schemaVersion: 2,
|
|
384
|
+
mediaType: IMAGE_MANIFEST,
|
|
385
|
+
artifactType: SIGSTORE_BUNDLE_MEDIA_TYPE,
|
|
386
|
+
config: { mediaType: EMPTY_CONFIG.mediaType, digest: bytesDigest(EMPTY_CONFIG.bytes), size: EMPTY_CONFIG.bytes.byteLength },
|
|
387
|
+
layers: [{ mediaType: SIGSTORE_BUNDLE_MEDIA_TYPE, digest: bundle.digest, size: bundle.bytes.byteLength, annotations: { "org.opencontainers.image.title": bundle.name } }],
|
|
388
|
+
subject,
|
|
389
|
+
annotations,
|
|
390
|
+
};
|
|
391
|
+
return new Uint8Array(Buffer.from(JSON.stringify(manifest)));
|
|
311
392
|
}
|
|
312
393
|
/** The media type of the empty config an artifact manifest names. */
|
|
313
394
|
const EMPTY_CONFIG = { mediaType: "application/vnd.oci.empty.v1+json", bytes: new Uint8Array(Buffer.from("{}")) };
|
|
@@ -329,12 +410,17 @@ export function referrerManifest(a, subject) {
|
|
|
329
410
|
};
|
|
330
411
|
return new Uint8Array(Buffer.from(JSON.stringify(manifest)));
|
|
331
412
|
}
|
|
332
|
-
/** The tags to point at the digest: the context's tag when set, else the declared ones with `{label}` filled in. */
|
|
413
|
+
/** The tags to point at the digest: the context's tag when set, else the declared ones with `{label}` filled in, without `latest` for a prerelease label. */
|
|
333
414
|
export function ociTags(decl, ctx) {
|
|
334
415
|
if (ctx.tag)
|
|
335
416
|
return [ctx.tag];
|
|
336
417
|
const declared = decl.tags ?? (ctx.label ? ["{label}"] : []);
|
|
337
|
-
|
|
418
|
+
const tags = declared.filter((t) => ctx.label !== null || !t.includes("{label}")).map((t) => t.split("{label}").join(ctx.label ?? ""));
|
|
419
|
+
// A prerelease label moves no `latest`; what is left is its own label tag.
|
|
420
|
+
if (prereleaseOf(ctx.label) === null)
|
|
421
|
+
return tags;
|
|
422
|
+
const kept = tags.filter((t) => t !== "latest");
|
|
423
|
+
return kept.length > 0 || ctx.label === null ? kept : [ctx.label];
|
|
338
424
|
}
|
|
339
425
|
/** The digest an OCI archive (a layout directory or a tar file of one) is pushed under: its top manifest's (#4657). */
|
|
340
426
|
export function ociArchiveDigest(abs) {
|
|
@@ -346,6 +432,18 @@ export function ociArchiveDigest(abs) {
|
|
|
346
432
|
layout.cleanup();
|
|
347
433
|
}
|
|
348
434
|
}
|
|
435
|
+
/**
|
|
436
|
+
* The tags a status change moves (#5163): the channel's tag when the release
|
|
437
|
+
* was cut to one, else the declared tags with no `{label}` in them, such as
|
|
438
|
+
* `latest`, without `latest` for a prerelease label, which never moved it
|
|
439
|
+
* (#5166). A tag that names the label belongs to that release and stays.
|
|
440
|
+
*/
|
|
441
|
+
export function ociMovingTags(decl, channel, label = null) {
|
|
442
|
+
if (channel)
|
|
443
|
+
return [channel];
|
|
444
|
+
const moving = (decl.tags ?? ["{label}"]).filter((t) => !t.includes("{label}"));
|
|
445
|
+
return prereleaseOf(label) === null ? moving : moving.filter((t) => t !== "latest");
|
|
446
|
+
}
|
|
349
447
|
export function ociTarget(decl, deps) {
|
|
350
448
|
const repo = parseRepository(decl.repository);
|
|
351
449
|
const fetchImpl = deps.fetch ?? ((url, init) => fetch(url, init));
|
|
@@ -383,11 +481,149 @@ export function ociTarget(decl, deps) {
|
|
|
383
481
|
});
|
|
384
482
|
};
|
|
385
483
|
const referrerItem = (r) => ({ name: r.attachment.name, destination: `${decl.repository}@${r.digest}, a referrer of the image`, digest: r.digest, attachment: r.attachment.kind });
|
|
484
|
+
/** #5164: the cosign signature and SLSA provenance of the image, which a stage signs when the publish signs. */
|
|
485
|
+
const signatures = [
|
|
486
|
+
{ predicateType: COSIGN_SIGN_PREDICATE, name: "cosign signature", attachment: "signature" },
|
|
487
|
+
{ predicateType: SLSA_PROVENANCE_PREDICATE, name: "SLSA provenance", attachment: "attestation" },
|
|
488
|
+
];
|
|
489
|
+
const signatureItem = (ctx, s, image, digest) => ({
|
|
490
|
+
name: s.name,
|
|
491
|
+
destination: digest ? `${decl.repository}@${digest}, a referrer of the image` : `${decl.repository}, a referrer of the image, signed when staged`,
|
|
492
|
+
...(digest ? { digest } : {}),
|
|
493
|
+
attachment: s.attachment,
|
|
494
|
+
signs: [{ name: `${decl.repository}@${image}`, digest: image }],
|
|
495
|
+
predicateType: s.predicateType,
|
|
496
|
+
...(ctx.signing ? { sigstore: ctx.signing.identity } : {}),
|
|
497
|
+
});
|
|
498
|
+
/** Sign the image and push each bundle as a referrer, unless the image has one with that predicate type already. */
|
|
499
|
+
const sign = async (ctx, registry, layout) => {
|
|
500
|
+
if (!ctx.signing)
|
|
501
|
+
return [];
|
|
502
|
+
const subject = { mediaType: layout.top.mediaType, digest: layout.top.digest, size: layout.top.bytes.byteLength };
|
|
503
|
+
const existing = await registry.referrers(layout.top.digest);
|
|
504
|
+
const items = [];
|
|
505
|
+
for (const s of signatures) {
|
|
506
|
+
const found = existing.find((m) => m.artifactType === SIGSTORE_BUNDLE_MEDIA_TYPE && m.annotations?.[BUNDLE_PREDICATE_ANNOTATION] === s.predicateType);
|
|
507
|
+
if (found) {
|
|
508
|
+
ctx.log(`${layout.top.digest} already has a ${s.name}; it is not signed again`);
|
|
509
|
+
items.push({ ...signatureItem(ctx, s, layout.top.digest, found.digest), present: true });
|
|
510
|
+
continue;
|
|
511
|
+
}
|
|
512
|
+
const name = `${decl.repository}@${layout.top.digest}`;
|
|
513
|
+
const statement = s.predicateType === COSIGN_SIGN_PREDICATE ? cosignSignStatement({ name: decl.repository, digest: layout.top.digest }) : slsaProvenanceStatement(ctx, [{ name, digest: layout.top.digest }]);
|
|
514
|
+
ctx.log(`signing ${name} with ${ctx.signing.signer.name}: ${s.name}`);
|
|
515
|
+
const bytes = await ctx.signing.signer.signStatement(statement);
|
|
516
|
+
const bundle = { kind: "provenance", name: `${s.attachment}.sigstore.json`, mediaType: SIGSTORE_BUNDLE_MEDIA_TYPE, bytes, digest: bytesDigest(bytes) };
|
|
517
|
+
const manifest = bundleReferrerManifest(bundle, s.predicateType, subject);
|
|
518
|
+
const digest = bytesDigest(manifest);
|
|
519
|
+
await registry.pushBlob(bytesDigest(EMPTY_CONFIG.bytes), () => EMPTY_CONFIG.bytes);
|
|
520
|
+
await registry.pushBlob(bundle.digest, () => bundle.bytes);
|
|
521
|
+
const listed = await registry.putManifest(digest, IMAGE_MANIFEST, manifest);
|
|
522
|
+
if (!listed) {
|
|
523
|
+
await registry.addToReferrersTag(layout.top.digest, {
|
|
524
|
+
mediaType: IMAGE_MANIFEST,
|
|
525
|
+
digest,
|
|
526
|
+
size: manifest.byteLength,
|
|
527
|
+
artifactType: SIGSTORE_BUNDLE_MEDIA_TYPE,
|
|
528
|
+
annotations: { "dev.sigstore.bundle.content": "dsse-envelope", [BUNDLE_PREDICATE_ANNOTATION]: s.predicateType },
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
items.push(signatureItem(ctx, s, layout.top.digest, digest));
|
|
532
|
+
}
|
|
533
|
+
return items;
|
|
534
|
+
};
|
|
386
535
|
const connect = (ctx) => {
|
|
387
536
|
const cred = ociCredential(decl, repo, ctx);
|
|
388
537
|
return { cred, registry: new Registry(repo, fetchImpl, cred, ctx, deps.sleep) };
|
|
389
538
|
};
|
|
539
|
+
/** The image's digest among a release's recorded items: the one item that is not an attachment. */
|
|
540
|
+
const imageDigest = (items) => items.find((i) => i.attachment === undefined && i.digest)?.digest;
|
|
390
541
|
return {
|
|
542
|
+
/** #5165: the repository; what the image bundles is not read from it, so a member names that with `release.dependsOn`. */
|
|
543
|
+
async names() {
|
|
544
|
+
return { provides: [trainName("oci", decl.repository)], needs: [] };
|
|
545
|
+
},
|
|
546
|
+
/** #5165: whether each tag that names the label is there; null when no declared tag names it. */
|
|
547
|
+
async published(ctx) {
|
|
548
|
+
const label = ctx.label;
|
|
549
|
+
if (label === null)
|
|
550
|
+
return null;
|
|
551
|
+
const tags = (decl.tags ?? ["{label}"]).filter((t) => t.includes("{label}")).map((t) => t.split("{label}").join(label));
|
|
552
|
+
if (tags.length === 0)
|
|
553
|
+
return null;
|
|
554
|
+
const { registry } = connect(ctx);
|
|
555
|
+
for (const t of tags)
|
|
556
|
+
if ((await registry.getManifest(t)) === null)
|
|
557
|
+
return false;
|
|
558
|
+
return true;
|
|
559
|
+
},
|
|
560
|
+
/** #5165: wait until each tag the reveal moved names the image's digest. */
|
|
561
|
+
async visible(ctx, published) {
|
|
562
|
+
const digest = imageDigest(published.items);
|
|
563
|
+
const tags = ociTags(decl, ctx);
|
|
564
|
+
if (!digest || tags.length === 0)
|
|
565
|
+
return;
|
|
566
|
+
const { registry } = connect(ctx);
|
|
567
|
+
await waitUntilServed(ctx, deps, {
|
|
568
|
+
what: decl.repository,
|
|
569
|
+
code: "publish-oci-not-served",
|
|
570
|
+
check: async () => {
|
|
571
|
+
const missing = [];
|
|
572
|
+
for (const t of tags)
|
|
573
|
+
if ((await registry.getManifest(t))?.digest !== digest)
|
|
574
|
+
missing.push(`${decl.repository}:${t}`);
|
|
575
|
+
return missing;
|
|
576
|
+
},
|
|
577
|
+
});
|
|
578
|
+
},
|
|
579
|
+
/**
|
|
580
|
+
* #5163: a registry has no deprecation, so deprecate does nothing here. A
|
|
581
|
+
* yank points each moving tag that names this release's digest at the
|
|
582
|
+
* head release's; a restore points them back when this release is the
|
|
583
|
+
* head. The label's own tag stays, since a registry need not delete a tag.
|
|
584
|
+
*/
|
|
585
|
+
async setStatus(ctx) {
|
|
586
|
+
if (ctx.status === "deprecated")
|
|
587
|
+
return [{ what: `${decl.repository} unchanged: a registry has no deprecation; yank moves its tags` }];
|
|
588
|
+
const ours = imageDigest(ctx.revealed);
|
|
589
|
+
if (!ours)
|
|
590
|
+
return [{ what: `${decl.repository} unchanged: the publish record names no image digest`, already: true }];
|
|
591
|
+
const tags = ociMovingTags(decl, ctx.tag, ctx.label);
|
|
592
|
+
if (tags.length === 0)
|
|
593
|
+
return [{ what: `${decl.repository} unchanged: every tag the target moves names the label, so none moves`, already: true }];
|
|
594
|
+
const isHead = ctx.head?.releaseDigest === ctx.release.releaseDigest;
|
|
595
|
+
if (ctx.status === "active" && !isHead)
|
|
596
|
+
return [{ what: `${decl.repository} ${tags.join(", ")} unchanged: a newer active release holds them`, already: true }];
|
|
597
|
+
const to = ctx.status === "active" ? ours : ctx.head ? imageDigest(ctx.head.items) : undefined;
|
|
598
|
+
const actions = [];
|
|
599
|
+
if (!to) {
|
|
600
|
+
for (const t of tags) {
|
|
601
|
+
actions.push({
|
|
602
|
+
what: `${decl.repository}:${t} stays where it is`,
|
|
603
|
+
refused: { code: "release-status-no-previous", message: `no earlier active release of this channel was pushed to ${decl.repository}, so ${t} has nowhere to move back to`, fix: "Cut and publish a release to move it to, or restore an earlier one." },
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
return actions;
|
|
607
|
+
}
|
|
608
|
+
if (!ctx.apply)
|
|
609
|
+
return tags.map((t) => ({ what: ctx.status === "active" ? `point ${decl.repository}:${t} at ${ours}` : `point ${decl.repository}:${t} at ${to}, if it names ${ours}` }));
|
|
610
|
+
const { registry } = connect(ctx);
|
|
611
|
+
let manifest;
|
|
612
|
+
for (const t of tags) {
|
|
613
|
+
const now = await registry.getManifest(t);
|
|
614
|
+
if (now?.digest === to || (ctx.status === "yanked" && now?.digest !== ours)) {
|
|
615
|
+
actions.push({ what: `${decl.repository}:${t} names ${now?.digest ?? "nothing"}; not moved`, already: true });
|
|
616
|
+
continue;
|
|
617
|
+
}
|
|
618
|
+
manifest ?? (manifest = await registry.getManifest(to));
|
|
619
|
+
if (!manifest)
|
|
620
|
+
throw new PublishTargetError("release-status-oci-failed", `${decl.repository} no longer holds ${to}, so ${t} can't point at it`);
|
|
621
|
+
await registry.putManifest(t, manifest.mediaType, manifest.bytes);
|
|
622
|
+
ctx.log(`tagged ${to} ${t}`);
|
|
623
|
+
actions.push({ what: `point ${decl.repository}:${t} at ${to}` });
|
|
624
|
+
}
|
|
625
|
+
return actions;
|
|
626
|
+
},
|
|
391
627
|
kind: "oci",
|
|
392
628
|
name: `oci ${decl.repository}`,
|
|
393
629
|
destination: decl.repository,
|
|
@@ -396,7 +632,7 @@ export function ociTarget(decl, deps) {
|
|
|
396
632
|
async plan(ctx) {
|
|
397
633
|
const layout = inspect(ctx);
|
|
398
634
|
try {
|
|
399
|
-
return [item(ctx, layout.top.digest), ...referrers(ctx, layout).map(referrerItem)];
|
|
635
|
+
return [item(ctx, layout.top.digest), ...referrers(ctx, layout).map(referrerItem), ...(ctx.signing ? signatures.map((s) => signatureItem(ctx, s, layout.top.digest)) : [])];
|
|
400
636
|
}
|
|
401
637
|
finally {
|
|
402
638
|
layout.cleanup();
|
|
@@ -439,13 +675,15 @@ export function ociTarget(decl, deps) {
|
|
|
439
675
|
await registry.putManifest(r.digest, IMAGE_MANIFEST, r.manifest);
|
|
440
676
|
items.push(referrerItem(r));
|
|
441
677
|
}
|
|
678
|
+
// #5164: signed in the stage, so no tag points at an image before its signature is there.
|
|
679
|
+
items.push(...(await sign(ctx, registry, layout)));
|
|
442
680
|
return { target: this.name, destination: this.destination, items, state: {} };
|
|
443
681
|
}
|
|
444
682
|
finally {
|
|
445
683
|
layout.cleanup();
|
|
446
684
|
}
|
|
447
685
|
},
|
|
448
|
-
async reveal(ctx) {
|
|
686
|
+
async reveal(ctx, staged) {
|
|
449
687
|
const layout = inspect(ctx);
|
|
450
688
|
try {
|
|
451
689
|
const { registry } = connect(ctx);
|
|
@@ -453,7 +691,8 @@ export function ociTarget(decl, deps) {
|
|
|
453
691
|
for (const t of tags)
|
|
454
692
|
await registry.putManifest(t, layout.top.mediaType, layout.top.bytes);
|
|
455
693
|
ctx.log(tags.length > 0 ? `tagged ${layout.top.digest} ${tags.join(", ")}` : `no tag to point at ${layout.top.digest}`);
|
|
456
|
-
|
|
694
|
+
const signed = (staged?.items ?? []).filter((i) => i.attachment === "signature" || i.attachment === "attestation").map(({ present: _present, ...i }) => i);
|
|
695
|
+
return { target: this.name, destination: this.destination, items: [item(ctx, layout.top.digest), ...referrers(ctx, layout).map(referrerItem), ...signed] };
|
|
457
696
|
}
|
|
458
697
|
finally {
|
|
459
698
|
layout.cleanup();
|