@intentius/chant 0.124.100 → 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/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-evidence-claims.d.ts +12 -0
- package/dist/ci-evidence-claims.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 +374 -0
- package/dist/cli/handlers/release.d.ts +43 -2
- package/dist/cli/handlers/release.js +667 -39
- 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 +50 -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 +19 -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 +15 -0
- 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/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-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 +369 -10
- package/dist/config.js +127 -7
- package/dist/deep-observation.js +9 -3
- package/dist/floor-table.data.js +21 -1
- package/dist/forge-remote.d.ts +13 -0
- package/dist/forge-remote.js +15 -0
- package/dist/lexicon.d.ts +45 -4
- 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.d.ts +62 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.js +275 -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 +13 -0
- package/dist/lifecycle/publish-declaration.d.ts +322 -4
- package/dist/lifecycle/publish-declaration.js +340 -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-helm.d.ts +83 -0
- package/dist/lifecycle/publish-helm.js +452 -0
- 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-maven.d.ts +79 -0
- package/dist/lifecycle/publish-maven.js +364 -0
- package/dist/lifecycle/publish-mcp-registry.d.ts +66 -0
- package/dist/lifecycle/publish-mcp-registry.js +305 -0
- package/dist/lifecycle/publish-npm.d.ts +27 -1
- package/dist/lifecycle/publish-npm.js +216 -3
- package/dist/lifecycle/publish-nuget.d.ts +93 -0
- package/dist/lifecycle/publish-nuget.js +377 -0
- package/dist/lifecycle/publish-oci.d.ts +91 -2
- package/dist/lifecycle/publish-oci.js +247 -8
- 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 +138 -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-rubygems.d.ts +84 -0
- package/dist/lifecycle/publish-rubygems.js +366 -0
- package/dist/lifecycle/publish-signing.d.ts +147 -0
- package/dist/lifecycle/publish-signing.js +257 -0
- package/dist/lifecycle/publish-targets.d.ts +37 -1
- package/dist/lifecycle/publish-targets.js +102 -0
- package/dist/lifecycle/publish-tauri.js +43 -0
- package/dist/lifecycle/publish-train-names.d.ts +57 -0
- package/dist/lifecycle/publish-train-names.js +123 -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 +290 -0
- package/dist/lifecycle/release-artifacts.js +808 -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 +64 -4
- package/dist/lifecycle/release-cut.js +147 -34
- package/dist/lifecycle/release-doctor.d.ts +113 -0
- package/dist/lifecycle/release-doctor.js +1198 -0
- package/dist/lifecycle/release-green.d.ts +86 -0
- package/dist/lifecycle/release-green.js +286 -0
- 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 +275 -0
- package/dist/lifecycle/release-init.js +984 -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 +251 -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 +247 -35
- 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 +322 -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/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/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/sensitive-key.d.ts +12 -0
- package/dist/sensitive-key.js +52 -0
- package/dist/tool-pins.d.ts +40 -0
- package/dist/tool-pins.js +66 -0
- package/dist/ts-loader.d.ts +8 -0
- package/dist/ts-loader.js +19 -0
- package/dist/wave-runtime.mjs +345 -342
- 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/lexicon-outputs.d.ts +1 -1
- package/dist/workspace/lexicon-outputs.js +1 -1
- 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 +50 -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/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 +36 -0
- package/dist/workspace/release-train-workflow.js +121 -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 +183 -59
- package/dist/workspace/release-workflow.js +570 -201
- 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 +504 -0
- package/dist/workspace/train-prepare.d.ts +64 -0
- package/dist/workspace/train-prepare.js +313 -0
- package/dist/workspace/train-publish.d.ts +177 -0
- package/dist/workspace/train-publish.js +574 -0
- package/dist/workspace/train-range-labels.d.ts +33 -0
- package/dist/workspace/train-range-labels.js +109 -0
- 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/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
|
@@ -61,6 +61,8 @@ import { readFileSync } from "node:fs";
|
|
|
61
61
|
import { inflateRawSync } from "node:zlib";
|
|
62
62
|
import { readCredential } from "./publish-credentials.js";
|
|
63
63
|
import { bytesDigest, checkReleaseDigest, memberFile, publishTargetKey } from "./publish-targets.js";
|
|
64
|
+
import { releaseVersion } from "./publish-index.js";
|
|
65
|
+
import { trainName, waitUntilServed } from "./publish-train-names.js";
|
|
64
66
|
import { PublishTargetError, } from "./release-publish.js";
|
|
65
67
|
/** The first chant that publishes a `marketplace` target (#4676). */
|
|
66
68
|
export const PUBLISH_MARKETPLACE_FLOOR = "0.124.63";
|
|
@@ -281,12 +283,87 @@ export function marketplaceTarget(decl, deps) {
|
|
|
281
283
|
const body = JSON.parse(res.text);
|
|
282
284
|
return (body.results?.[0]?.extensions?.[0]?.versions ?? []).some((v) => v.version === id.version);
|
|
283
285
|
};
|
|
286
|
+
/** #5165: the extension's manifest: from the `.vsix` when the checkout has it, else the member's package.json. */
|
|
287
|
+
const manifestOf = (ctx) => {
|
|
288
|
+
try {
|
|
289
|
+
const entry = readZipEntry(readFileSync(memberFile(ctx.cwd, decl.vsix)), "extension/package.json");
|
|
290
|
+
if (entry)
|
|
291
|
+
return JSON.parse(entry.toString("utf-8"));
|
|
292
|
+
}
|
|
293
|
+
catch {
|
|
294
|
+
// No .vsix here: the member's own manifest names the extension.
|
|
295
|
+
}
|
|
296
|
+
try {
|
|
297
|
+
return JSON.parse(readFileSync(memberFile(ctx.cwd, "package.json"), "utf-8"));
|
|
298
|
+
}
|
|
299
|
+
catch {
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
/** Whether the marketplace lists the version, read without downloading it. */
|
|
304
|
+
const has = async (ctx, id) => {
|
|
305
|
+
if (decl.marketplace === "vscode")
|
|
306
|
+
return galleryHas(ctx, id);
|
|
307
|
+
const meta = await get(`${registry}/api/${encodeURIComponent(id.publisher)}/${encodeURIComponent(id.name)}/${encodeURIComponent(id.version)}`);
|
|
308
|
+
if (meta.status === 404)
|
|
309
|
+
return false;
|
|
310
|
+
if (meta.status !== 200)
|
|
311
|
+
fail(ctx, `reading ${id.publisher}.${id.name}@${id.version}`, meta.status, meta.text);
|
|
312
|
+
return true;
|
|
313
|
+
};
|
|
284
314
|
const target = {
|
|
285
315
|
kind: "marketplace",
|
|
286
316
|
name: `${label} ${decl.vsix}`,
|
|
287
317
|
destination: label,
|
|
288
318
|
credentialEnv: tokenNames,
|
|
289
319
|
key: publishTargetKey(decl),
|
|
320
|
+
uploadsAtReveal: true,
|
|
321
|
+
/** #5165: the extension, and the extensions its `extensionDependencies` and `extensionPack` name. */
|
|
322
|
+
async names(ctx) {
|
|
323
|
+
const m = manifestOf(ctx);
|
|
324
|
+
if (!m || typeof m.publisher !== "string" || typeof m.name !== "string")
|
|
325
|
+
return { provides: [], needs: [] };
|
|
326
|
+
const self = trainName("marketplace", `${m.publisher}.${m.name}`);
|
|
327
|
+
const needs = new Set();
|
|
328
|
+
for (const field of ["extensionDependencies", "extensionPack"]) {
|
|
329
|
+
const list = m[field];
|
|
330
|
+
if (Array.isArray(list))
|
|
331
|
+
for (const n of list)
|
|
332
|
+
if (typeof n === "string" && n.includes("."))
|
|
333
|
+
needs.add(trainName("marketplace", n));
|
|
334
|
+
}
|
|
335
|
+
needs.delete(self);
|
|
336
|
+
return { provides: [self], needs: [...needs] };
|
|
337
|
+
},
|
|
338
|
+
/** #5165: whether the marketplace lists the release's version of the extension. */
|
|
339
|
+
async published(ctx) {
|
|
340
|
+
const m = manifestOf(ctx);
|
|
341
|
+
const version = releaseVersion(ctx.label);
|
|
342
|
+
if (!m || typeof m.publisher !== "string" || typeof m.name !== "string" || !version)
|
|
343
|
+
return null;
|
|
344
|
+
return has(ctx, { publisher: m.publisher, name: m.name, version });
|
|
345
|
+
},
|
|
346
|
+
/** #5165: wait until the marketplace lists the version the reveal uploaded. */
|
|
347
|
+
async visible(ctx, published) {
|
|
348
|
+
const ids = published.items
|
|
349
|
+
.filter((i) => !i.refused)
|
|
350
|
+
.map((i) => /^([^.@]+)\.([^@]+)@(.+)$/.exec(i.name))
|
|
351
|
+
.filter((m) => m !== null)
|
|
352
|
+
.map((m) => ({ publisher: m[1], name: m[2], version: m[3] }));
|
|
353
|
+
if (ids.length === 0)
|
|
354
|
+
return;
|
|
355
|
+
await waitUntilServed(ctx, deps, {
|
|
356
|
+
what: label,
|
|
357
|
+
code: "publish-marketplace-not-served",
|
|
358
|
+
check: async () => {
|
|
359
|
+
const missing = [];
|
|
360
|
+
for (const id of ids)
|
|
361
|
+
if (!(await has(ctx, id)))
|
|
362
|
+
missing.push(`${id.publisher}.${id.name}@${id.version}`);
|
|
363
|
+
return missing;
|
|
364
|
+
},
|
|
365
|
+
});
|
|
366
|
+
},
|
|
290
367
|
async plan(ctx) {
|
|
291
368
|
return [setup(ctx).item];
|
|
292
369
|
},
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Maven Central target (#5232): a bundle of Maven components uploaded to
|
|
3
|
+
* the Central Portal (`POST /api/v1/publisher/upload`).
|
|
4
|
+
*
|
|
5
|
+
* The bundle is a `.zip` in Maven repository layout
|
|
6
|
+
* (`<group path>/<artifactId>/<version>/<artifactId>-<version>.pom` and the
|
|
7
|
+
* files beside it), a directory in that layout, which chant zips, or
|
|
8
|
+
* `artifact:<name>` for the one `.zip` the release records for that entry. A
|
|
9
|
+
* directory gets a `.md5` and `.sha1` for each file that has none, as Central
|
|
10
|
+
* asks; chant signs nothing, so each file needs its `.asc` beside it, from the
|
|
11
|
+
* build (`publish-maven-unsigned`). A file the release records must match its
|
|
12
|
+
* digest.
|
|
13
|
+
*
|
|
14
|
+
* The Portal holds a deployment it has validated until someone publishes it,
|
|
15
|
+
* so this target stages for real. The stage reads the repository
|
|
16
|
+
* (`https://repo1.maven.org/maven2/`) for each component's `.pom`: a
|
|
17
|
+
* component it serves with the same bytes is `present`, one with other
|
|
18
|
+
* bytes, or a bundle only part of which is there, is refused
|
|
19
|
+
* (`publish-maven-version-exists`). It then uploads the bundle with
|
|
20
|
+
* `publishingType=USER_MANAGED` and waits until the Portal says `VALIDATED`;
|
|
21
|
+
* `FAILED` is refused with the Portal's errors (`publish-maven-invalid`), and
|
|
22
|
+
* the deployment is left in the Portal for a person to read. The deployment's
|
|
23
|
+
* id goes in the publish record's state. The reveal publishes that deployment
|
|
24
|
+
* (`POST /api/v1/publisher/deployment/<id>`); one the Portal already
|
|
25
|
+
* publishes is not sent again.
|
|
26
|
+
*
|
|
27
|
+
* Credentials: a Central Portal user token, its name from `usernameEnv`
|
|
28
|
+
* (default `MAVEN_CENTRAL_USERNAME`) and its password from `passwordEnv`
|
|
29
|
+
* (default `MAVEN_CENTRAL_PASSWORD`), sent as `Authorization: Bearer
|
|
30
|
+
* <base64 of name:password>`. The Portal has no trusted publishing.
|
|
31
|
+
*
|
|
32
|
+
* Maven Central keeps every version it publishes and has no deprecation, so
|
|
33
|
+
* the target has no status change, and `chant release yank` refuses it.
|
|
34
|
+
*
|
|
35
|
+
* Under the `supply-chain` group a component with no SBOM in it (a file
|
|
36
|
+
* ending `-cyclonedx.json`, `-cyclonedx.xml` or `-spdx.json`, as the
|
|
37
|
+
* CycloneDX and SPDX Maven plugins attach one) is refused unless `sbom` is
|
|
38
|
+
* `false`.
|
|
39
|
+
*/
|
|
40
|
+
import type { MavenPublishDeclaration } from "./publish-declaration.js";
|
|
41
|
+
import { type PublishContext, type PublishDeps, type PublishTarget } from "./release-publish.js";
|
|
42
|
+
/** The first chant that publishes a `maven` target (#5232). */
|
|
43
|
+
export declare const PUBLISH_MAVEN_FLOOR = "0.124.102";
|
|
44
|
+
export declare const CENTRAL_PORTAL = "https://central.sonatype.com";
|
|
45
|
+
export declare const MAVEN_CENTRAL_REPOSITORY = "https://repo1.maven.org/maven2/";
|
|
46
|
+
/** How often the stage asks the Portal whether it has validated the bundle. */
|
|
47
|
+
export declare const MAVEN_STATUS_POLL_MS = 10000;
|
|
48
|
+
/** How long the stage waits for the Portal to validate the bundle. */
|
|
49
|
+
export declare const MAVEN_VALIDATION_WAIT_MS: number;
|
|
50
|
+
/** How long a train waits for the repository to serve what the reveal published: Central takes up to half an hour. */
|
|
51
|
+
export declare const MAVEN_VISIBLE_WAIT_MS: number;
|
|
52
|
+
export declare const mavenUsernameEnv: (decl: Pick<MavenPublishDeclaration, "usernameEnv">) => string;
|
|
53
|
+
export declare const mavenPasswordEnv: (decl: Pick<MavenPublishDeclaration, "passwordEnv">) => string;
|
|
54
|
+
/** One Maven component of a bundle. */
|
|
55
|
+
export interface MavenComponent {
|
|
56
|
+
groupId: string;
|
|
57
|
+
artifactId: string;
|
|
58
|
+
version: string;
|
|
59
|
+
/** Its directory in the bundle. */
|
|
60
|
+
dir: string;
|
|
61
|
+
pom: Buffer;
|
|
62
|
+
/** Its files in the bundle, by path. */
|
|
63
|
+
files: string[];
|
|
64
|
+
/** The SBOM file it carries, if any. */
|
|
65
|
+
sbom: string | null;
|
|
66
|
+
}
|
|
67
|
+
/** The components of a bundle's files, keyed by path. */
|
|
68
|
+
export declare function mavenComponents(files: ReadonlyMap<string, Buffer>): MavenComponent[];
|
|
69
|
+
/** The `groupId:artifactId` of each dependency a `.pom` needs at compile or run time. */
|
|
70
|
+
export declare function pomDependencies(pom: string): string[];
|
|
71
|
+
/** The bundle a declaration names, read: the zip to upload and its components. */
|
|
72
|
+
export declare function readMavenBundle(ctx: Pick<PublishContext, "cwd" | "release">, bundle: string): {
|
|
73
|
+
path: string;
|
|
74
|
+
zip: Buffer;
|
|
75
|
+
digest: string;
|
|
76
|
+
files: Map<string, Buffer>;
|
|
77
|
+
components: MavenComponent[];
|
|
78
|
+
};
|
|
79
|
+
export declare function mavenTarget(decl: MavenPublishDeclaration, deps: PublishDeps): PublishTarget;
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Maven Central target (#5232): a bundle of Maven components uploaded to
|
|
3
|
+
* the Central Portal (`POST /api/v1/publisher/upload`).
|
|
4
|
+
*
|
|
5
|
+
* The bundle is a `.zip` in Maven repository layout
|
|
6
|
+
* (`<group path>/<artifactId>/<version>/<artifactId>-<version>.pom` and the
|
|
7
|
+
* files beside it), a directory in that layout, which chant zips, or
|
|
8
|
+
* `artifact:<name>` for the one `.zip` the release records for that entry. A
|
|
9
|
+
* directory gets a `.md5` and `.sha1` for each file that has none, as Central
|
|
10
|
+
* asks; chant signs nothing, so each file needs its `.asc` beside it, from the
|
|
11
|
+
* build (`publish-maven-unsigned`). A file the release records must match its
|
|
12
|
+
* digest.
|
|
13
|
+
*
|
|
14
|
+
* The Portal holds a deployment it has validated until someone publishes it,
|
|
15
|
+
* so this target stages for real. The stage reads the repository
|
|
16
|
+
* (`https://repo1.maven.org/maven2/`) for each component's `.pom`: a
|
|
17
|
+
* component it serves with the same bytes is `present`, one with other
|
|
18
|
+
* bytes, or a bundle only part of which is there, is refused
|
|
19
|
+
* (`publish-maven-version-exists`). It then uploads the bundle with
|
|
20
|
+
* `publishingType=USER_MANAGED` and waits until the Portal says `VALIDATED`;
|
|
21
|
+
* `FAILED` is refused with the Portal's errors (`publish-maven-invalid`), and
|
|
22
|
+
* the deployment is left in the Portal for a person to read. The deployment's
|
|
23
|
+
* id goes in the publish record's state. The reveal publishes that deployment
|
|
24
|
+
* (`POST /api/v1/publisher/deployment/<id>`); one the Portal already
|
|
25
|
+
* publishes is not sent again.
|
|
26
|
+
*
|
|
27
|
+
* Credentials: a Central Portal user token, its name from `usernameEnv`
|
|
28
|
+
* (default `MAVEN_CENTRAL_USERNAME`) and its password from `passwordEnv`
|
|
29
|
+
* (default `MAVEN_CENTRAL_PASSWORD`), sent as `Authorization: Bearer
|
|
30
|
+
* <base64 of name:password>`. The Portal has no trusted publishing.
|
|
31
|
+
*
|
|
32
|
+
* Maven Central keeps every version it publishes and has no deprecation, so
|
|
33
|
+
* the target has no status change, and `chant release yank` refuses it.
|
|
34
|
+
*
|
|
35
|
+
* Under the `supply-chain` group a component with no SBOM in it (a file
|
|
36
|
+
* ending `-cyclonedx.json`, `-cyclonedx.xml` or `-spdx.json`, as the
|
|
37
|
+
* CycloneDX and SPDX Maven plugins attach one) is refused unless `sbom` is
|
|
38
|
+
* `false`.
|
|
39
|
+
*/
|
|
40
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
41
|
+
import { readdirSync, readFileSync, statSync } from "node:fs";
|
|
42
|
+
import { join, relative } from "node:path";
|
|
43
|
+
import { readCredential } from "./publish-credentials.js";
|
|
44
|
+
import { releaseVersion } from "./publish-index.js";
|
|
45
|
+
import { zipEntry, zipEntryNames } from "./publish-pypi.js";
|
|
46
|
+
import { bytesDigest, checkReleaseDigest, expandArtifactAssets, memberFile, publishTargetKey } from "./publish-targets.js";
|
|
47
|
+
import { trainName, waitUntilServed } from "./publish-train-names.js";
|
|
48
|
+
import { zipArchive } from "./release-artifacts.js";
|
|
49
|
+
import { NEXT_RELEASE } from "../release-floors.js";
|
|
50
|
+
import { PublishTargetError } from "./release-publish.js";
|
|
51
|
+
/** The first chant that publishes a `maven` target (#5232). */
|
|
52
|
+
export const PUBLISH_MAVEN_FLOOR = NEXT_RELEASE;
|
|
53
|
+
export const CENTRAL_PORTAL = "https://central.sonatype.com";
|
|
54
|
+
export const MAVEN_CENTRAL_REPOSITORY = "https://repo1.maven.org/maven2/";
|
|
55
|
+
/** How often the stage asks the Portal whether it has validated the bundle. */
|
|
56
|
+
export const MAVEN_STATUS_POLL_MS = 10000;
|
|
57
|
+
/** How long the stage waits for the Portal to validate the bundle. */
|
|
58
|
+
export const MAVEN_VALIDATION_WAIT_MS = 30 * 60000;
|
|
59
|
+
/** How long a train waits for the repository to serve what the reveal published: Central takes up to half an hour. */
|
|
60
|
+
export const MAVEN_VISIBLE_WAIT_MS = 60 * 60000;
|
|
61
|
+
export const mavenUsernameEnv = (decl) => decl.usernameEnv ?? "MAVEN_CENTRAL_USERNAME";
|
|
62
|
+
export const mavenPasswordEnv = (decl) => decl.passwordEnv ?? "MAVEN_CENTRAL_PASSWORD";
|
|
63
|
+
const CHECKSUM = /\.(md5|sha1|sha256|sha512)$/;
|
|
64
|
+
/** The components of a bundle's files, keyed by path. */
|
|
65
|
+
export function mavenComponents(files) {
|
|
66
|
+
const out = [];
|
|
67
|
+
for (const [path, bytes] of [...files.entries()].sort(([a], [b]) => a.localeCompare(b))) {
|
|
68
|
+
const m = /^(.+)\/([^/]+)\/([^/]+)\/([^/]+)\.pom$/.exec(path);
|
|
69
|
+
if (!m || m[4] !== `${m[2]}-${m[3]}`)
|
|
70
|
+
continue;
|
|
71
|
+
const dir = `${m[1]}/${m[2]}/${m[3]}`;
|
|
72
|
+
const own = [...files.keys()].filter((f) => f.startsWith(`${dir}/`) && !f.slice(dir.length + 1).includes("/")).sort();
|
|
73
|
+
out.push({ groupId: m[1].split("/").join("."), artifactId: m[2], version: m[3], dir, pom: bytes, files: own, sbom: own.find((f) => /-(cyclonedx\.(json|xml)|spdx\.json)$/.test(f)) ?? null });
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
/** The `groupId:artifactId` of each dependency a `.pom` needs at compile or run time. */
|
|
78
|
+
export function pomDependencies(pom) {
|
|
79
|
+
const body = pom.replace(/<!--[\s\S]*?-->/g, "").replace(/<dependencyManagement>[\s\S]*?<\/dependencyManagement>/g, "").replace(/<build>[\s\S]*?<\/build>/g, "").replace(/<profiles>[\s\S]*?<\/profiles>/g, "");
|
|
80
|
+
const out = new Set();
|
|
81
|
+
for (const d of body.matchAll(/<dependency>([\s\S]*?)<\/dependency>/g)) {
|
|
82
|
+
const get = (tag) => new RegExp(`<${tag}>\\s*([^<]+?)\\s*</${tag}>`).exec(d[1])?.[1];
|
|
83
|
+
const scope = get("scope") ?? "compile";
|
|
84
|
+
if (scope === "test" || scope === "provided" || scope === "system" || get("optional") === "true")
|
|
85
|
+
continue;
|
|
86
|
+
const g = get("groupId");
|
|
87
|
+
const a = get("artifactId");
|
|
88
|
+
if (g && a && !g.includes("${"))
|
|
89
|
+
out.add(`${g}:${a}`);
|
|
90
|
+
}
|
|
91
|
+
return [...out];
|
|
92
|
+
}
|
|
93
|
+
const hex = (algo, bytes) => createHash(algo).update(bytes).digest("hex");
|
|
94
|
+
/** Every file under `abs`, by its path from `abs` with `/` between parts. */
|
|
95
|
+
function walk(abs, base = abs) {
|
|
96
|
+
return readdirSync(abs)
|
|
97
|
+
.sort()
|
|
98
|
+
.flatMap((n) => {
|
|
99
|
+
const p = join(abs, n);
|
|
100
|
+
return statSync(p).isDirectory() ? walk(p, base) : [relative(base, p).split("\\").join("/")];
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/** The bundle a declaration names, read: the zip to upload and its components. */
|
|
104
|
+
export function readMavenBundle(ctx, bundle) {
|
|
105
|
+
const paths = expandArtifactAssets(ctx.release, [bundle]);
|
|
106
|
+
if (paths.length !== 1)
|
|
107
|
+
throw new PublishTargetError("publish-maven-bundle", `${bundle} is ${paths.length} files, and a maven target uploads one bundle`, "Have the build write one .zip, or name the directory in Maven repository layout.");
|
|
108
|
+
const path = paths[0];
|
|
109
|
+
const abs = memberFile(ctx.cwd, path);
|
|
110
|
+
const files = new Map();
|
|
111
|
+
let zip;
|
|
112
|
+
if (statSync(abs).isDirectory()) {
|
|
113
|
+
for (const f of walk(abs)) {
|
|
114
|
+
const bytes = readFileSync(join(abs, f));
|
|
115
|
+
checkReleaseDigest(ctx.release, "asset", ctx.cwd, join(path, f), [bytesDigest(new Uint8Array(bytes))]);
|
|
116
|
+
files.set(f, bytes);
|
|
117
|
+
}
|
|
118
|
+
for (const [f, bytes] of [...files.entries()]) {
|
|
119
|
+
if (CHECKSUM.test(f) || f.endsWith(".asc"))
|
|
120
|
+
continue;
|
|
121
|
+
if (!files.has(`${f}.md5`))
|
|
122
|
+
files.set(`${f}.md5`, Buffer.from(hex("md5", bytes)));
|
|
123
|
+
if (!files.has(`${f}.sha1`))
|
|
124
|
+
files.set(`${f}.sha1`, Buffer.from(hex("sha1", bytes)));
|
|
125
|
+
}
|
|
126
|
+
zip = zipArchive([...files.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([name, bytes]) => ({ name, bytes })), 315532800);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
zip = readFileSync(abs);
|
|
130
|
+
checkReleaseDigest(ctx.release, "asset", ctx.cwd, path, [bytesDigest(new Uint8Array(zip))]);
|
|
131
|
+
try {
|
|
132
|
+
for (const n of zipEntryNames(zip))
|
|
133
|
+
if (!n.endsWith("/"))
|
|
134
|
+
files.set(n, zipEntry(zip, n) ?? Buffer.alloc(0));
|
|
135
|
+
}
|
|
136
|
+
catch (err) {
|
|
137
|
+
throw new PublishTargetError("publish-maven-bundle", `${path} is not a zip chant can read: ${err instanceof Error ? err.message : String(err)}`, "Name a .zip in Maven repository layout, or the directory itself.");
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const components = mavenComponents(files);
|
|
141
|
+
if (components.length === 0) {
|
|
142
|
+
throw new PublishTargetError("publish-maven-no-components", `${path} holds no component: no <group path>/<artifactId>/<version>/<artifactId>-<version>.pom`, "Point bundle at a Maven repository layout, such as the directory mvn deploy -DaltDeploymentRepository=local::file:./target/staging-deploy writes.");
|
|
143
|
+
}
|
|
144
|
+
for (const c of components) {
|
|
145
|
+
if (c.version.endsWith("-SNAPSHOT"))
|
|
146
|
+
throw new PublishTargetError("publish-maven-snapshot", `${c.groupId}:${c.artifactId}:${c.version} is a snapshot, and Maven Central publishes releases`, "Build the release's version, such as the release's label.");
|
|
147
|
+
const unsigned = c.files.filter((f) => !CHECKSUM.test(f) && !f.endsWith(".asc") && !files.has(`${f}.asc`));
|
|
148
|
+
if (unsigned.length > 0) {
|
|
149
|
+
throw new PublishTargetError("publish-maven-unsigned", `${unsigned.join(", ")} ${unsigned.length === 1 ? "has" : "have"} no .asc signature beside ${unsigned.length === 1 ? "it" : "them"}, and Maven Central takes only signed files`, "Sign the files with GPG in the build, such as with maven-gpg-plugin, and publish the key's public half to a keyserver.");
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return { path, zip, digest: bytesDigest(new Uint8Array(zip)), files, components };
|
|
153
|
+
}
|
|
154
|
+
const coordinate = (c) => `${c.groupId}:${c.artifactId}@${c.version}`;
|
|
155
|
+
export function mavenTarget(decl, deps) {
|
|
156
|
+
const fetchImpl = deps.fetch ?? ((url, init) => fetch(url, init));
|
|
157
|
+
const sleep = deps.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
158
|
+
const now = deps.now ?? Date.now;
|
|
159
|
+
const api = (decl.api ?? CENTRAL_PORTAL).replace(/\/+$/, "");
|
|
160
|
+
const repository = (decl.repository ?? MAVEN_CENTRAL_REPOSITORY).replace(/\/*$/, "/");
|
|
161
|
+
const userName = mavenUsernameEnv(decl);
|
|
162
|
+
const passName = mavenPasswordEnv(decl);
|
|
163
|
+
const label = decl.api ? new URL(api).host : "Maven Central";
|
|
164
|
+
const read = (ctx) => {
|
|
165
|
+
const b = readMavenBundle(ctx, decl.bundle);
|
|
166
|
+
if (ctx.requireSbom && decl.sbom !== false) {
|
|
167
|
+
const without = b.components.find((c) => c.sbom === null);
|
|
168
|
+
if (without) {
|
|
169
|
+
throw new PublishTargetError("publish-sbom-missing", `${without.groupId}:${without.artifactId}:${without.version} carries no SBOM: Maven Central keeps an SBOM as a file of the component, such as ${without.artifactId}-${without.version}-cyclonedx.json`, "Attach one in the build, such as with cyclonedx-maven-plugin, or set sbom: false to publish without one.");
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return b;
|
|
173
|
+
};
|
|
174
|
+
const items = (cs) => cs.map((c) => ({ name: coordinate(c), destination: `${CENTRAL_PORTAL}/artifact/${c.groupId}/${c.artifactId}/${c.version}`, digest: bytesDigest(new Uint8Array(c.pom)), ...(c.sbom ? { sbom: c.sbom.split("/").pop() } : {}) }));
|
|
175
|
+
const authorization = (ctx) => {
|
|
176
|
+
const user = readCredential(ctx.env, [userName], ctx.redactor);
|
|
177
|
+
const pass = readCredential(ctx.env, [passName], ctx.redactor);
|
|
178
|
+
if (!user || !pass) {
|
|
179
|
+
throw new PublishTargetError("publish-credentials-missing", `the ${label} target reads a Central Portal user token from ${userName} and ${passName}, and ${[!user ? userName : null, !pass ? passName : null].filter(Boolean).join(" and ")} ${!user && !pass ? "are" : "is"} not set`, `Generate a user token at ${CENTRAL_PORTAL}/account and set ${userName} to its name and ${passName} to its password.`);
|
|
180
|
+
}
|
|
181
|
+
const bearer = Buffer.from(`${user.value}:${pass.value}`, "utf-8").toString("base64");
|
|
182
|
+
ctx.redactor.add(bearer);
|
|
183
|
+
return `Bearer ${bearer}`;
|
|
184
|
+
};
|
|
185
|
+
const fail = (ctx, code, what, status, text, fix) => {
|
|
186
|
+
throw new PublishTargetError(code, ctx.redactor.redact(`${what} on ${label} answered ${status}${text ? `: ${text.replace(/\s+/g, " ").slice(0, 300)}` : ""}`), fix);
|
|
187
|
+
};
|
|
188
|
+
const pomUrl = (c) => `${repository}${c.groupId.split(".").join("/")}/${c.artifactId}/${c.version}/${c.artifactId}-${c.version}.pom`;
|
|
189
|
+
/** The `.pom` the repository serves for a component, or null. */
|
|
190
|
+
const served = async (ctx, c) => {
|
|
191
|
+
const url = pomUrl(c);
|
|
192
|
+
const res = await fetchImpl(url, { method: "GET", headers: { "user-agent": "chant" } });
|
|
193
|
+
if (res.status === 404)
|
|
194
|
+
return null;
|
|
195
|
+
if (res.status !== 200)
|
|
196
|
+
fail(ctx, "publish-maven-failed", `reading ${url}`, res.status, await res.text().catch(() => ""));
|
|
197
|
+
return res.arrayBuffer ? Buffer.from(await res.arrayBuffer()) : Buffer.from(await res.text(), "utf-8");
|
|
198
|
+
};
|
|
199
|
+
/** True when every component is published with the same `.pom`; false when none is; refused otherwise. */
|
|
200
|
+
const published = async (ctx, cs) => {
|
|
201
|
+
const there = [];
|
|
202
|
+
for (const c of cs) {
|
|
203
|
+
const pom = await served(ctx, c);
|
|
204
|
+
if (pom === null)
|
|
205
|
+
continue;
|
|
206
|
+
if (!pom.equals(c.pom))
|
|
207
|
+
throw new PublishTargetError("publish-maven-version-exists", `${label} already has ${c.groupId}:${c.artifactId}:${c.version}, with another .pom`, "Maven Central never takes a version twice: cut a release with a new version.");
|
|
208
|
+
there.push(coordinate(c));
|
|
209
|
+
}
|
|
210
|
+
if (there.length === 0)
|
|
211
|
+
return false;
|
|
212
|
+
if (there.length === cs.length)
|
|
213
|
+
return true;
|
|
214
|
+
throw new PublishTargetError("publish-maven-version-exists", `${label} already has ${there.join(", ")}, and not ${cs.map(coordinate).filter((n) => !there.includes(n)).join(", ")}; a deployment that holds a published component fails validation`, "Leave the published components out of the bundle, or cut a release with a new version.");
|
|
215
|
+
};
|
|
216
|
+
/** The deployment's state and errors, or null when the Portal has no such deployment. */
|
|
217
|
+
const status = async (ctx, auth, id) => {
|
|
218
|
+
const url = `${api}/api/v1/publisher/status?id=${encodeURIComponent(id)}`;
|
|
219
|
+
const res = await fetchImpl(url, { method: "POST", headers: { "user-agent": "chant", accept: "application/json", authorization: auth } });
|
|
220
|
+
const text = await res.text().catch(() => "");
|
|
221
|
+
if (res.status === 404)
|
|
222
|
+
return null;
|
|
223
|
+
if (res.status !== 200)
|
|
224
|
+
fail(ctx, "publish-maven-failed", `reading deployment ${id}`, res.status, text);
|
|
225
|
+
try {
|
|
226
|
+
const body = JSON.parse(text);
|
|
227
|
+
return { state: typeof body.deploymentState === "string" ? body.deploymentState : "UNKNOWN", errors: body.errors === undefined ? "" : JSON.stringify(body.errors) };
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
return fail(ctx, "publish-maven-failed", `reading deployment ${id}`, res.status, "not JSON");
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
/** Wait until the Portal is done validating; refuses `FAILED` and a wait past the cap. */
|
|
234
|
+
const validated = async (ctx, auth, id) => {
|
|
235
|
+
const start = now();
|
|
236
|
+
let logged;
|
|
237
|
+
for (;;) {
|
|
238
|
+
const s = await status(ctx, auth, id);
|
|
239
|
+
if (s === null)
|
|
240
|
+
throw new PublishTargetError("publish-maven-deployment-missing", `${label} has no deployment ${id}: it was dropped`, "Cut a release with a new version, or upload the bundle in the Central Portal by hand.");
|
|
241
|
+
if (s.state === "FAILED") {
|
|
242
|
+
throw new PublishTargetError("publish-maven-invalid", ctx.redactor.redact(`${label} refused deployment ${id}${s.errors ? `: ${s.errors.slice(0, 600)}` : ""}`), `Fix the bundle and cut a new release. The deployment stays in the Central Portal at ${CENTRAL_PORTAL}/publishing/deployments, where it can be read and dropped.`);
|
|
243
|
+
}
|
|
244
|
+
if (s.state !== "PENDING" && s.state !== "VALIDATING")
|
|
245
|
+
return s.state;
|
|
246
|
+
if (now() - start >= MAVEN_VALIDATION_WAIT_MS) {
|
|
247
|
+
throw new PublishTargetError("publish-maven-validation-timeout", `${label} did not validate deployment ${id} within ${Math.round(MAVEN_VALIDATION_WAIT_MS / 60000)} minutes`, "Run the same publish again: it waits on the same deployment and uploads nothing twice.");
|
|
248
|
+
}
|
|
249
|
+
if (logged === undefined || now() - logged >= 60000) {
|
|
250
|
+
ctx.log(`waiting for ${label} to validate deployment ${id} (${s.state})`);
|
|
251
|
+
logged = now();
|
|
252
|
+
}
|
|
253
|
+
await sleep(MAVEN_STATUS_POLL_MS);
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
const target = {
|
|
257
|
+
kind: "maven",
|
|
258
|
+
name: `${label} ${decl.bundle}`,
|
|
259
|
+
destination: label,
|
|
260
|
+
credentialEnv: [userName, passName],
|
|
261
|
+
key: publishTargetKey(decl),
|
|
262
|
+
async names(ctx) {
|
|
263
|
+
const { components } = readMavenBundle(ctx, decl.bundle);
|
|
264
|
+
const provides = components.map((c) => trainName("maven", `${c.groupId}:${c.artifactId}`));
|
|
265
|
+
const needs = new Set(components.flatMap((c) => pomDependencies(c.pom.toString("utf-8")).map((d) => trainName("maven", d))));
|
|
266
|
+
return { provides, needs: [...needs].filter((n) => !provides.includes(n)) };
|
|
267
|
+
},
|
|
268
|
+
/** #5165: whether the repository serves each component's `.pom` at the release's version. */
|
|
269
|
+
async published(ctx) {
|
|
270
|
+
const version = releaseVersion(ctx.label);
|
|
271
|
+
if (!version)
|
|
272
|
+
return null;
|
|
273
|
+
let components;
|
|
274
|
+
try {
|
|
275
|
+
components = readMavenBundle(ctx, decl.bundle).components;
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
for (const c of components)
|
|
281
|
+
if ((await served(ctx, { ...c, version })) === null)
|
|
282
|
+
return false;
|
|
283
|
+
return true;
|
|
284
|
+
},
|
|
285
|
+
/** #5165: wait until the repository serves each component the reveal published. */
|
|
286
|
+
async visible(ctx, done) {
|
|
287
|
+
const cs = done.items.filter((i) => i.attachment === undefined && !i.refused).map((i) => /^([^:]+):([^@]+)@(.+)$/.exec(i.name)).filter((m) => m !== null).map((m) => ({ groupId: m[1], artifactId: m[2], version: m[3] }));
|
|
288
|
+
if (cs.length === 0)
|
|
289
|
+
return;
|
|
290
|
+
await waitUntilServed(ctx, deps, {
|
|
291
|
+
what: label,
|
|
292
|
+
code: "publish-maven-not-served",
|
|
293
|
+
capMs: MAVEN_VISIBLE_WAIT_MS,
|
|
294
|
+
check: async () => {
|
|
295
|
+
const missing = [];
|
|
296
|
+
for (const c of cs)
|
|
297
|
+
if ((await served(ctx, c)) === null)
|
|
298
|
+
missing.push(coordinate(c));
|
|
299
|
+
return missing;
|
|
300
|
+
},
|
|
301
|
+
});
|
|
302
|
+
},
|
|
303
|
+
async plan(ctx) {
|
|
304
|
+
const b = read(ctx);
|
|
305
|
+
authorization(ctx);
|
|
306
|
+
return items(b.components);
|
|
307
|
+
},
|
|
308
|
+
async stage(ctx) {
|
|
309
|
+
const b = read(ctx);
|
|
310
|
+
const auth = authorization(ctx);
|
|
311
|
+
if (await published(ctx, b.components)) {
|
|
312
|
+
ctx.log(`${label} already has every component with the same .pom`);
|
|
313
|
+
const staged = { target: target.name, destination: target.destination, items: items(b.components).map((i) => ({ ...i, present: true })), state: { present: "true" } };
|
|
314
|
+
return staged;
|
|
315
|
+
}
|
|
316
|
+
const boundary = `chant-${randomBytes(12).toString("hex")}`;
|
|
317
|
+
const name = `${b.components[0].groupId}:${b.components[0].artifactId}:${b.components[0].version}`;
|
|
318
|
+
const body = Buffer.concat([
|
|
319
|
+
Buffer.from(`--${boundary}\r\nContent-Disposition: form-data; name="bundle"; filename="bundle.zip"\r\nContent-Type: application/octet-stream\r\n\r\n`, "utf-8"),
|
|
320
|
+
b.zip,
|
|
321
|
+
Buffer.from(`\r\n--${boundary}--\r\n`, "utf-8"),
|
|
322
|
+
]);
|
|
323
|
+
ctx.log(`uploading ${b.path} (${b.zip.byteLength} bytes, ${b.components.length} component${b.components.length === 1 ? "" : "s"}) to ${label}, held for the reveal to publish`);
|
|
324
|
+
const res = await fetchImpl(`${api}/api/v1/publisher/upload?publishingType=USER_MANAGED&name=${encodeURIComponent(name)}`, {
|
|
325
|
+
method: "POST",
|
|
326
|
+
headers: { "user-agent": "chant", "content-type": `multipart/form-data; boundary=${boundary}`, authorization: auth },
|
|
327
|
+
body: new Uint8Array(body),
|
|
328
|
+
});
|
|
329
|
+
const text = (await res.text().catch(() => "")).trim();
|
|
330
|
+
if (res.status !== 200 && res.status !== 201)
|
|
331
|
+
fail(ctx, "publish-maven-failed", "uploading the bundle", res.status, text, res.status === 401 || res.status === 403 ? `Check the user token in ${userName} and ${passName}, and that its account owns the namespace ${b.components[0].groupId}.` : undefined);
|
|
332
|
+
const id = text.replace(/^"|"$/g, "");
|
|
333
|
+
if (!id)
|
|
334
|
+
fail(ctx, "publish-maven-failed", "uploading the bundle", res.status, "no deployment id");
|
|
335
|
+
ctx.log(`${label} took the bundle as deployment ${id}`);
|
|
336
|
+
const state = await validated(ctx, auth, id);
|
|
337
|
+
ctx.log(`${label} validated deployment ${id} (${state}); the reveal publishes it`);
|
|
338
|
+
const staged = { target: target.name, destination: target.destination, items: items(b.components), state: { deployment: id } };
|
|
339
|
+
return staged;
|
|
340
|
+
},
|
|
341
|
+
async reveal(ctx, staged) {
|
|
342
|
+
if (staged.state.present === "true")
|
|
343
|
+
return { target: target.name, destination: target.destination, items: staged.items.map((i) => ({ ...i, present: true })) };
|
|
344
|
+
const id = staged.state.deployment;
|
|
345
|
+
if (!id)
|
|
346
|
+
throw new PublishTargetError("publish-maven-deployment-missing", "the stage recorded no deployment to publish", "Cut a release with a new version.");
|
|
347
|
+
const auth = authorization(ctx);
|
|
348
|
+
const state = await validated(ctx, auth, id);
|
|
349
|
+
if (state === "PUBLISHING" || state === "PUBLISHED") {
|
|
350
|
+
ctx.log(`${label} already publishes deployment ${id} (${state})`);
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
ctx.log(`publishing deployment ${id} on ${label}`);
|
|
354
|
+
const res = await fetchImpl(`${api}/api/v1/publisher/deployment/${encodeURIComponent(id)}`, { method: "POST", headers: { "user-agent": "chant", authorization: auth } });
|
|
355
|
+
const text = await res.text().catch(() => "");
|
|
356
|
+
if (res.status < 200 || res.status > 299)
|
|
357
|
+
fail(ctx, "publish-maven-failed", `publishing deployment ${id}`, res.status, text);
|
|
358
|
+
ctx.log(`${label} is publishing deployment ${id}; the repository serves it within about half an hour`);
|
|
359
|
+
}
|
|
360
|
+
return { target: target.name, destination: target.destination, items: staged.items };
|
|
361
|
+
},
|
|
362
|
+
};
|
|
363
|
+
return target;
|
|
364
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MCP Registry target (#5162): a `server.json` published to the official
|
|
3
|
+
* MCP Registry, https://registry.modelcontextprotocol.io, so MCP clients find
|
|
4
|
+
* the server. A `server.json` names the npm packages, PyPI packages or OCI
|
|
5
|
+
* images that run the server, and the registry checks they exist, so this
|
|
6
|
+
* target reveals after every other target (`revealsLast`).
|
|
7
|
+
*
|
|
8
|
+
* It speaks the registry's HTTP API directly, the requests `mcp-publisher
|
|
9
|
+
* login github-oidc` and `mcp-publisher publish` make, so no tool is
|
|
10
|
+
* downloaded or run:
|
|
11
|
+
*
|
|
12
|
+
* - `POST /v0.1/auth/github-oidc` with `{ "oidc_token": ... }` exchanges the
|
|
13
|
+
* GitHub Actions OIDC token, requested with the registry's origin
|
|
14
|
+
* (`https://registry.modelcontextprotocol.io`) as its audience, for a
|
|
15
|
+
* registry token that lasts minutes. `POST /v0.1/auth/github-at` does the
|
|
16
|
+
* same for a GitHub token (`{ "github_token": ... }`).
|
|
17
|
+
* - `GET /v0.1/servers/{name}/versions/{version}` says whether a version is
|
|
18
|
+
* already published.
|
|
19
|
+
* - `POST /v0.1/publish` with the `server.json` as the body and the registry
|
|
20
|
+
* token as a bearer credential publishes it.
|
|
21
|
+
*
|
|
22
|
+
* The registry has no draft and refuses a version it already holds, and it
|
|
23
|
+
* does not let a version be replaced. So the stage sends nothing: it checks
|
|
24
|
+
* the `server.json` against the release, exchanges for a token to prove the
|
|
25
|
+
* credentials work, and reads whether the version is there. The reveal
|
|
26
|
+
* publishes.
|
|
27
|
+
*
|
|
28
|
+
* The `server.json` must belong to this release: its `version` is the
|
|
29
|
+
* release's label (from its first digit), and each package that names a
|
|
30
|
+
* version, and each OCI image's tag, is the same. Anything else is refused in
|
|
31
|
+
* the plan (`publish-mcp-registry-version-mismatch`,
|
|
32
|
+
* `publish-mcp-registry-package-mismatch`), so a release can't publish a
|
|
33
|
+
* listing for another version. `release.version.files` stamps the label into
|
|
34
|
+
* the file.
|
|
35
|
+
*/
|
|
36
|
+
import type { McpRegistryPublishDeclaration } from "./publish-declaration.js";
|
|
37
|
+
import { type PublishDeps, type PublishTarget } from "./release-publish.js";
|
|
38
|
+
/** The first chant with the `mcp-registry` publish target: a `server.json` published to the MCP Registry after the packages it names, with GitHub OIDC, and the `mcp-registry-*` checks of `chant release doctor` (#5162). */
|
|
39
|
+
export declare const PUBLISH_MCP_REGISTRY_FLOOR = "0.124.101";
|
|
40
|
+
export declare const MCP_REGISTRY = "https://registry.modelcontextprotocol.io";
|
|
41
|
+
/** The variable a `github-token` target reads by default. */
|
|
42
|
+
export declare const MCP_GITHUB_TOKEN_ENV = "MCP_GITHUB_TOKEN";
|
|
43
|
+
/** The variable a `registry-token` target reads by default. */
|
|
44
|
+
export declare const MCP_REGISTRY_TOKEN_ENV = "MCP_REGISTRY_TOKEN";
|
|
45
|
+
export type McpRegistryAuth = NonNullable<McpRegistryPublishDeclaration["auth"]>;
|
|
46
|
+
/** The declaration's `auth`, refused when `tokenEnv` is set beside the OIDC exchange, which reads none. */
|
|
47
|
+
export declare function mcpRegistryAuth(decl: Pick<McpRegistryPublishDeclaration, "auth" | "tokenEnv">): McpRegistryAuth;
|
|
48
|
+
/** The variables the target's credential is read from, whose values are masked. */
|
|
49
|
+
export declare function mcpRegistryTokenEnv(decl: Pick<McpRegistryPublishDeclaration, "auth" | "tokenEnv">): string[];
|
|
50
|
+
/** The registry's origin, which is the audience of the OIDC token: scheme and lowercased host. */
|
|
51
|
+
export declare function mcpRegistryAudience(registry: string): string;
|
|
52
|
+
export interface ServerJson {
|
|
53
|
+
name: string;
|
|
54
|
+
version: string;
|
|
55
|
+
packages: Array<{
|
|
56
|
+
registryType?: string;
|
|
57
|
+
identifier?: string;
|
|
58
|
+
version?: string;
|
|
59
|
+
}>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Read `text` as a `server.json` and check it is the release's: `label` is
|
|
63
|
+
* the release's label. Throws {@link PublishTargetError}.
|
|
64
|
+
*/
|
|
65
|
+
export declare function checkServerJson(text: string, path: string, label: string | null): ServerJson;
|
|
66
|
+
export declare function mcpRegistryTarget(decl: McpRegistryPublishDeclaration, deps: PublishDeps): PublishTarget;
|