@intentius/chant 0.124.101 → 0.124.102
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/ci-evidence-claims.d.ts +12 -0
- package/dist/ci-evidence-claims.js +12 -0
- package/dist/cli/handlers/release-init.js +50 -18
- package/dist/cli/handlers/release.d.ts +1 -1
- package/dist/cli/handlers/release.js +12 -9
- package/dist/cli/release-commands/cut.js +4 -3
- package/dist/cli/release-commands/init.js +4 -1
- package/dist/cli/release-commands/workflow.js +4 -2
- package/dist/cloud-lister/index.d.ts +4 -1
- package/dist/cloud-lister/index.js +2 -1
- package/dist/cloud-lister/kubernetes-components.d.ts +56 -0
- package/dist/cloud-lister/kubernetes-components.js +642 -0
- package/dist/cloud-lister/kubernetes.d.ts +18 -0
- package/dist/cloud-lister/kubernetes.js +26 -1
- package/dist/cloud-lister/mask.d.ts +5 -1
- package/dist/cloud-lister/mask.js +14 -5
- package/dist/config-import.d.ts +1 -1
- package/dist/config-import.js +6 -2
- package/dist/config-sandbox.d.ts +1 -1
- package/dist/config-sandbox.js +3 -3
- package/dist/config.d.ts +75 -1
- package/dist/config.js +27 -2
- package/dist/deep-observation.js +9 -3
- package/dist/floor-table.data.js +12 -6
- package/dist/lexicon.d.ts +4 -2
- package/dist/lifecycle/__fixtures__/package-files.d.ts +32 -0
- package/dist/lifecycle/__fixtures__/package-files.js +72 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.js +5 -0
- package/dist/lifecycle/publish-credentials.d.ts +1 -1
- package/dist/lifecycle/publish-credentials.js +5 -0
- package/dist/lifecycle/publish-declaration.d.ts +123 -0
- package/dist/lifecycle/publish-declaration.js +140 -0
- package/dist/lifecycle/publish-helm.d.ts +83 -0
- package/dist/lifecycle/publish-helm.js +452 -0
- package/dist/lifecycle/publish-maven.d.ts +79 -0
- package/dist/lifecycle/publish-maven.js +364 -0
- package/dist/lifecycle/publish-mcp-registry.js +1 -2
- package/dist/lifecycle/publish-npm.d.ts +27 -1
- package/dist/lifecycle/publish-npm.js +51 -1
- package/dist/lifecycle/publish-nuget.d.ts +93 -0
- package/dist/lifecycle/publish-nuget.js +377 -0
- package/dist/lifecycle/publish-oci.d.ts +57 -1
- package/dist/lifecycle/publish-oci.js +1 -1
- package/dist/lifecycle/publish-package-files.d.ts +16 -0
- package/dist/lifecycle/publish-package-files.js +39 -0
- package/dist/lifecycle/publish-pypi.d.ts +2 -0
- package/dist/lifecycle/publish-pypi.js +1 -1
- package/dist/lifecycle/publish-rubygems.d.ts +84 -0
- package/dist/lifecycle/publish-rubygems.js +366 -0
- package/dist/lifecycle/publish-targets.d.ts +10 -0
- package/dist/lifecycle/publish-targets.js +22 -0
- package/dist/lifecycle/publish-train-names.d.ts +4 -1
- package/dist/lifecycle/publish-train-names.js +5 -0
- package/dist/lifecycle/release-artifacts.d.ts +80 -2
- package/dist/lifecycle/release-artifacts.js +242 -5
- package/dist/lifecycle/release-cut.d.ts +6 -1
- package/dist/lifecycle/release-cut.js +15 -0
- package/dist/lifecycle/release-doctor.js +208 -6
- package/dist/lifecycle/release-init-registries.d.ts +48 -0
- package/dist/lifecycle/release-init-registries.js +97 -0
- package/dist/lifecycle/release-init.d.ts +22 -2
- package/dist/lifecycle/release-init.js +132 -7
- package/dist/lifecycle/release-next.js +1 -2
- package/dist/lifecycle/release-publish.d.ts +1 -1
- package/dist/lifecycle/release-publish.js +1 -1
- package/dist/lifecycle/release-tag.js +1 -2
- package/dist/op/local-executor.d.ts +1 -1
- package/dist/op/local-executor.js +2 -2
- package/dist/op/op-waves-evidence.js +9 -2
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/sensitive-key.d.ts +12 -0
- package/dist/sensitive-key.js +52 -0
- package/dist/tool-pins.d.ts +2 -0
- package/dist/tool-pins.js +12 -0
- package/dist/ts-loader.d.ts +8 -0
- package/dist/ts-loader.js +19 -0
- package/dist/wave-runtime.mjs +325 -325
- package/dist/workspace/lexicon-outputs.d.ts +1 -1
- package/dist/workspace/lexicon-outputs.js +1 -1
- package/dist/workspace/release-steps/index.js +4 -0
- package/dist/workspace/release-steps/nfpm.d.ts +13 -0
- package/dist/workspace/release-steps/nfpm.js +29 -0
- package/dist/workspace/release-steps/nuget.d.ts +14 -0
- package/dist/workspace/release-steps/nuget.js +16 -0
- package/dist/workspace/release-steps/targets.d.ts +2 -2
- package/dist/workspace/release-steps/targets.js +3 -3
- package/dist/workspace/release-train-workflow.d.ts +7 -0
- package/dist/workspace/release-train-workflow.js +46 -10
- package/dist/workspace/release-workflow.d.ts +28 -3
- package/dist/workspace/release-workflow.js +38 -15
- package/dist/workspace/train-cut.d.ts +2 -2
- package/dist/workspace/train-cut.js +27 -5
- package/dist/workspace/train-prepare.d.ts +6 -3
- package/dist/workspace/train-prepare.js +54 -8
- package/dist/workspace/train-publish.js +2 -3
- package/dist/workspace/train-shell.d.ts +5 -0
- package/dist/workspace/train-shell.js +17 -0
- package/dist/workspace/trust/check-evidence-report.d.ts +3 -7
- package/dist/workspace/trust/check-evidence-report.js +3 -7
- package/package.json +1 -1
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The NuGet target (#5232): `.nupkg` files pushed to nuget.org, or to another
|
|
3
|
+
* feed that takes NuGet's push API (`PUT <pushUrl>`, a multipart body whose
|
|
4
|
+
* first part is the package, the key in `X-NuGet-ApiKey`).
|
|
5
|
+
*
|
|
6
|
+
* The packages are files, directories of them, or `artifact:<name>`. Each
|
|
7
|
+
* file the release records must match its digest. The id and version are
|
|
8
|
+
* read from the `.nuspec` at the package's root.
|
|
9
|
+
*
|
|
10
|
+
* A feed has no draft: a version is listed once it is pushed and validated,
|
|
11
|
+
* and an id and version can never be pushed again. So the stage pushes
|
|
12
|
+
* nothing. It checks the packages and the credential, and reads the feed's
|
|
13
|
+
* flat container (`<base>/<id>/index.json`) for the versions it already
|
|
14
|
+
* holds: such a version is `present`. nuget.org signs every package it takes
|
|
15
|
+
* with its repository signature, so the bytes it serves are never the bytes
|
|
16
|
+
* pushed and no digest is compared. The reveal reads the flat container
|
|
17
|
+
* again and pushes the rest; a push answered 409 (the version exists) is
|
|
18
|
+
* `present` too, since a version pushed moments ago is not in the flat
|
|
19
|
+
* container until nuget.org has validated it.
|
|
20
|
+
*
|
|
21
|
+
* Credentials:
|
|
22
|
+
*
|
|
23
|
+
* - `auth: "token"`: an API key from `tokenEnv` (default `NUGET_API_KEY`).
|
|
24
|
+
* - `auth: "trusted-publishing"`, nuget.org only: the run's OIDC ID token
|
|
25
|
+
* (audience `https://www.nuget.org`, from GitHub Actions or
|
|
26
|
+
* `NUGET_ID_TOKEN`, a GitLab job's `id_tokens`) is posted to
|
|
27
|
+
* `https://www.nuget.org/api/v2/token` with the user in `userEnv` (default
|
|
28
|
+
* `NUGET_USER`), the nuget.org profile whose trusted publishing policy
|
|
29
|
+
* names the workflow, for an API key that lasts an hour. nuget.org takes
|
|
30
|
+
* an ID token once, so the stage exchanges one only in GitHub Actions,
|
|
31
|
+
* which issues a new token each time it is asked; with `NUGET_ID_TOKEN`
|
|
32
|
+
* the reveal's exchange is the only one.
|
|
33
|
+
*
|
|
34
|
+
* Unset, `auth` is a token when the key's variable is set, else trusted
|
|
35
|
+
* publishing when the run has an OIDC ID token.
|
|
36
|
+
*
|
|
37
|
+
* A status change (#5163): `chant release yank` unlists each version the
|
|
38
|
+
* release pushed (`DELETE <pushUrl>/<id>/<version>`, which nuget.org reads as
|
|
39
|
+
* an unlist; the version stays restorable for anyone who names it), and
|
|
40
|
+
* `restore` lists it again (`POST`). NuGet's API has no deprecation, so
|
|
41
|
+
* `deprecate` changes nothing.
|
|
42
|
+
*
|
|
43
|
+
* Under the `supply-chain` group a package that carries no SBOM (an
|
|
44
|
+
* `.spdx.json`, `.cdx.json` or `.cyclonedx.json` file, or `_manifest/spdx_*`
|
|
45
|
+
* as Microsoft's sbom-tool writes it) is refused unless `sbom` is `false`.
|
|
46
|
+
*/
|
|
47
|
+
import { readFileSync } from "node:fs";
|
|
48
|
+
import { randomBytes } from "node:crypto";
|
|
49
|
+
import { readCredential } from "./publish-credentials.js";
|
|
50
|
+
import { releaseVersion } from "./publish-index.js";
|
|
51
|
+
import { packageFiles } from "./publish-package-files.js";
|
|
52
|
+
import { zipEntry, zipEntryNames } from "./publish-pypi.js";
|
|
53
|
+
import { bytesDigest, checkReleaseDigest, hasIdToken, publishTargetKey, runIdToken } from "./publish-targets.js";
|
|
54
|
+
import { trainName, waitUntilServed } from "./publish-train-names.js";
|
|
55
|
+
import { NEXT_RELEASE } from "../release-floors.js";
|
|
56
|
+
import { PublishTargetError } from "./release-publish.js";
|
|
57
|
+
/** The first chant that publishes a `nuget` target (#5232). */
|
|
58
|
+
export const PUBLISH_NUGET_FLOOR = NEXT_RELEASE;
|
|
59
|
+
export const NUGET_ORG = { label: "nuget.org", site: "https://www.nuget.org", push: "https://www.nuget.org/api/v2/package", flat: "https://api.nuget.org/v3-flatcontainer/", token: "https://www.nuget.org/api/v2/token" };
|
|
60
|
+
/** The audience nuget.org takes an OIDC ID token for. */
|
|
61
|
+
export const NUGET_AUDIENCE = "https://www.nuget.org";
|
|
62
|
+
/** The variable an OIDC ID token for nuget.org is read from outside GitHub Actions, as nuget.org's docs name it for GitLab. */
|
|
63
|
+
export const NUGET_ID_TOKEN_ENV = "NUGET_ID_TOKEN";
|
|
64
|
+
/** The feed a declaration pushes to. */
|
|
65
|
+
export function nugetFeed(decl) {
|
|
66
|
+
if (decl.pushUrl && decl.flatContainerUrl) {
|
|
67
|
+
return { label: new URL(decl.pushUrl).host, nugetOrg: false, push: decl.pushUrl.replace(/\/+$/, ""), flat: decl.flatContainerUrl.endsWith("/") ? decl.flatContainerUrl : `${decl.flatContainerUrl}/` };
|
|
68
|
+
}
|
|
69
|
+
return { label: NUGET_ORG.label, nugetOrg: true, push: NUGET_ORG.push, flat: NUGET_ORG.flat };
|
|
70
|
+
}
|
|
71
|
+
export const nugetTokenEnv = (decl) => decl.tokenEnv ?? "NUGET_API_KEY";
|
|
72
|
+
export const nugetUserEnv = (decl) => decl.userEnv ?? "NUGET_USER";
|
|
73
|
+
/** How the target authenticates in `env`. */
|
|
74
|
+
export function nugetAuth(decl, env) {
|
|
75
|
+
if (decl.auth)
|
|
76
|
+
return decl.auth;
|
|
77
|
+
if (env[nugetTokenEnv(decl)])
|
|
78
|
+
return "token";
|
|
79
|
+
return nugetFeed(decl).nugetOrg && hasIdToken(env, NUGET_ID_TOKEN_ENV) ? "trusted-publishing" : "token";
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A NuGet version as the flat container lists it: lowercased, no build
|
|
83
|
+
* metadata, no leading zeros, and a fourth part of `0` left off.
|
|
84
|
+
*/
|
|
85
|
+
export function normalizeNugetVersion(version) {
|
|
86
|
+
const v = version.trim().toLowerCase().replace(/\+.*$/, "");
|
|
87
|
+
const dash = v.indexOf("-");
|
|
88
|
+
const core = dash < 0 ? v : v.slice(0, dash);
|
|
89
|
+
const pre = dash < 0 ? "" : v.slice(dash);
|
|
90
|
+
const parts = core.split(".").map((p) => (/^\d+$/.test(p) ? String(Number(p)) : p));
|
|
91
|
+
while (parts.length < 3)
|
|
92
|
+
parts.push("0");
|
|
93
|
+
if (parts.length === 4 && parts[3] === "0")
|
|
94
|
+
parts.pop();
|
|
95
|
+
return `${parts.join(".")}${pre}`;
|
|
96
|
+
}
|
|
97
|
+
const xmlText = (s) => s.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&").trim();
|
|
98
|
+
/** Read one `.nupkg`: its `.nuspec`'s id, version and dependencies. */
|
|
99
|
+
export function readNupkg(path, abs) {
|
|
100
|
+
const bytes = readFileSync(abs);
|
|
101
|
+
const file = abs.split(/[\\/]/).pop();
|
|
102
|
+
const bad = (why) => new PublishTargetError("publish-nuget-not-a-package", `${path} is not a NuGet package chant can read: ${why}`, "Name the .nupkg files dotnet pack writes.");
|
|
103
|
+
let names;
|
|
104
|
+
try {
|
|
105
|
+
names = zipEntryNames(bytes);
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
throw bad(err instanceof Error ? err.message : String(err));
|
|
109
|
+
}
|
|
110
|
+
const spec = names.find((n) => /^[^/]+\.nuspec$/i.test(n));
|
|
111
|
+
if (!spec)
|
|
112
|
+
throw bad("it holds no .nuspec at its root");
|
|
113
|
+
let text;
|
|
114
|
+
try {
|
|
115
|
+
text = zipEntry(bytes, spec)?.toString("utf-8") ?? "";
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
throw bad(err instanceof Error ? err.message : String(err));
|
|
119
|
+
}
|
|
120
|
+
const metadata = /<metadata\b[^>]*>([\s\S]*?)<\/metadata>/i.exec(text)?.[1] ?? "";
|
|
121
|
+
const id = /<id>([^<]+)<\/id>/i.exec(metadata)?.[1];
|
|
122
|
+
const version = /<version>([^<]+)<\/version>/i.exec(metadata)?.[1];
|
|
123
|
+
if (!id || !version)
|
|
124
|
+
throw bad(`${spec} has no <id> or <version>`);
|
|
125
|
+
const dependencies = [...new Set([...metadata.matchAll(/<dependency\b[^>]*\bid="([^"]+)"/gi)].map((m) => xmlText(m[1])))];
|
|
126
|
+
const sbom = names.find((n) => /(^|\/)_manifest\/spdx_[^/]+\/[^/]+\.json$/i.test(n) || /\.(spdx|cdx|cyclonedx)\.json$/i.test(n)) ?? null;
|
|
127
|
+
return { path, file, bytes, digest: bytesDigest(new Uint8Array(bytes)), id: xmlText(id), version: xmlText(version), dependencies, sbom };
|
|
128
|
+
}
|
|
129
|
+
export function nugetTarget(decl, deps) {
|
|
130
|
+
const fetchImpl = deps.fetch ?? ((url, init) => fetch(url, init));
|
|
131
|
+
const feed = nugetFeed(decl);
|
|
132
|
+
const tokenName = nugetTokenEnv(decl);
|
|
133
|
+
const userName = nugetUserEnv(decl);
|
|
134
|
+
const packages = (ctx) => {
|
|
135
|
+
const out = packageFiles(ctx, decl.packages, ".nupkg", "publish-nuget", "Build the packages before publishing, such as with dotnet pack -o dist/nuget.").map(({ path, abs }) => {
|
|
136
|
+
const p = readNupkg(path, abs);
|
|
137
|
+
checkReleaseDigest(ctx.release, "asset", ctx.cwd, path, [p.digest]);
|
|
138
|
+
return p;
|
|
139
|
+
});
|
|
140
|
+
if (ctx.requireSbom && decl.sbom !== false) {
|
|
141
|
+
const without = out.find((p) => p.sbom === null);
|
|
142
|
+
if (without) {
|
|
143
|
+
throw new PublishTargetError("publish-sbom-missing", `${without.file} carries no SBOM: a feed keeps no file beside a package, so a package carries its SBOM, such as _manifest/spdx_2.2/manifest.spdx.json`, "Build packages that carry an SBOM, such as with Microsoft's sbom-tool, or set sbom: false to publish without one.");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return out;
|
|
147
|
+
};
|
|
148
|
+
const item = (p) => ({
|
|
149
|
+
name: `${p.id}@${p.version}`,
|
|
150
|
+
destination: feed.nugetOrg ? `${NUGET_ORG.site}/packages/${p.id}/${p.version}` : `${feed.flat}${p.id.toLowerCase()}/`,
|
|
151
|
+
digest: p.digest,
|
|
152
|
+
...(p.sbom ? { sbom: p.sbom } : {}),
|
|
153
|
+
});
|
|
154
|
+
const fail = (ctx, code, what, status, text, fix) => {
|
|
155
|
+
throw new PublishTargetError(code, ctx.redactor.redact(`${what} on ${feed.label} answered ${status}${text ? `: ${text.replace(/\s+/g, " ").slice(0, 300)}` : ""}`), fix);
|
|
156
|
+
};
|
|
157
|
+
/** The versions the feed lists for an id, normalized; empty when it has no such package. */
|
|
158
|
+
const versions = async (ctx, id, key) => {
|
|
159
|
+
const url = `${feed.flat}${id.toLowerCase()}/index.json`;
|
|
160
|
+
const res = await fetchImpl(url, { method: "GET", headers: { "user-agent": "chant", accept: "application/json", ...(!feed.nugetOrg && key ? { "x-nuget-apikey": key } : {}) } });
|
|
161
|
+
const text = await res.text().catch(() => "");
|
|
162
|
+
if (res.status === 404)
|
|
163
|
+
return new Set();
|
|
164
|
+
if (res.status !== 200)
|
|
165
|
+
fail(ctx, "publish-nuget-failed", `reading ${url}`, res.status, text);
|
|
166
|
+
try {
|
|
167
|
+
const list = JSON.parse(text).versions;
|
|
168
|
+
return new Set(Array.isArray(list) ? list.filter((v) => typeof v === "string").map(normalizeNugetVersion) : []);
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return fail(ctx, "publish-nuget-failed", `reading ${url}`, res.status, "not JSON");
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
const presence = async (ctx, pkgs, key) => {
|
|
175
|
+
const byId = new Map();
|
|
176
|
+
const out = new Map();
|
|
177
|
+
for (const p of pkgs) {
|
|
178
|
+
const k = p.id.toLowerCase();
|
|
179
|
+
if (!byId.has(k))
|
|
180
|
+
byId.set(k, await versions(ctx, p.id, key));
|
|
181
|
+
out.set(`${p.id}@${p.version}`, byId.get(k).has(normalizeNugetVersion(p.version)));
|
|
182
|
+
}
|
|
183
|
+
return out;
|
|
184
|
+
};
|
|
185
|
+
/** The API key, or null under trusted publishing; refuses a run with neither. */
|
|
186
|
+
const credential = (ctx) => {
|
|
187
|
+
const auth = nugetAuth(decl, ctx.env);
|
|
188
|
+
if (auth === "token") {
|
|
189
|
+
const key = readCredential(ctx.env, [tokenName], ctx.redactor);
|
|
190
|
+
if (!key) {
|
|
191
|
+
throw new PublishTargetError("publish-credentials-missing", `the ${feed.label} target reads its API key from ${tokenName}, and it is not set${feed.nugetOrg ? ", and this run has no OIDC ID token for trusted publishing" : ""}`, feed.nugetOrg ? `Set ${tokenName} to a nuget.org API key that may push the packages, or publish from a CI job with an OIDC ID token and a trusted publishing policy on nuget.org.` : `Set ${tokenName} to a key the feed takes.`);
|
|
192
|
+
}
|
|
193
|
+
return { auth, key, user: null };
|
|
194
|
+
}
|
|
195
|
+
if (!hasIdToken(ctx.env, NUGET_ID_TOKEN_ENV)) {
|
|
196
|
+
throw new PublishTargetError("publish-credentials-missing", `the nuget.org target publishes with trusted publishing, and this run has no OIDC ID token: not a GitHub Actions job with id-token: write, and ${NUGET_ID_TOKEN_ENV} is not set`, `In GitHub Actions, give the job permissions: id-token: write. In GitLab CI, declare ${NUGET_ID_TOKEN_ENV} under the job's id_tokens with aud: ${NUGET_AUDIENCE}.`);
|
|
197
|
+
}
|
|
198
|
+
const user = readCredential(ctx.env, [userName], ctx.redactor);
|
|
199
|
+
if (!user)
|
|
200
|
+
throw new PublishTargetError("publish-credentials-missing", `trusted publishing on nuget.org names the user whose policy trusts this workflow, and ${userName} is not set`, `Set ${userName} to that nuget.org profile name (not the email address).`);
|
|
201
|
+
return { auth, key: null, user: user.value };
|
|
202
|
+
};
|
|
203
|
+
/** Trusted publishing: an API key for this run, for its OIDC ID token. It lasts an hour. */
|
|
204
|
+
const exchange = async (ctx, user) => {
|
|
205
|
+
const jwt = await runIdToken(ctx, fetchImpl, NUGET_AUDIENCE, NUGET_ID_TOKEN_ENV, "publish-nuget-trusted-publishing");
|
|
206
|
+
const res = await fetchImpl(NUGET_ORG.token, { method: "POST", headers: { "user-agent": "chant", "content-type": "application/json", authorization: `Bearer ${jwt}` }, body: JSON.stringify({ username: user, tokenType: "ApiKey" }) });
|
|
207
|
+
const text = await res.text().catch(() => "");
|
|
208
|
+
let body = {};
|
|
209
|
+
try {
|
|
210
|
+
body = JSON.parse(text);
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
// Reported by its status.
|
|
214
|
+
}
|
|
215
|
+
if (res.status !== 200 || typeof body.apiKey !== "string" || !body.apiKey) {
|
|
216
|
+
throw new PublishTargetError("publish-nuget-trusted-publishing", ctx.redactor.redact(`nuget.org gave no API key for this run's OIDC ID token: it answered ${res.status}${typeof body.error === "string" ? `: ${body.error}` : text ? `: ${text.replace(/\s+/g, " ").slice(0, 300)}` : ""}`), `Add a trusted publishing policy on nuget.org for this repository and workflow file, and set ${userName} to the profile name of the user who created it.`);
|
|
217
|
+
}
|
|
218
|
+
ctx.redactor.add(body.apiKey);
|
|
219
|
+
return body.apiKey;
|
|
220
|
+
};
|
|
221
|
+
/** Whether the stage can exchange without spending the reveal's ID token: GitHub Actions issues one per request. */
|
|
222
|
+
const canCheckExchange = (env) => !env[NUGET_ID_TOKEN_ENV] && Boolean(env.ACTIONS_ID_TOKEN_REQUEST_URL && env.ACTIONS_ID_TOKEN_REQUEST_TOKEN);
|
|
223
|
+
const push = async (ctx, p, key) => {
|
|
224
|
+
const boundary = `chant-${randomBytes(12).toString("hex")}`;
|
|
225
|
+
const body = Buffer.concat([
|
|
226
|
+
Buffer.from(`--${boundary}\r\nContent-Disposition: form-data; name="package"; filename="${p.file}"\r\nContent-Type: application/octet-stream\r\n\r\n`, "utf-8"),
|
|
227
|
+
p.bytes,
|
|
228
|
+
Buffer.from(`\r\n--${boundary}--\r\n`, "utf-8"),
|
|
229
|
+
]);
|
|
230
|
+
ctx.log(`pushing ${p.file} (${p.bytes.byteLength} bytes) to ${feed.label}`);
|
|
231
|
+
const res = await fetchImpl(feed.push, {
|
|
232
|
+
method: "PUT",
|
|
233
|
+
headers: { "user-agent": "chant", "content-type": `multipart/form-data; boundary=${boundary}`, "x-nuget-apikey": key, "x-nuget-protocol-version": "4.1.0" },
|
|
234
|
+
body: new Uint8Array(body),
|
|
235
|
+
});
|
|
236
|
+
const text = await res.text().catch(() => "");
|
|
237
|
+
if (res.status === 200 || res.status === 201 || res.status === 202)
|
|
238
|
+
return "sent";
|
|
239
|
+
if (res.status === 409)
|
|
240
|
+
return "present";
|
|
241
|
+
if (res.status === 400)
|
|
242
|
+
return fail(ctx, "publish-nuget-invalid", `pushing ${p.file}`, res.status, text, "Fix the package: the feed refused it as invalid.");
|
|
243
|
+
return fail(ctx, "publish-nuget-failed", `pushing ${p.file}`, res.status, text, res.status === 401 || res.status === 403 ? `Check that the key may push ${p.id}: on nuget.org, its scope and glob pattern, or the trusted publishing policy's.` : undefined);
|
|
244
|
+
};
|
|
245
|
+
const target = {
|
|
246
|
+
kind: "nuget",
|
|
247
|
+
name: `${feed.label} ${decl.packages.join(", ")}`,
|
|
248
|
+
destination: feed.label,
|
|
249
|
+
credentialEnv: [tokenName, userName, NUGET_ID_TOKEN_ENV],
|
|
250
|
+
key: publishTargetKey(decl),
|
|
251
|
+
uploadsAtReveal: true,
|
|
252
|
+
async names(ctx) {
|
|
253
|
+
const pkgs = packages(ctx);
|
|
254
|
+
const provides = [...new Set(pkgs.map((p) => trainName("nuget", p.id)))];
|
|
255
|
+
const needs = new Set(pkgs.flatMap((p) => p.dependencies.map((d) => trainName("nuget", d))));
|
|
256
|
+
return { provides, needs: [...needs].filter((n) => !provides.includes(n)) };
|
|
257
|
+
},
|
|
258
|
+
/** #5165: whether the feed lists each package at the release's version. */
|
|
259
|
+
async published(ctx) {
|
|
260
|
+
const version = releaseVersion(ctx.label);
|
|
261
|
+
if (!version)
|
|
262
|
+
return null;
|
|
263
|
+
let pkgs;
|
|
264
|
+
try {
|
|
265
|
+
pkgs = packages(ctx);
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
const key = readCredential(ctx.env, [tokenName], ctx.redactor)?.value ?? null;
|
|
271
|
+
const present = await presence(ctx, pkgs.map((p) => ({ id: p.id, version })), key);
|
|
272
|
+
return [...present.values()].every(Boolean);
|
|
273
|
+
},
|
|
274
|
+
/** #5165: wait until the flat container lists each version the reveal pushed. nuget.org validates and indexes a package first, which takes minutes. */
|
|
275
|
+
async visible(ctx, published) {
|
|
276
|
+
const pkgs = published.items.filter((i) => i.attachment === undefined && !i.refused).map((i) => /^(.+)@([^@]+)$/.exec(i.name)).filter((m) => m !== null).map((m) => ({ id: m[1], version: m[2] }));
|
|
277
|
+
if (pkgs.length === 0)
|
|
278
|
+
return;
|
|
279
|
+
const key = readCredential(ctx.env, [tokenName], ctx.redactor)?.value ?? null;
|
|
280
|
+
await waitUntilServed(ctx, deps, {
|
|
281
|
+
what: feed.label,
|
|
282
|
+
code: "publish-nuget-not-served",
|
|
283
|
+
check: async () => {
|
|
284
|
+
const present = await presence(ctx, pkgs, key);
|
|
285
|
+
return [...present.entries()].filter(([, v]) => !v).map(([k]) => k);
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
},
|
|
289
|
+
async plan(ctx) {
|
|
290
|
+
const pkgs = packages(ctx);
|
|
291
|
+
credential(ctx);
|
|
292
|
+
return pkgs.map(item);
|
|
293
|
+
},
|
|
294
|
+
async stage(ctx) {
|
|
295
|
+
const pkgs = packages(ctx);
|
|
296
|
+
const cred = credential(ctx);
|
|
297
|
+
if (cred.key)
|
|
298
|
+
ctx.log(`using the API key from ${cred.key.from}; ${feed.label} has no read-only check of a key, so whether it may push shows at the reveal`);
|
|
299
|
+
else if (canCheckExchange(ctx.env)) {
|
|
300
|
+
await exchange(ctx, cred.user);
|
|
301
|
+
ctx.log("nuget.org takes this run as a trusted publisher; the reveal asks for a new key");
|
|
302
|
+
}
|
|
303
|
+
else
|
|
304
|
+
ctx.log(`nuget.org takes an ID token once, so the reveal makes the trusted-publishing exchange with ${NUGET_ID_TOKEN_ENV}`);
|
|
305
|
+
const present = await presence(ctx, pkgs, cred.key?.value ?? null);
|
|
306
|
+
const items = pkgs.map((p) => (present.get(`${p.id}@${p.version}`) ? { ...item(p), present: true } : item(p)));
|
|
307
|
+
const waiting = items.filter((i) => !i.present).map((i) => i.name);
|
|
308
|
+
ctx.log(waiting.length === 0 ? `${feed.label} already lists every package at its version` : `${waiting.join(", ")} ${waiting.length === 1 ? "is" : "are"} pushed at the reveal, since ${feed.label} has no draft`);
|
|
309
|
+
const staged = { target: target.name, destination: target.destination, items, state: waiting.length === 0 ? { present: "true" } : {} };
|
|
310
|
+
return staged;
|
|
311
|
+
},
|
|
312
|
+
async reveal(ctx, staged) {
|
|
313
|
+
if (staged.state.present === "true")
|
|
314
|
+
return { target: target.name, destination: target.destination, items: staged.items.map((i) => ({ ...i, present: true })) };
|
|
315
|
+
const pkgs = packages(ctx);
|
|
316
|
+
const cred = credential(ctx);
|
|
317
|
+
// Read again: a reveal run after a push whose record was lost finds the version there.
|
|
318
|
+
const present = await presence(ctx, pkgs, cred.key?.value ?? null);
|
|
319
|
+
let key = cred.key?.value ?? null;
|
|
320
|
+
const done = [];
|
|
321
|
+
const items = [];
|
|
322
|
+
for (const p of pkgs) {
|
|
323
|
+
const name = `${p.id}@${p.version}`;
|
|
324
|
+
if (present.get(name)) {
|
|
325
|
+
items.push({ ...item(p), present: true });
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
key ?? (key = await exchange(ctx, cred.user));
|
|
329
|
+
let r;
|
|
330
|
+
try {
|
|
331
|
+
r = await push(ctx, p, key);
|
|
332
|
+
}
|
|
333
|
+
catch (err) {
|
|
334
|
+
if (err instanceof PublishTargetError && done.length > 0)
|
|
335
|
+
throw new PublishTargetError(err.code, `${err.message}. Pushed before it: ${done.join(", ")}; the same publish run again pushes only the rest`, err.fix);
|
|
336
|
+
throw err;
|
|
337
|
+
}
|
|
338
|
+
if (r === "present")
|
|
339
|
+
ctx.log(`${feed.label} already has ${name}; it signs what it takes, so the bytes are not compared`);
|
|
340
|
+
else
|
|
341
|
+
done.push(name);
|
|
342
|
+
items.push(r === "present" ? { ...item(p), present: true } : item(p));
|
|
343
|
+
}
|
|
344
|
+
return { target: target.name, destination: target.destination, items };
|
|
345
|
+
},
|
|
346
|
+
/**
|
|
347
|
+
* #5163: a yank unlists each version the release pushed, a restore lists
|
|
348
|
+
* it again. NuGet's API has no deprecation.
|
|
349
|
+
*/
|
|
350
|
+
async setStatus(ctx) {
|
|
351
|
+
if (ctx.status === "deprecated")
|
|
352
|
+
return [{ what: `${feed.label} unchanged: NuGet's API has no deprecation; yank unlists the versions`, already: true }];
|
|
353
|
+
const relist = ctx.status === "active";
|
|
354
|
+
const pkgs = ctx.revealed.filter((i) => i.attachment === undefined && !i.refused && i.name.lastIndexOf("@") > 0).map((i) => ({ id: i.name.slice(0, i.name.lastIndexOf("@")), version: i.name.slice(i.name.lastIndexOf("@") + 1) }));
|
|
355
|
+
const what = (p) => `${relist ? "POST" : "DELETE"} ${feed.push}/${p.id}/${p.version} (${relist ? "list" : "unlist"} ${p.id}@${p.version})`;
|
|
356
|
+
if (!ctx.apply)
|
|
357
|
+
return pkgs.map((p) => ({ what: what(p) }));
|
|
358
|
+
const cred = credential(ctx);
|
|
359
|
+
const key = cred.key?.value ?? (await exchange(ctx, cred.user));
|
|
360
|
+
const actions = [];
|
|
361
|
+
for (const p of pkgs) {
|
|
362
|
+
ctx.log(`${relist ? "listing" : "unlisting"} ${p.id}@${p.version} on ${feed.label}`);
|
|
363
|
+
const res = await fetchImpl(`${feed.push}/${encodeURIComponent(p.id)}/${encodeURIComponent(p.version)}`, { method: relist ? "POST" : "DELETE", headers: { "user-agent": "chant", "x-nuget-apikey": key, "x-nuget-protocol-version": "4.1.0" } });
|
|
364
|
+
const text = await res.text().catch(() => "");
|
|
365
|
+
if (res.status === 404) {
|
|
366
|
+
actions.push({ what: `${p.id}@${p.version} is not on ${feed.label}; nothing to ${relist ? "restore" : "yank"}`, already: true });
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
if (res.status < 200 || res.status > 299)
|
|
370
|
+
fail(ctx, "release-status-nuget-failed", what(p), res.status, text, `Unlisting needs a key that may unlist ${p.id}.`);
|
|
371
|
+
actions.push({ what: what(p) });
|
|
372
|
+
}
|
|
373
|
+
return actions;
|
|
374
|
+
},
|
|
375
|
+
};
|
|
376
|
+
return target;
|
|
377
|
+
}
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
import { type Attachment } from "./publish-attachments.js";
|
|
46
46
|
import { type Credential } from "./publish-credentials.js";
|
|
47
47
|
import type { OciPublishDeclaration } from "./publish-declaration.js";
|
|
48
|
-
import { type PublishContext, type PublishDeps, type PublishTarget } from "./release-publish.js";
|
|
48
|
+
import { type PublishContext, type PublishContextBase, type PublishDeps, type PublishFetch, type PublishTarget } from "./release-publish.js";
|
|
49
49
|
/** A repository reference split into where the registry is and the name in it. */
|
|
50
50
|
export interface OciRepository {
|
|
51
51
|
/** The host as written, used to find docker config credentials. */
|
|
@@ -65,6 +65,61 @@ export declare function ociCredential(decl: Pick<OciPublishDeclaration, "usernam
|
|
|
65
65
|
export declare const OCI_PUSH_ATTEMPTS = 4;
|
|
66
66
|
/** The wait before the second try, doubled for each try after it. */
|
|
67
67
|
export declare const OCI_PUSH_RETRY_MS = 2000;
|
|
68
|
+
/**
|
|
69
|
+
* A registry client that answers the registry's auth challenge and keeps the
|
|
70
|
+
* token. A 401 under a token it already holds, as when the registry's token
|
|
71
|
+
* expires during a long push, is answered once more (#4877).
|
|
72
|
+
*/
|
|
73
|
+
export declare class Registry {
|
|
74
|
+
private readonly repo;
|
|
75
|
+
private readonly fetch;
|
|
76
|
+
private readonly cred;
|
|
77
|
+
private readonly ctx;
|
|
78
|
+
private readonly sleep;
|
|
79
|
+
private auth;
|
|
80
|
+
constructor(repo: OciRepository, fetch: PublishFetch, cred: {
|
|
81
|
+
username: string;
|
|
82
|
+
password: Credential;
|
|
83
|
+
} | null, ctx: PublishContextBase, sleep?: (ms: number) => Promise<void>);
|
|
84
|
+
private fail;
|
|
85
|
+
request(method: string, path: string, headers?: Record<string, string>, body?: Uint8Array): Promise<Awaited<ReturnType<PublishFetch>>>;
|
|
86
|
+
private answerChallenge;
|
|
87
|
+
/**
|
|
88
|
+
* Run `attempt` up to {@link OCI_PUSH_ATTEMPTS} times while it fails with a
|
|
89
|
+
* {@link retryable} answer or a dropped connection, waiting longer before
|
|
90
|
+
* each try (#4877). Any other answer fails the target at once.
|
|
91
|
+
*/
|
|
92
|
+
private tries;
|
|
93
|
+
/** Upload a blob unless the registry holds it. True when it was uploaded. */
|
|
94
|
+
pushBlob(digest: string, bytes: () => Uint8Array): Promise<boolean>;
|
|
95
|
+
/** Whether the registry holds the manifest `digest`. */
|
|
96
|
+
hasManifest(digest: string, mediaType: string): Promise<boolean>;
|
|
97
|
+
/** The manifest `ref` (a tag or a digest) names, or null when the registry has none (#5163). */
|
|
98
|
+
getManifest(ref: string): Promise<{
|
|
99
|
+
mediaType: string;
|
|
100
|
+
bytes: Uint8Array;
|
|
101
|
+
digest: string;
|
|
102
|
+
} | null>;
|
|
103
|
+
/** Put a manifest. True when the registry answered with `OCI-Subject`, so its referrers API lists a manifest with a subject. */
|
|
104
|
+
putManifest(ref: string, mediaType: string, bytes: Uint8Array): Promise<boolean>;
|
|
105
|
+
/**
|
|
106
|
+
* The referrers of `digest` (#5164): the referrers API's index, else, on a
|
|
107
|
+
* registry without it (GHCR, Docker Hub), the index the referrers tag
|
|
108
|
+
* schema keeps at the tag `sha256-<hex>`. Empty when there is neither.
|
|
109
|
+
*/
|
|
110
|
+
referrers(digest: string): Promise<ReferrerDescriptor[]>;
|
|
111
|
+
private referrersTag;
|
|
112
|
+
/** Add `descriptor` to the referrers tag of `subject` (the OCI distribution spec's fallback), unless it is listed there. */
|
|
113
|
+
addToReferrersTag(subject: string, descriptor: ReferrerDescriptor): Promise<void>;
|
|
114
|
+
}
|
|
115
|
+
/** One referrer as an index lists it. */
|
|
116
|
+
interface ReferrerDescriptor {
|
|
117
|
+
mediaType: string;
|
|
118
|
+
digest: string;
|
|
119
|
+
size: number;
|
|
120
|
+
artifactType?: string;
|
|
121
|
+
annotations?: Record<string, string>;
|
|
122
|
+
}
|
|
68
123
|
/** The tag the referrers tag schema keeps the referrers of `digest` under: `sha256-<hex>`. */
|
|
69
124
|
export declare function referrersTagOf(digest: string): string;
|
|
70
125
|
/**
|
|
@@ -100,3 +155,4 @@ export declare function ociArchiveDigest(abs: string): string;
|
|
|
100
155
|
*/
|
|
101
156
|
export declare function ociMovingTags(decl: OciPublishDeclaration, channel: string | null, label?: string | null): string[];
|
|
102
157
|
export declare function ociTarget(decl: OciPublishDeclaration, deps: PublishDeps): PublishTarget;
|
|
158
|
+
export {};
|
|
@@ -194,7 +194,7 @@ class RegistryAnswer extends Error {
|
|
|
194
194
|
* token. A 401 under a token it already holds, as when the registry's token
|
|
195
195
|
* expires during a long push, is answered once more (#4877).
|
|
196
196
|
*/
|
|
197
|
-
class Registry {
|
|
197
|
+
export class Registry {
|
|
198
198
|
constructor(repo, fetch, cred, ctx, sleep = (ms) => new Promise((r) => setTimeout(r, ms))) {
|
|
199
199
|
this.repo = repo;
|
|
200
200
|
this.fetch = fetch;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The package files a registry target names (#5232): files, directories of
|
|
3
|
+
* them, and `artifact:<name>` for the files the release records for a
|
|
4
|
+
* `release.artifacts` entry, as the nuget and rubygems targets take them.
|
|
5
|
+
*/
|
|
6
|
+
import { type PublishContext } from "./release-publish.js";
|
|
7
|
+
/**
|
|
8
|
+
* Each file `entries` names, in order: a file as it is, a directory as every
|
|
9
|
+
* file in it whose name ends in `ext`, in name order, and `artifact:<name>` as
|
|
10
|
+
* the release's paths for it. A directory with none is refused with
|
|
11
|
+
* `<code>-no-files`, a file name given twice with `<code>-duplicate-file`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function packageFiles(ctx: Pick<PublishContext, "cwd" | "release">, entries: readonly string[], ext: string, code: string, buildFix: string): Array<{
|
|
14
|
+
path: string;
|
|
15
|
+
abs: string;
|
|
16
|
+
}>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The package files a registry target names (#5232): files, directories of
|
|
3
|
+
* them, and `artifact:<name>` for the files the release records for a
|
|
4
|
+
* `release.artifacts` entry, as the nuget and rubygems targets take them.
|
|
5
|
+
*/
|
|
6
|
+
import { readdirSync, statSync } from "node:fs";
|
|
7
|
+
import { basename, join } from "node:path";
|
|
8
|
+
import { expandArtifactAssets, memberFile } from "./publish-targets.js";
|
|
9
|
+
import { PublishTargetError } from "./release-publish.js";
|
|
10
|
+
/**
|
|
11
|
+
* Each file `entries` names, in order: a file as it is, a directory as every
|
|
12
|
+
* file in it whose name ends in `ext`, in name order, and `artifact:<name>` as
|
|
13
|
+
* the release's paths for it. A directory with none is refused with
|
|
14
|
+
* `<code>-no-files`, a file name given twice with `<code>-duplicate-file`.
|
|
15
|
+
*/
|
|
16
|
+
export function packageFiles(ctx, entries, ext, code, buildFix) {
|
|
17
|
+
const out = [];
|
|
18
|
+
const seen = new Set();
|
|
19
|
+
const add = (path) => {
|
|
20
|
+
const abs = memberFile(ctx.cwd, path);
|
|
21
|
+
if (seen.has(basename(abs)))
|
|
22
|
+
throw new PublishTargetError(`${code}-duplicate-file`, `${basename(abs)} is named twice`, "Name each file once.");
|
|
23
|
+
seen.add(basename(abs));
|
|
24
|
+
out.push({ path, abs });
|
|
25
|
+
};
|
|
26
|
+
for (const entry of expandArtifactAssets(ctx.release, entries)) {
|
|
27
|
+
const abs = memberFile(ctx.cwd, entry);
|
|
28
|
+
if (statSync(abs).isDirectory()) {
|
|
29
|
+
const found = readdirSync(abs).filter((f) => f.endsWith(ext) && statSync(join(abs, f)).isFile()).sort();
|
|
30
|
+
if (found.length === 0)
|
|
31
|
+
throw new PublishTargetError(`${code}-no-files`, `${entry} holds no ${ext} file`, buildFix);
|
|
32
|
+
for (const f of found)
|
|
33
|
+
add(join(entry, f));
|
|
34
|
+
}
|
|
35
|
+
else
|
|
36
|
+
add(entry);
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
@@ -87,6 +87,8 @@ export declare function pypiAuth(decl: PypiPublishDeclaration, env: NodeJS.Proce
|
|
|
87
87
|
export declare function normalizeProjectName(name: string): string;
|
|
88
88
|
/** The names of a zip archive's entries. */
|
|
89
89
|
export declare function zipEntryNames(zip: Buffer): string[];
|
|
90
|
+
/** One file of a zip archive, or null. Reads stored and deflated entries. */
|
|
91
|
+
export declare function zipEntry(zip: Buffer, name: string): Buffer | null;
|
|
90
92
|
/** Each entry of a tar archive, by name, with its bytes: ustar names with their prefix, and pax and GNU long names. */
|
|
91
93
|
export declare function tarEntries(tar: Buffer): Map<string, Buffer>;
|
|
92
94
|
/** A distribution's core metadata (RFC 822 headers, then the description as the body). */
|
|
@@ -115,7 +115,7 @@ export function zipEntryNames(zip) {
|
|
|
115
115
|
return names;
|
|
116
116
|
}
|
|
117
117
|
/** One file of a zip archive, or null. Reads stored and deflated entries. */
|
|
118
|
-
function zipEntry(zip, name) {
|
|
118
|
+
export function zipEntry(zip, name) {
|
|
119
119
|
let end = -1;
|
|
120
120
|
for (let i = zip.length - 22; i >= Math.max(0, zip.length - 22 - 0xffff); i--) {
|
|
121
121
|
if (zip.readUInt32LE(i) === 0x06054b50) {
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The RubyGems target (#5232): `.gem` files pushed to RubyGems.org, or to
|
|
3
|
+
* another host that takes its API (`POST /api/v1/gems`, the gem as the body,
|
|
4
|
+
* the key in `Authorization`).
|
|
5
|
+
*
|
|
6
|
+
* The gems are files, directories of them, or `artifact:<name>`. Each file
|
|
7
|
+
* the release records must match its digest. The name, version and platform
|
|
8
|
+
* are read from the gem's own `metadata.gz`.
|
|
9
|
+
*
|
|
10
|
+
* A host has no draft: a version is visible once it is pushed, and a name,
|
|
11
|
+
* version and platform can never be pushed again, even after a yank. So the
|
|
12
|
+
* stage pushes nothing. It checks the gems and the credential, and reads
|
|
13
|
+
* `/api/v1/versions/<name>.json`: a version the host lists for the platform
|
|
14
|
+
* with the same SHA-256 is `present`; one it lists with another is refused
|
|
15
|
+
* (`publish-rubygems-version-exists`). The reveal reads it again and pushes
|
|
16
|
+
* the rest, so a reveal run again after a push whose record was lost sends
|
|
17
|
+
* nothing twice.
|
|
18
|
+
*
|
|
19
|
+
* Credentials:
|
|
20
|
+
*
|
|
21
|
+
* - `auth: "token"`: an API key from `tokenEnv` (default `GEM_HOST_API_KEY`,
|
|
22
|
+
* the variable `gem push` reads), with the push scope.
|
|
23
|
+
* - `auth: "trusted-publishing"`, RubyGems.org only: the run's OIDC ID token
|
|
24
|
+
* (audience `rubygems.org`, from GitHub Actions or `RUBYGEMS_ID_TOKEN`) is
|
|
25
|
+
* exchanged at `POST /api/v1/oidc/trusted_publisher/exchange_token` for a
|
|
26
|
+
* key that lasts minutes. The stage exchanges to check that RubyGems.org
|
|
27
|
+
* takes this workflow as a trusted publisher, and drops the key; the
|
|
28
|
+
* reveal exchanges again.
|
|
29
|
+
*
|
|
30
|
+
* Unset, `auth` is a token when the key's variable is set, else trusted
|
|
31
|
+
* publishing when the run has an OIDC ID token.
|
|
32
|
+
*
|
|
33
|
+
* A status change (#5163): `chant release yank` yanks each version the
|
|
34
|
+
* release pushed (`DELETE /api/v1/gems/yank`), with a key in `tokenEnv` that
|
|
35
|
+
* may yank. RubyGems.org takes no yank back, so `restore` is refused, and it
|
|
36
|
+
* has no deprecation, so `deprecate` changes nothing.
|
|
37
|
+
*
|
|
38
|
+
* A host keeps no file beside a gem, so nothing is attached. Under the
|
|
39
|
+
* `supply-chain` group the target is refused (`publish-sbom-missing`) unless
|
|
40
|
+
* `sbom` is `false`.
|
|
41
|
+
*/
|
|
42
|
+
import type { RubygemsPublishDeclaration } from "./publish-declaration.js";
|
|
43
|
+
import { type PublishDeps, type PublishTarget } from "./release-publish.js";
|
|
44
|
+
/** The first chant that publishes a `rubygems` target (#5232). */
|
|
45
|
+
export declare const PUBLISH_RUBYGEMS_FLOOR = "0.124.102";
|
|
46
|
+
export declare const RUBYGEMS_ORG = "https://rubygems.org";
|
|
47
|
+
/** The audience RubyGems.org takes an OIDC ID token for. */
|
|
48
|
+
export declare const RUBYGEMS_AUDIENCE = "rubygems.org";
|
|
49
|
+
/** The variable an OIDC ID token for RubyGems.org is read from outside GitHub Actions. */
|
|
50
|
+
export declare const RUBYGEMS_ID_TOKEN_ENV = "RUBYGEMS_ID_TOKEN";
|
|
51
|
+
export declare const rubygemsHost: (decl: Pick<RubygemsPublishDeclaration, "host">) => string;
|
|
52
|
+
export declare const rubygemsTokenEnv: (decl: Pick<RubygemsPublishDeclaration, "tokenEnv">) => string;
|
|
53
|
+
/** How the target authenticates in `env`. */
|
|
54
|
+
export declare function rubygemsAuth(decl: RubygemsPublishDeclaration, env: NodeJS.ProcessEnv): "token" | "trusted-publishing";
|
|
55
|
+
/** One `.gem`, read. */
|
|
56
|
+
export interface RubyGem {
|
|
57
|
+
path: string;
|
|
58
|
+
file: string;
|
|
59
|
+
bytes: Buffer;
|
|
60
|
+
digest: string;
|
|
61
|
+
name: string;
|
|
62
|
+
version: string;
|
|
63
|
+
platform: string;
|
|
64
|
+
/** The gems it needs at run time. */
|
|
65
|
+
dependencies: string[];
|
|
66
|
+
}
|
|
67
|
+
/** A gemspec's name, version, platform and runtime dependencies, from the YAML `gem build` writes into `metadata.gz`. */
|
|
68
|
+
export declare function parseGemMetadata(yaml: string): {
|
|
69
|
+
name: string | null;
|
|
70
|
+
version: string | null;
|
|
71
|
+
platform: string;
|
|
72
|
+
dependencies: string[];
|
|
73
|
+
};
|
|
74
|
+
/** Read one `.gem`: a tar holding `metadata.gz`. */
|
|
75
|
+
export declare function readGem(path: string, abs: string): RubyGem;
|
|
76
|
+
/** An item's name: `<name>@<version>`, with `-<platform>` for a platform gem. A gem version holds no `-`. */
|
|
77
|
+
export declare const gemItemName: (g: Pick<RubyGem, "name" | "version" | "platform">) => string;
|
|
78
|
+
/** The gem an item names. */
|
|
79
|
+
export declare function parseGemItemName(name: string): {
|
|
80
|
+
name: string;
|
|
81
|
+
version: string;
|
|
82
|
+
platform: string;
|
|
83
|
+
} | null;
|
|
84
|
+
export declare function rubygemsTarget(decl: RubygemsPublishDeclaration, deps: PublishDeps): PublishTarget;
|