@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.
Files changed (270) hide show
  1. package/dist/action-pins.d.ts +2 -0
  2. package/dist/action-pins.js +3 -0
  3. package/dist/ci-detect.d.ts +13 -0
  4. package/dist/ci-detect.js +12 -0
  5. package/dist/ci-evidence-claims.d.ts +12 -0
  6. package/dist/ci-evidence-claims.js +12 -0
  7. package/dist/ci-system.d.ts +66 -0
  8. package/dist/ci-system.js +61 -0
  9. package/dist/cli/handlers/build.js +27 -0
  10. package/dist/cli/handlers/release-doctor.d.ts +12 -0
  11. package/dist/cli/handlers/release-doctor.js +118 -0
  12. package/dist/cli/handlers/release-init.d.ts +10 -0
  13. package/dist/cli/handlers/release-init.js +374 -0
  14. package/dist/cli/handlers/release.d.ts +43 -2
  15. package/dist/cli/handlers/release.js +667 -39
  16. package/dist/cli/handlers/run-generate.js +11 -0
  17. package/dist/cli/main.d.ts +2 -0
  18. package/dist/cli/main.js +44 -101
  19. package/dist/cli/parse-args.js +48 -0
  20. package/dist/cli/registry.d.ts +16 -0
  21. package/dist/cli/release-commands/artifacts.d.ts +3 -0
  22. package/dist/cli/release-commands/artifacts.js +14 -0
  23. package/dist/cli/release-commands/candidates.d.ts +3 -0
  24. package/dist/cli/release-commands/candidates.js +16 -0
  25. package/dist/cli/release-commands/changed.d.ts +3 -0
  26. package/dist/cli/release-commands/changed.js +14 -0
  27. package/dist/cli/release-commands/compose.d.ts +3 -0
  28. package/dist/cli/release-commands/compose.js +16 -0
  29. package/dist/cli/release-commands/cut.d.ts +3 -0
  30. package/dist/cli/release-commands/cut.js +50 -0
  31. package/dist/cli/release-commands/doctor.d.ts +3 -0
  32. package/dist/cli/release-commands/doctor.js +14 -0
  33. package/dist/cli/release-commands/export.d.ts +3 -0
  34. package/dist/cli/release-commands/export.js +12 -0
  35. package/dist/cli/release-commands/images.d.ts +3 -0
  36. package/dist/cli/release-commands/images.js +13 -0
  37. package/dist/cli/release-commands/index.d.ts +8 -0
  38. package/dist/cli/release-commands/index.js +52 -0
  39. package/dist/cli/release-commands/init.d.ts +3 -0
  40. package/dist/cli/release-commands/init.js +19 -0
  41. package/dist/cli/release-commands/list.d.ts +3 -0
  42. package/dist/cli/release-commands/list.js +10 -0
  43. package/dist/cli/release-commands/next.d.ts +3 -0
  44. package/dist/cli/release-commands/next.js +13 -0
  45. package/dist/cli/release-commands/publish.d.ts +3 -0
  46. package/dist/cli/release-commands/publish.js +22 -0
  47. package/dist/cli/release-commands/stamp.d.ts +3 -0
  48. package/dist/cli/release-commands/stamp.js +15 -0
  49. package/dist/cli/release-commands/status.d.ts +3 -0
  50. package/dist/cli/release-commands/status.js +17 -0
  51. package/dist/cli/release-commands/tag.d.ts +3 -0
  52. package/dist/cli/release-commands/tag.js +12 -0
  53. package/dist/cli/release-commands/types.d.ts +20 -0
  54. package/dist/cli/release-commands/types.js +1 -0
  55. package/dist/cli/release-commands/verify.d.ts +3 -0
  56. package/dist/cli/release-commands/verify.js +15 -0
  57. package/dist/cli/release-commands/workflow.d.ts +3 -0
  58. package/dist/cli/release-commands/workflow.js +15 -0
  59. package/dist/cloud-lister/index.d.ts +4 -1
  60. package/dist/cloud-lister/index.js +2 -1
  61. package/dist/cloud-lister/kubernetes-components.d.ts +56 -0
  62. package/dist/cloud-lister/kubernetes-components.js +642 -0
  63. package/dist/cloud-lister/kubernetes.d.ts +18 -0
  64. package/dist/cloud-lister/kubernetes.js +26 -1
  65. package/dist/cloud-lister/mask.d.ts +5 -1
  66. package/dist/cloud-lister/mask.js +14 -5
  67. package/dist/components/cli-support.d.ts +1 -1
  68. package/dist/components/cli-support.js +1 -1
  69. package/dist/config-environments.d.ts +8 -1
  70. package/dist/config-environments.js +2 -0
  71. package/dist/config-import.d.ts +1 -1
  72. package/dist/config-import.js +6 -2
  73. package/dist/config-sandbox.d.ts +1 -1
  74. package/dist/config-sandbox.js +3 -3
  75. package/dist/config.d.ts +369 -10
  76. package/dist/config.js +127 -7
  77. package/dist/deep-observation.js +9 -3
  78. package/dist/floor-table.data.js +21 -1
  79. package/dist/forge-remote.d.ts +13 -0
  80. package/dist/forge-remote.js +15 -0
  81. package/dist/lexicon.d.ts +45 -4
  82. package/dist/lifecycle/__fixtures__/package-files.d.ts +32 -0
  83. package/dist/lifecycle/__fixtures__/package-files.js +72 -0
  84. package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +62 -0
  85. package/dist/lifecycle/__fixtures__/publish-fakes.js +275 -3
  86. package/dist/lifecycle/publish-attachments.d.ts +2 -1
  87. package/dist/lifecycle/publish-attachments.js +19 -2
  88. package/dist/lifecycle/publish-cargo.d.ts +99 -0
  89. package/dist/lifecycle/publish-cargo.js +412 -0
  90. package/dist/lifecycle/publish-credentials.d.ts +1 -1
  91. package/dist/lifecycle/publish-credentials.js +13 -0
  92. package/dist/lifecycle/publish-declaration.d.ts +322 -4
  93. package/dist/lifecycle/publish-declaration.js +340 -9
  94. package/dist/lifecycle/publish-forge.d.ts +45 -2
  95. package/dist/lifecycle/publish-forge.js +434 -34
  96. package/dist/lifecycle/publish-git-ssh.d.ts +15 -0
  97. package/dist/lifecycle/publish-git-ssh.js +30 -4
  98. package/dist/lifecycle/publish-github.d.ts +40 -2
  99. package/dist/lifecycle/publish-github.js +100 -3
  100. package/dist/lifecycle/publish-helm.d.ts +83 -0
  101. package/dist/lifecycle/publish-helm.js +452 -0
  102. package/dist/lifecycle/publish-homebrew.d.ts +7 -9
  103. package/dist/lifecycle/publish-homebrew.js +34 -197
  104. package/dist/lifecycle/publish-index.d.ts +141 -0
  105. package/dist/lifecycle/publish-index.js +719 -0
  106. package/dist/lifecycle/publish-marketplace.js +77 -0
  107. package/dist/lifecycle/publish-maven.d.ts +79 -0
  108. package/dist/lifecycle/publish-maven.js +364 -0
  109. package/dist/lifecycle/publish-mcp-registry.d.ts +66 -0
  110. package/dist/lifecycle/publish-mcp-registry.js +305 -0
  111. package/dist/lifecycle/publish-npm.d.ts +27 -1
  112. package/dist/lifecycle/publish-npm.js +216 -3
  113. package/dist/lifecycle/publish-nuget.d.ts +93 -0
  114. package/dist/lifecycle/publish-nuget.js +377 -0
  115. package/dist/lifecycle/publish-oci.d.ts +91 -2
  116. package/dist/lifecycle/publish-oci.js +247 -8
  117. package/dist/lifecycle/publish-package-files.d.ts +16 -0
  118. package/dist/lifecycle/publish-package-files.js +39 -0
  119. package/dist/lifecycle/publish-pypi.d.ts +138 -0
  120. package/dist/lifecycle/publish-pypi.js +657 -0
  121. package/dist/lifecycle/publish-record.d.ts +6 -3
  122. package/dist/lifecycle/publish-record.js +6 -3
  123. package/dist/lifecycle/publish-rubygems.d.ts +84 -0
  124. package/dist/lifecycle/publish-rubygems.js +366 -0
  125. package/dist/lifecycle/publish-signing.d.ts +147 -0
  126. package/dist/lifecycle/publish-signing.js +257 -0
  127. package/dist/lifecycle/publish-targets.d.ts +37 -1
  128. package/dist/lifecycle/publish-targets.js +102 -0
  129. package/dist/lifecycle/publish-tauri.js +43 -0
  130. package/dist/lifecycle/publish-train-names.d.ts +57 -0
  131. package/dist/lifecycle/publish-train-names.js +123 -0
  132. package/dist/lifecycle/publish-verify.d.ts +121 -0
  133. package/dist/lifecycle/publish-verify.js +130 -0
  134. package/dist/lifecycle/query.js +8 -0
  135. package/dist/lifecycle/release-artifacts.d.ts +290 -0
  136. package/dist/lifecycle/release-artifacts.js +808 -0
  137. package/dist/lifecycle/release-changelog.d.ts +13 -1
  138. package/dist/lifecycle/release-changelog.js +35 -2
  139. package/dist/lifecycle/release-cut.d.ts +64 -4
  140. package/dist/lifecycle/release-cut.js +147 -34
  141. package/dist/lifecycle/release-doctor.d.ts +113 -0
  142. package/dist/lifecycle/release-doctor.js +1198 -0
  143. package/dist/lifecycle/release-green.d.ts +86 -0
  144. package/dist/lifecycle/release-green.js +286 -0
  145. package/dist/lifecycle/release-init-registries.d.ts +48 -0
  146. package/dist/lifecycle/release-init-registries.js +97 -0
  147. package/dist/lifecycle/release-init.d.ts +275 -0
  148. package/dist/lifecycle/release-init.js +984 -0
  149. package/dist/lifecycle/release-intents.d.ts +73 -0
  150. package/dist/lifecycle/release-intents.js +128 -0
  151. package/dist/lifecycle/release-next.d.ts +111 -0
  152. package/dist/lifecycle/release-next.js +251 -0
  153. package/dist/lifecycle/release-prerelease.d.ts +19 -0
  154. package/dist/lifecycle/release-prerelease.js +30 -0
  155. package/dist/lifecycle/release-publish.d.ts +256 -10
  156. package/dist/lifecycle/release-publish.js +247 -35
  157. package/dist/lifecycle/release-status-change.d.ts +226 -0
  158. package/dist/lifecycle/release-status-change.js +478 -0
  159. package/dist/lifecycle/release-status.d.ts +11 -0
  160. package/dist/lifecycle/release-status.js +1 -1
  161. package/dist/lifecycle/release-store.d.ts +73 -2
  162. package/dist/lifecycle/release-store.js +32 -1
  163. package/dist/lifecycle/release-tag.d.ts +142 -0
  164. package/dist/lifecycle/release-tag.js +322 -0
  165. package/dist/lifecycle/release-verify.d.ts +73 -1
  166. package/dist/lifecycle/release-verify.js +117 -2
  167. package/dist/lifecycle/release-version-formats.d.ts +73 -0
  168. package/dist/lifecycle/release-version-formats.js +570 -0
  169. package/dist/lifecycle/release-version.d.ts +58 -10
  170. package/dist/lifecycle/release-version.js +164 -36
  171. package/dist/lifecycle/release-workstation.d.ts +3 -2
  172. package/dist/lifecycle/release-workstation.js +3 -2
  173. package/dist/op/generate-pipeline.js +1 -1
  174. package/dist/op/local-executor.d.ts +1 -1
  175. package/dist/op/local-executor.js +2 -2
  176. package/dist/op/op-waves-evidence.js +9 -2
  177. package/dist/pr-forge-base.js +4 -2
  178. package/dist/pr-forge.d.ts +20 -2
  179. package/dist/pr-forge.js +46 -10
  180. package/dist/release-floors.d.ts +8 -1
  181. package/dist/release-floors.js +9 -2
  182. package/dist/sensitive-key.d.ts +12 -0
  183. package/dist/sensitive-key.js +52 -0
  184. package/dist/tool-pins.d.ts +40 -0
  185. package/dist/tool-pins.js +66 -0
  186. package/dist/ts-loader.d.ts +8 -0
  187. package/dist/ts-loader.js +19 -0
  188. package/dist/wave-runtime.mjs +345 -342
  189. package/dist/workspace/ci-forge.d.ts +17 -0
  190. package/dist/workspace/ci-forge.js +17 -0
  191. package/dist/workspace/ci-init.js +1 -1
  192. package/dist/workspace/composites.schema.json +1 -0
  193. package/dist/workspace/declaration.d.ts +8 -0
  194. package/dist/workspace/declaration.js +12 -0
  195. package/dist/workspace/declaration.schema.json +8 -0
  196. package/dist/workspace/environments.d.ts +2 -0
  197. package/dist/workspace/environments.js +1 -1
  198. package/dist/workspace/identity-gate-rule.d.ts +61 -5
  199. package/dist/workspace/identity-gate-rule.js +81 -12
  200. package/dist/workspace/lexicon-outputs.d.ts +1 -1
  201. package/dist/workspace/lexicon-outputs.js +1 -1
  202. package/dist/workspace/member-pipeline.d.ts +2 -1
  203. package/dist/workspace/member-pipeline.js +5 -2
  204. package/dist/workspace/reason-codes.d.ts +2 -0
  205. package/dist/workspace/reason-codes.js +3 -1
  206. package/dist/workspace/release-changed.d.ts +75 -4
  207. package/dist/workspace/release-changed.js +205 -34
  208. package/dist/workspace/release-changed.schema.json +20 -2
  209. package/dist/workspace/release-steps/artifacts.d.ts +7 -0
  210. package/dist/workspace/release-steps/artifacts.js +45 -0
  211. package/dist/workspace/release-steps/builds.d.ts +12 -0
  212. package/dist/workspace/release-steps/builds.js +38 -0
  213. package/dist/workspace/release-steps/doctor.d.ts +8 -0
  214. package/dist/workspace/release-steps/doctor.js +14 -0
  215. package/dist/workspace/release-steps/goreleaser.d.ts +16 -0
  216. package/dist/workspace/release-steps/goreleaser.js +36 -0
  217. package/dist/workspace/release-steps/green.d.ts +3 -0
  218. package/dist/workspace/release-steps/green.js +6 -0
  219. package/dist/workspace/release-steps/images.d.ts +22 -0
  220. package/dist/workspace/release-steps/images.js +59 -0
  221. package/dist/workspace/release-steps/index.d.ts +9 -0
  222. package/dist/workspace/release-steps/index.js +50 -0
  223. package/dist/workspace/release-steps/nfpm.d.ts +13 -0
  224. package/dist/workspace/release-steps/nfpm.js +29 -0
  225. package/dist/workspace/release-steps/nuget.d.ts +14 -0
  226. package/dist/workspace/release-steps/nuget.js +16 -0
  227. package/dist/workspace/release-steps/pypi.d.ts +15 -0
  228. package/dist/workspace/release-steps/pypi.js +21 -0
  229. package/dist/workspace/release-steps/qemu.d.ts +21 -0
  230. package/dist/workspace/release-steps/qemu.js +35 -0
  231. package/dist/workspace/release-steps/signing.d.ts +18 -0
  232. package/dist/workspace/release-steps/signing.js +30 -0
  233. package/dist/workspace/release-steps/stamp.d.ts +3 -0
  234. package/dist/workspace/release-steps/stamp.js +4 -0
  235. package/dist/workspace/release-steps/targets.d.ts +31 -0
  236. package/dist/workspace/release-steps/targets.js +40 -0
  237. package/dist/workspace/release-steps/types.d.ts +104 -0
  238. package/dist/workspace/release-steps/types.js +2 -0
  239. package/dist/workspace/release-steps/verify.d.ts +3 -0
  240. package/dist/workspace/release-steps/verify.js +4 -0
  241. package/dist/workspace/release-toolchains.d.ts +59 -0
  242. package/dist/workspace/release-toolchains.js +133 -0
  243. package/dist/workspace/release-train-workflow.d.ts +36 -0
  244. package/dist/workspace/release-train-workflow.js +121 -0
  245. package/dist/workspace/release-train.d.ts +3 -1
  246. package/dist/workspace/release-train.js +20 -3
  247. package/dist/workspace/release-workflow.d.ts +183 -59
  248. package/dist/workspace/release-workflow.js +570 -201
  249. package/dist/workspace/releases.schema.json +70 -1
  250. package/dist/workspace/search-contract.d.ts +1 -1
  251. package/dist/workspace/security.js +9 -2
  252. package/dist/workspace/train-cut.d.ts +182 -0
  253. package/dist/workspace/train-cut.js +504 -0
  254. package/dist/workspace/train-prepare.d.ts +64 -0
  255. package/dist/workspace/train-prepare.js +313 -0
  256. package/dist/workspace/train-publish.d.ts +177 -0
  257. package/dist/workspace/train-publish.js +574 -0
  258. package/dist/workspace/train-range-labels.d.ts +33 -0
  259. package/dist/workspace/train-range-labels.js +109 -0
  260. package/dist/workspace/train-shell.d.ts +5 -0
  261. package/dist/workspace/train-shell.js +17 -0
  262. package/dist/workspace/trust/check-evidence-report.d.ts +3 -7
  263. package/dist/workspace/trust/check-evidence-report.js +3 -7
  264. package/dist/workspace/trust/seal.d.ts +13 -3
  265. package/dist/workspace/trust/seal.js +14 -4
  266. package/dist/workspace/work-cli.d.ts +3 -2
  267. package/dist/workspace/work-cli.js +3 -2
  268. package/dist/workspace/workspace-ledger.d.ts +14 -1
  269. package/dist/workspace/workspace-ledger.js +33 -7
  270. package/package.json +1 -1
@@ -0,0 +1,257 @@
1
+ /**
2
+ * Sigstore signing at publish (#5164): keyless signatures and OIDC-signed
3
+ * SLSA provenance for what the OCI and forge targets publish, beside the
4
+ * release's own provenance statement and the cut's ssh signature, which stay
5
+ * as they are (./publish-attachments.ts).
6
+ *
7
+ * In a CI job with an OIDC token, a target's stage signs before anything is
8
+ * revealed:
9
+ *
10
+ * - an image gets a cosign signature, a Sigstore bundle over an in-toto
11
+ * statement whose predicate type is `https://sigstore.dev/cosign/sign/v1`,
12
+ * and SLSA provenance (`https://slsa.dev/provenance/v1`), each pushed as
13
+ * an OCI referrer of the image with the artifact type
14
+ * `application/vnd.dev.sigstore.bundle.v0.3+json`, the layout `cosign sign`
15
+ * and `actions/attest-build-provenance` push. `cosign verify` and `cosign
16
+ * verify-attestation --type slsaprovenance1` check them.
17
+ * - a forge release gets `<file>.sigstore.json` beside each file it holds (a
18
+ * `cosign sign-blob` bundle, checked with `cosign verify-blob`) and
19
+ * {@link SLSA_BUNDLE_FILE}, SLSA provenance over the declared assets.
20
+ *
21
+ * chant writes the statements and runs `cosign` (version 3, the binary
22
+ * `CHANT_COSIGN` names, else `cosign` on `PATH`) to sign them with the job's
23
+ * token: `cosign sign-blob` for a file and `cosign attest-blob --statement`
24
+ * for a statement. It pushes and uploads the bundles itself, with the
25
+ * target's own credentials. The generated release workflow downloads cosign
26
+ * pinned by SHA-256 (../tool-pins.ts).
27
+ *
28
+ * Signing is off unless `release.signing` in `chant.config.ts` turns it on
29
+ * or the workspace opts into the `supply-chain` group, where `signing: false`
30
+ * turns it off with a warning. When it is on and the run can't sign (no OIDC
31
+ * token cosign takes, or no cosign), the publish is refused before anything
32
+ * is sent.
33
+ */
34
+ import { execFile, execFileSync } from "node:child_process";
35
+ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
36
+ import { tmpdir } from "node:os";
37
+ import { join } from "node:path";
38
+ import { promisify } from "node:util";
39
+ import { IN_TOTO_STATEMENT_TYPE } from "./publish-attachments.js";
40
+ import { PublishTargetError } from "./release-publish.js";
41
+ /** The media type of a Sigstore bundle, and the artifact type of a referrer that holds one. */
42
+ export const SIGSTORE_BUNDLE_MEDIA_TYPE = "application/vnd.dev.sigstore.bundle.v0.3+json";
43
+ /** The predicate type of cosign's image signature statement. */
44
+ export const COSIGN_SIGN_PREDICATE = "https://sigstore.dev/cosign/sign/v1";
45
+ /** The predicate type of SLSA provenance v1. */
46
+ export const SLSA_PROVENANCE_PREDICATE = "https://slsa.dev/provenance/v1";
47
+ /** What a file's signature bundle is named after: `<file>.sigstore.json`. */
48
+ export const SIGSTORE_BUNDLE_SUFFIX = ".sigstore.json";
49
+ /** The forge asset that holds SLSA provenance over the release's assets. */
50
+ export const SLSA_BUNDLE_FILE = "release.slsa.sigstore.json";
51
+ /** The OCI annotation a bundle referrer names its predicate type under. */
52
+ export const BUNDLE_PREDICATE_ANNOTATION = "dev.sigstore.bundle.predicateType";
53
+ /** The buildType of SLSA provenance written in GitHub Actions, the one `actions/attest-build-provenance` writes. */
54
+ export const GITHUB_BUILD_TYPE = "https://actions.github.io/buildtypes/workflow/v1";
55
+ /** The buildType of SLSA provenance written in GitLab CI. */
56
+ export const GITLAB_BUILD_TYPE = "https://intentius.io/chant/release/build/gitlab-ci/v1";
57
+ /** The cosign major version chant runs: 3 writes Sigstore bundles by default. */
58
+ export const COSIGN_MAJOR = 3;
59
+ /** Whether a publish signs: `release.signing` first, then the `supply-chain` group. */
60
+ export function resolveSigning(config, groups) {
61
+ const named = typeof config === "object" ? { ...(config.identity ? { identity: config.identity } : {}), ...(config.issuer ? { issuer: config.issuer } : {}) } : {};
62
+ if (config === false) {
63
+ return {
64
+ on: false,
65
+ from: "off",
66
+ warning: groups.has("supply-chain") ? "the workspace opts into supply-chain, and release.signing: false publishes images and forge assets without Sigstore signatures or SLSA provenance" : null,
67
+ };
68
+ }
69
+ if (config !== undefined)
70
+ return { on: true, from: "config", warning: null, ...named };
71
+ return groups.has("supply-chain") ? { on: true, from: "supply-chain", warning: null } : { on: false, from: "off", warning: null };
72
+ }
73
+ const escape = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
74
+ /**
75
+ * Whether this run can sign keylessly, and the identity its certificate will
76
+ * name: in GitHub Actions, a job with `id-token: write`, whose certificate
77
+ * names a workflow of the repository; in GitLab CI, an ID token named
78
+ * `SIGSTORE_ID_TOKEN` with the audience `sigstore`, whose certificate names
79
+ * the project's pipeline. Anywhere else there is none.
80
+ */
81
+ export function signingIdentity(env) {
82
+ if (env.GITHUB_ACTIONS === "true") {
83
+ if (!env.ACTIONS_ID_TOKEN_REQUEST_URL || !env.ACTIONS_ID_TOKEN_REQUEST_TOKEN)
84
+ return { reason: "this GitHub Actions job has no OIDC token; give the job permissions: id-token: write" };
85
+ const server = (env.GITHUB_SERVER_URL ?? "https://github.com").replace(/\/+$/, "");
86
+ const repo = env.GITHUB_REPOSITORY;
87
+ if (!repo)
88
+ return { reason: "this GitHub Actions job has no GITHUB_REPOSITORY" };
89
+ return { identity: { issuer: "https://token.actions.githubusercontent.com", identity: `^${escape(server)}/${escape(repo)}/` } };
90
+ }
91
+ if (env.GITLAB_CI === "true") {
92
+ if (!env.SIGSTORE_ID_TOKEN)
93
+ return { reason: "this GitLab CI job has no SIGSTORE_ID_TOKEN; declare it under the job's id_tokens with aud: sigstore" };
94
+ const server = (env.CI_SERVER_URL ?? "https://gitlab.com").replace(/\/+$/, "");
95
+ const project = env.CI_PROJECT_PATH;
96
+ if (!project)
97
+ return { reason: "this GitLab CI job has no CI_PROJECT_PATH" };
98
+ return { identity: { issuer: server, identity: `^${escape(server)}/${escape(project)}//` } };
99
+ }
100
+ return { reason: "this run is not in GitHub Actions or GitLab CI, and keyless signing needs a CI job's OIDC token" };
101
+ }
102
+ const subjectOf = (s) => {
103
+ const [alg, hex] = s.digest.includes(":") ? s.digest.split(":") : ["sha256", s.digest];
104
+ return { name: s.name, digest: { [alg]: hex } };
105
+ };
106
+ /** The statement cosign signs for an image: its digest under `https://sigstore.dev/cosign/sign/v1`, with an empty predicate. */
107
+ export function cosignSignStatement(subject) {
108
+ return { _type: IN_TOTO_STATEMENT_TYPE, subject: [subjectOf(subject)], predicateType: COSIGN_SIGN_PREDICATE, predicate: {} };
109
+ }
110
+ /**
111
+ * SLSA provenance v1 over `subjects`, from the CI job's environment. In
112
+ * GitHub Actions it is the predicate `actions/attest-build-provenance`
113
+ * writes: the workflow, the event, the repository's ids, the commit and the
114
+ * run. In GitLab CI it names the project, its CI config, the pipeline source
115
+ * and the job. Either adds `internalParameters.chant`, the release's digest,
116
+ * label and member, and the source it resolves is the release's commit.
117
+ */
118
+ export function slsaProvenanceStatement(ctx, subjects) {
119
+ const env = ctx.env;
120
+ const chant = { releaseDigest: ctx.release.releaseDigest, label: ctx.label, member: ctx.release.member };
121
+ let predicate;
122
+ if (env.GITLAB_CI === "true") {
123
+ const server = (env.CI_SERVER_URL ?? "https://gitlab.com").replace(/\/+$/, "");
124
+ const project = `${server}/${env.CI_PROJECT_PATH ?? ""}`;
125
+ const ref = env.CI_COMMIT_TAG ? `refs/tags/${env.CI_COMMIT_TAG}` : `refs/heads/${env.CI_COMMIT_REF_NAME ?? ""}`;
126
+ predicate = {
127
+ buildDefinition: {
128
+ buildType: GITLAB_BUILD_TYPE,
129
+ externalParameters: { project, ref, configPath: env.CI_CONFIG_PATH ?? ".gitlab-ci.yml" },
130
+ internalParameters: { gitlab: { pipelineSource: env.CI_PIPELINE_SOURCE ?? null, projectId: env.CI_PROJECT_ID ?? null, runnerEnvironment: env.CI_RUNNER_EXECUTABLE_ARCH ?? null }, chant },
131
+ resolvedDependencies: [{ uri: `git+${project}@${ref}`, digest: { gitCommit: ctx.release.commit } }],
132
+ },
133
+ runDetails: {
134
+ builder: { id: `${project}//${env.CI_CONFIG_PATH ?? ".gitlab-ci.yml"}@${ref}` },
135
+ metadata: { invocationId: env.CI_JOB_URL ?? `${project}/-/jobs/${env.CI_JOB_ID ?? ""}` },
136
+ },
137
+ };
138
+ }
139
+ else {
140
+ const server = (env.GITHUB_SERVER_URL ?? "https://github.com").replace(/\/+$/, "");
141
+ const repo = env.GITHUB_REPOSITORY ?? "";
142
+ const workflowRef = env.GITHUB_WORKFLOW_REF ?? "";
143
+ const path = workflowRef.startsWith(`${repo}/`) ? workflowRef.slice(repo.length + 1).split("@")[0] : workflowRef.split("@")[0];
144
+ const ref = env.GITHUB_REF ?? "";
145
+ predicate = {
146
+ buildDefinition: {
147
+ buildType: GITHUB_BUILD_TYPE,
148
+ externalParameters: { workflow: { ref, repository: `${server}/${repo}`, path } },
149
+ internalParameters: {
150
+ github: { event_name: env.GITHUB_EVENT_NAME ?? null, repository_id: env.GITHUB_REPOSITORY_ID ?? null, repository_owner_id: env.GITHUB_REPOSITORY_OWNER_ID ?? null, runner_environment: env.RUNNER_ENVIRONMENT ?? null },
151
+ chant,
152
+ },
153
+ resolvedDependencies: [{ uri: `git+${server}/${repo}@${ref}`, digest: { gitCommit: ctx.release.commit } }],
154
+ },
155
+ runDetails: {
156
+ builder: { id: `${server}/${workflowRef}` },
157
+ metadata: { invocationId: `${server}/${repo}/actions/runs/${env.GITHUB_RUN_ID ?? ""}/attempts/${env.GITHUB_RUN_ATTEMPT ?? "1"}` },
158
+ },
159
+ };
160
+ }
161
+ return { _type: IN_TOTO_STATEMENT_TYPE, subject: subjects.map(subjectOf), predicateType: SLSA_PROVENANCE_PREDICATE, predicate };
162
+ }
163
+ /** The cosign a run uses: `CHANT_COSIGN`, else `cosign` on `PATH`. */
164
+ export function cosignPath(env) {
165
+ return env.CHANT_COSIGN && env.CHANT_COSIGN !== "" ? env.CHANT_COSIGN : "cosign";
166
+ }
167
+ /** Null when `cosign` runs and is version {@link COSIGN_MAJOR} or later, else why not. */
168
+ function cosignUnavailable(cosign, env) {
169
+ let out;
170
+ try {
171
+ out = execFileSync(cosign, ["version"], { encoding: "utf-8", env, stdio: ["ignore", "pipe", "pipe"] });
172
+ }
173
+ catch (err) {
174
+ const e = err;
175
+ if (e.code === "ENOENT")
176
+ return { version: null, reason: `${cosign} is not there: install cosign ${COSIGN_MAJOR} on PATH, or set CHANT_COSIGN to it` };
177
+ out = String(e.stdout ?? "");
178
+ if (!out)
179
+ return { version: null, reason: `${cosign} version failed: ${e.message}` };
180
+ }
181
+ const v = /GitVersion:\s*v?(\d+)\.(\d+)\.(\d+)/.exec(out);
182
+ if (!v)
183
+ return { version: null, reason: `${cosign} version printed no GitVersion, so chant can't tell it is cosign ${COSIGN_MAJOR}` };
184
+ const version = `v${v[1]}.${v[2]}.${v[3]}`;
185
+ return Number(v[1]) < COSIGN_MAJOR ? { version, reason: `${cosign} is cosign ${version}, and chant signs with cosign ${COSIGN_MAJOR} or later` } : { version, reason: null };
186
+ }
187
+ const run = promisify(execFile);
188
+ /** Run cosign with `args`; a failure is a {@link PublishTargetError} with `code` and the end of its stderr, redacted. */
189
+ async function cosignRun(cosign, args, env, redactor, code, what) {
190
+ try {
191
+ await run(cosign, args, { env, maxBuffer: 16 * 1024 * 1024 });
192
+ return { ok: true };
193
+ }
194
+ catch (err) {
195
+ const e = err;
196
+ const tail = String(e.stderr ?? e.message).trim().split("\n").filter(Boolean).slice(-3).join("; ");
197
+ const reason = redactor ? redactor.redact(tail) : tail;
198
+ if (code)
199
+ throw new PublishTargetError(code, `${what} failed: ${reason}`, "Check that the job's OIDC token reaches cosign and that Fulcio and Rekor are reachable, then run the publish again.");
200
+ return { ok: false, reason };
201
+ }
202
+ }
203
+ function withTemp(fn) {
204
+ const dir = mkdtempSync(join(tmpdir(), "chant-sign-"));
205
+ return fn(dir).finally(() => rmSync(dir, { recursive: true, force: true }));
206
+ }
207
+ /** A {@link Signer} that runs cosign keylessly, with `env`, which carries the job's OIDC token. */
208
+ export function cosignSigner(env, redactor, cosign = cosignPath(env)) {
209
+ let checked = null;
210
+ const check = () => (checked ?? (checked = cosignUnavailable(cosign, env)));
211
+ return {
212
+ get name() {
213
+ return `cosign${check().version ? ` ${check().version}` : ""}`;
214
+ },
215
+ unavailable: () => check().reason,
216
+ signBlob: (bytes, name) => withTemp(async (dir) => {
217
+ const file = join(dir, "blob");
218
+ writeFileSync(file, bytes);
219
+ await cosignRun(cosign, ["sign-blob", "--yes", "--new-bundle-format=true", "--bundle", join(dir, "out.json"), file], env, redactor, "publish-signing-failed", `cosign sign-blob for ${name}`);
220
+ return new Uint8Array(readFileSync(join(dir, "out.json")));
221
+ }),
222
+ signStatement: (statement) => withTemp(async (dir) => {
223
+ const file = join(dir, "statement.json");
224
+ writeFileSync(file, JSON.stringify(statement));
225
+ await cosignRun(cosign, ["attest-blob", "--yes", "--new-bundle-format=true", "--statement", file, "--bundle", join(dir, "out.json")], env, redactor, "publish-signing-failed", `cosign attest-blob for ${statement.predicateType}`);
226
+ return new Uint8Array(readFileSync(join(dir, "out.json")));
227
+ }),
228
+ };
229
+ }
230
+ /** The `--type` cosign takes for a predicate type: its short name for SLSA provenance v1, else the URI. */
231
+ const cosignType = (predicateType) => (predicateType === SLSA_PROVENANCE_PREDICATE ? "slsaprovenance1" : predicateType);
232
+ const idFlags = (id) => ["--certificate-identity-regexp", id.identity, "--certificate-oidc-issuer", id.issuer];
233
+ const hexOf = (digest) => (digest.includes(":") ? digest.split(":")[1] : digest);
234
+ /** A {@link SigstoreVerifier} that runs cosign. Image checks read the registry with docker's credentials. */
235
+ export function cosignVerifier(env, cosign = cosignPath(env)) {
236
+ let checked = null;
237
+ const check = () => (checked ?? (checked = cosignUnavailable(cosign, env)));
238
+ const go = async (args) => {
239
+ const r = await cosignRun(cosign, args, env, null, "", "");
240
+ return r.ok ? null : r.reason;
241
+ };
242
+ const blob = (bundle, args) => withTemp(async (dir) => {
243
+ const file = join(dir, "bundle.json");
244
+ writeFileSync(file, bundle);
245
+ return go(args(file));
246
+ });
247
+ return {
248
+ get name() {
249
+ return `cosign${check().version ? ` ${check().version}` : ""}`;
250
+ },
251
+ unavailable: () => check().reason,
252
+ verifyBlob: (bundle, digest, id) => blob(bundle, (f) => ["verify-blob", "--bundle", f, ...idFlags(id), `sha256:${hexOf(digest)}`]),
253
+ verifyBlobAttestation: (bundle, digest, predicateType, id) => blob(bundle, (f) => ["verify-blob-attestation", "--bundle", f, "--type", cosignType(predicateType), "--digest", hexOf(digest), "--digestAlg", "sha256", ...idFlags(id)]),
254
+ verifyImage: (ref, id) => go(["verify", ...idFlags(id), ref]),
255
+ verifyImageAttestation: (ref, predicateType, id) => go(["verify-attestation", "--type", cosignType(predicateType), ...idFlags(id), ref]),
256
+ };
257
+ }
@@ -15,14 +15,35 @@
15
15
  * Marketplace (through `vsce`) or Open VSX (through its REST API).
16
16
  * - `tauri-updater` (./publish-tauri.ts): a Tauri updater manifest and the
17
17
  * app's bundles on a rolling GitHub release, replaced on each publish.
18
+ * - `pypi` (./publish-pypi.ts): wheels and sdists uploaded to PyPI, TestPyPI
19
+ * or another index, with a token or PyPI's trusted publishing (#5167).
20
+ * - `cargo` (./publish-cargo.ts): `cargo publish` per crate of a workspace,
21
+ * in dependency order, to crates.io or another registry (#5167).
22
+ * - `mcp-registry` (./publish-mcp-registry.ts): a `server.json` on the
23
+ * official MCP Registry, revealed after every other target.
24
+ * - `index` (./publish-index.ts): manifests in an index repository such as
25
+ * krew-index or winget-pkgs, committed or proposed in a pull request,
26
+ * revealed after every other target. `homebrew` is its tap preset.
27
+ * - `helm` (./publish-helm.ts): Helm chart archives pushed to an OCI
28
+ * registry, and listed in a chart repository's `index.yaml` on a branch of
29
+ * a GitHub repository (#5233).
30
+ * - `maven` (./publish-maven.ts): a bundle uploaded to the Central Portal
31
+ * and validated at the stage, published to Maven Central at the reveal
32
+ * (#5232).
33
+ * - `nuget` (./publish-nuget.ts): `.nupkg` files pushed to nuget.org or
34
+ * another feed, with an API key or nuget.org's trusted publishing (#5232).
35
+ * - `rubygems` (./publish-rubygems.ts): `.gem` files pushed to RubyGems.org
36
+ * or another host, with an API key or trusted publishing (#5232).
18
37
  *
19
38
  * A file a target reads that the release records as an artifact at the same
20
39
  * path is checked against the release's digest, and a file that differs is
21
40
  * refused (`publish-artifact-digest-mismatch`). Other files are the commit's
22
41
  * by the checkout check (`checkCheckoutIsRelease` in ./release-publish.ts).
42
+ * A forge, homebrew or index target's `assets` may name `artifact:<name>`, every
43
+ * file the release records for that `release.artifacts` entry (#5151).
23
44
  */
24
45
  import type { PublishDeclaration } from "./publish-declaration.js";
25
- import { type PublishDeps, type PublishTarget } from "./release-publish.js";
46
+ import { type PublishContextBase, type PublishDeps, type PublishFetch, type PublishTarget } from "./release-publish.js";
26
47
  import type { Release, ReleaseArtifact } from "./release-store.js";
27
48
  /** Make each declaration a target, in the order declared. */
28
49
  export declare function createPublishTargets(decls: readonly PublishDeclaration[], deps?: PublishDeps): Promise<PublishTarget[]>;
@@ -48,3 +69,18 @@ export declare function releaseArtifactAt(release: Release, kind: ReleaseArtifac
48
69
  * and for an image its manifest and config digests).
49
70
  */
50
71
  export declare function checkReleaseDigest(release: Release, kind: ReleaseArtifact["kind"], cwd: string, path: string, digests: readonly string[]): void;
72
+ /**
73
+ * A target's `assets` with each `artifact:<name>` (#5151) made the paths the
74
+ * release records for that `release.artifacts` entry, in path order. A name
75
+ * the release records no file for is refused.
76
+ */
77
+ export declare function expandArtifactAssets(release: Release, assets: readonly string[]): string[];
78
+ /** True when the run can get an OIDC ID token: a GitHub Actions job with `id-token: write`, or one in `variable`. */
79
+ export declare function hasIdToken(env: NodeJS.ProcessEnv, variable: string): boolean;
80
+ /**
81
+ * The run's OIDC ID token for `audience` (#5167): the value of `variable`
82
+ * when it is set, as a GitLab job's `id_tokens` entry gives it, else one
83
+ * GitHub Actions issues. Masked by the context's redactor. Throws `code`
84
+ * when there is none.
85
+ */
86
+ export declare function runIdToken(ctx: PublishContextBase, fetchImpl: PublishFetch, audience: string, variable: string, code: string): Promise<string>;
@@ -15,11 +15,32 @@
15
15
  * Marketplace (through `vsce`) or Open VSX (through its REST API).
16
16
  * - `tauri-updater` (./publish-tauri.ts): a Tauri updater manifest and the
17
17
  * app's bundles on a rolling GitHub release, replaced on each publish.
18
+ * - `pypi` (./publish-pypi.ts): wheels and sdists uploaded to PyPI, TestPyPI
19
+ * or another index, with a token or PyPI's trusted publishing (#5167).
20
+ * - `cargo` (./publish-cargo.ts): `cargo publish` per crate of a workspace,
21
+ * in dependency order, to crates.io or another registry (#5167).
22
+ * - `mcp-registry` (./publish-mcp-registry.ts): a `server.json` on the
23
+ * official MCP Registry, revealed after every other target.
24
+ * - `index` (./publish-index.ts): manifests in an index repository such as
25
+ * krew-index or winget-pkgs, committed or proposed in a pull request,
26
+ * revealed after every other target. `homebrew` is its tap preset.
27
+ * - `helm` (./publish-helm.ts): Helm chart archives pushed to an OCI
28
+ * registry, and listed in a chart repository's `index.yaml` on a branch of
29
+ * a GitHub repository (#5233).
30
+ * - `maven` (./publish-maven.ts): a bundle uploaded to the Central Portal
31
+ * and validated at the stage, published to Maven Central at the reveal
32
+ * (#5232).
33
+ * - `nuget` (./publish-nuget.ts): `.nupkg` files pushed to nuget.org or
34
+ * another feed, with an API key or nuget.org's trusted publishing (#5232).
35
+ * - `rubygems` (./publish-rubygems.ts): `.gem` files pushed to RubyGems.org
36
+ * or another host, with an API key or trusted publishing (#5232).
18
37
  *
19
38
  * A file a target reads that the release records as an artifact at the same
20
39
  * path is checked against the release's digest, and a file that differs is
21
40
  * refused (`publish-artifact-digest-mismatch`). Other files are the commit's
22
41
  * by the checkout check (`checkCheckoutIsRelease` in ./release-publish.ts).
42
+ * A forge, homebrew or index target's `assets` may name `artifact:<name>`, every
43
+ * file the release records for that `release.artifacts` entry (#5151).
23
44
  */
24
45
  import { createHash } from "node:crypto";
25
46
  import { existsSync, readFileSync, statSync } from "node:fs";
@@ -49,6 +70,30 @@ export async function createPublishTargets(decls, deps = {}) {
49
70
  case "tauri-updater":
50
71
  out.push((await import("./publish-tauri.js")).tauriUpdaterTarget(d, deps));
51
72
  break;
73
+ case "pypi":
74
+ out.push((await import("./publish-pypi.js")).pypiTarget(d, deps));
75
+ break;
76
+ case "cargo":
77
+ out.push((await import("./publish-cargo.js")).cargoTarget(d, deps));
78
+ break;
79
+ case "mcp-registry":
80
+ out.push((await import("./publish-mcp-registry.js")).mcpRegistryTarget(d, deps));
81
+ break;
82
+ case "index":
83
+ out.push((await import("./publish-index.js")).indexTarget(d, deps));
84
+ break;
85
+ case "helm":
86
+ out.push((await import("./publish-helm.js")).helmTarget(d, deps));
87
+ break;
88
+ case "maven":
89
+ out.push((await import("./publish-maven.js")).mavenTarget(d, deps));
90
+ break;
91
+ case "nuget":
92
+ out.push((await import("./publish-nuget.js")).nugetTarget(d, deps));
93
+ break;
94
+ case "rubygems":
95
+ out.push((await import("./publish-rubygems.js")).rubygemsTarget(d, deps));
96
+ break;
52
97
  }
53
98
  }
54
99
  return out;
@@ -98,3 +143,60 @@ export function checkReleaseDigest(release, kind, cwd, path, digests) {
98
143
  return;
99
144
  throw new PublishTargetError("publish-artifact-digest-mismatch", `${path} is not the ${kind} release ${release.releaseDigest} built: the release records ${recorded.digest}, and the file here is ${digests[0]}`, "Publish the files the cut built. A publish never builds, so restore them from the cut's build, or cut a new release.");
100
145
  }
146
+ /**
147
+ * A target's `assets` with each `artifact:<name>` (#5151) made the paths the
148
+ * release records for that `release.artifacts` entry, in path order. A name
149
+ * the release records no file for is refused.
150
+ */
151
+ export function expandArtifactAssets(release, assets) {
152
+ return assets.flatMap((a) => {
153
+ if (!a.startsWith("artifact:"))
154
+ return [a];
155
+ const name = a.slice("artifact:".length);
156
+ const paths = release.artifactDigests
157
+ .filter((f) => f.kind === "asset" && f.component === name)
158
+ .map((f) => f.path)
159
+ .sort();
160
+ if (paths.length === 0) {
161
+ throw new PublishTargetError("publish-artifact-not-recorded", `assets names ${a}, and release ${release.releaseDigest} records no file for an artifact "${name}"`, "Name an entry of release.artifacts the release was cut with, or cut a new release.");
162
+ }
163
+ return paths;
164
+ });
165
+ }
166
+ /** True when the run can get an OIDC ID token: a GitHub Actions job with `id-token: write`, or one in `variable`. */
167
+ export function hasIdToken(env, variable) {
168
+ return Boolean(env[variable] || (env.ACTIONS_ID_TOKEN_REQUEST_URL && env.ACTIONS_ID_TOKEN_REQUEST_TOKEN));
169
+ }
170
+ /**
171
+ * The run's OIDC ID token for `audience` (#5167): the value of `variable`
172
+ * when it is set, as a GitLab job's `id_tokens` entry gives it, else one
173
+ * GitHub Actions issues. Masked by the context's redactor. Throws `code`
174
+ * when there is none.
175
+ */
176
+ export async function runIdToken(ctx, fetchImpl, audience, variable, code) {
177
+ const direct = ctx.env[variable];
178
+ if (direct) {
179
+ ctx.redactor.add(direct);
180
+ return direct;
181
+ }
182
+ if (!(ctx.env.ACTIONS_ID_TOKEN_REQUEST_URL && ctx.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN)) {
183
+ throw new PublishTargetError(code, `this run has no OIDC ID token: not a GitHub Actions job with id-token: write, and ${variable} is not set`, `In GitHub Actions, give the job permissions: id-token: write. Elsewhere, put an ID token whose audience is ${audience} in ${variable}.`);
184
+ }
185
+ ctx.redactor.add(ctx.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN);
186
+ const url = new URL(ctx.env.ACTIONS_ID_TOKEN_REQUEST_URL);
187
+ url.searchParams.set("audience", audience);
188
+ const res = await fetchImpl(url.toString(), { method: "GET", headers: { authorization: `Bearer ${ctx.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN}`, accept: "application/json" } });
189
+ const text = await res.text().catch(() => "");
190
+ let value;
191
+ try {
192
+ value = res.status === 200 ? JSON.parse(text).value : undefined;
193
+ }
194
+ catch {
195
+ value = undefined;
196
+ }
197
+ if (typeof value !== "string" || !value) {
198
+ throw new PublishTargetError(code, `GitHub Actions gave no OIDC ID token for ${audience}: it answered ${res.status}`, "Give the job permissions: id-token: write.");
199
+ }
200
+ ctx.redactor.add(value);
201
+ return value;
202
+ }
@@ -50,6 +50,8 @@ import { GitHubRepo, githubApi } from "./publish-github.js";
50
50
  import { fillUrl, releaseVersion } from "./publish-homebrew.js";
51
51
  import { bytesDigest, checkReleaseDigest, memberFile, publishTargetKey } from "./publish-targets.js";
52
52
  import { PublishTargetError } from "./release-publish.js";
53
+ import { prereleaseOf } from "./release-prerelease.js";
54
+ import { trainName, waitUntilServed } from "./publish-train-names.js";
53
55
  /** The first chant that publishes a `tauri-updater` target (#4676). */
54
56
  export const PUBLISH_TAURI_UPDATER_FLOOR = "0.124.63";
55
57
  /** The updater manifest's bytes: 2-space JSON with a trailing newline, keys in the order Tauri's docs show them. */
@@ -106,6 +108,7 @@ export function tauriUpdaterTarget(decl, deps) {
106
108
  const repo = new GitHubRepo(githubApi(decl.api, ctx.env), decl.repo, token, fetchImpl, ctx, "publish-tauri-failed");
107
109
  return { version, token, files, repo, draftName: `${decl.tag} ${version}` };
108
110
  };
111
+ const skipNote = (ctx) => `skipped: ${ctx.label} is a prerelease, and the updater feed is what installed apps update from`;
109
112
  const where = (name) => `github ${decl.repo} release ${decl.tag}, asset ${name}`;
110
113
  const itemOf = (f, present = false) => ({ name: f.path, destination: where(f.name), digest: f.digest, ...(present ? { present: true } : {}) });
111
114
  const holdsAll = (rel, files) => rel.assets.size === files.length && files.every((f) => rel.assets.get(f.name) === f.digest);
@@ -115,10 +118,48 @@ export function tauriUpdaterTarget(decl, deps) {
115
118
  destination: `github ${decl.repo} release ${decl.tag}`,
116
119
  credentialEnv: tokenNames,
117
120
  key: publishTargetKey(decl),
121
+ /** #5165: the rolling release; it needs nothing a train orders by. */
122
+ async names() {
123
+ return { provides: [trainName("tauri-updater", `${decl.repo}@${decl.tag}`)], needs: [] };
124
+ },
125
+ /**
126
+ * #5165: whether the rolling release is this version's, by the name the
127
+ * stage gives its draft (`<tag> <version>`). A rolling release that holds
128
+ * another version can't say whether this one went out before it.
129
+ */
130
+ async published(ctx) {
131
+ if (prereleaseOf(ctx.label))
132
+ return true;
133
+ const version = releaseVersion(ctx.label);
134
+ const token = readCredential(ctx.env, tokenNames, ctx.redactor);
135
+ if (!version || !token)
136
+ return null;
137
+ const rel = await new GitHubRepo(githubApi(decl.api, ctx.env), decl.repo, token, fetchImpl, ctx, "publish-tauri-failed").publishedRelease(decl.tag);
138
+ return rel?.name === `${decl.tag} ${version}` ? true : null;
139
+ },
140
+ /** #5165: wait until the rolling release GitHub serves is this version's. */
141
+ async visible(ctx) {
142
+ const version = releaseVersion(ctx.label);
143
+ const token = readCredential(ctx.env, tokenNames, ctx.redactor);
144
+ if (prereleaseOf(ctx.label) || !version || !token)
145
+ return;
146
+ const repo = new GitHubRepo(githubApi(decl.api, ctx.env), decl.repo, token, fetchImpl, ctx, "publish-tauri-failed");
147
+ await waitUntilServed(ctx, deps, {
148
+ what: `github ${decl.repo}`,
149
+ code: "publish-tauri-not-served",
150
+ check: async () => ((await repo.publishedRelease(decl.tag))?.name === `${decl.tag} ${version}` ? [] : [`release ${decl.tag} ${version}`]),
151
+ });
152
+ },
118
153
  async plan(ctx) {
154
+ if (prereleaseOf(ctx.label))
155
+ return [{ name: decl.tag, destination: target.destination, notes: skipNote(ctx) }];
119
156
  return setup(ctx).files.map((f) => itemOf(f));
120
157
  },
121
158
  async stage(ctx) {
159
+ if (prereleaseOf(ctx.label)) {
160
+ ctx.log(skipNote(ctx));
161
+ return { target: target.name, destination: target.destination, items: [], state: { prerelease: "true" } };
162
+ }
122
163
  const { version, token, files, repo, draftName } = setup(ctx);
123
164
  ctx.log(`using the token from ${token.from}`);
124
165
  const done = (items, state) => ({ target: target.name, destination: target.destination, items, state });
@@ -151,6 +192,8 @@ export function tauriUpdaterTarget(decl, deps) {
151
192
  return done(items, { releaseId: draft.id });
152
193
  },
153
194
  async reveal(ctx, staged) {
195
+ if (staged.state.prerelease === "true")
196
+ return { target: target.name, destination: target.destination, items: [] };
154
197
  const items = staged.items.map((i) => ({ name: i.name, destination: i.destination, ...(i.digest ? { digest: i.digest } : {}) }));
155
198
  if (staged.state.published)
156
199
  return { target: target.name, destination: target.destination, items: items.map((i) => ({ ...i, present: true })) };
@@ -0,0 +1,57 @@
1
+ /**
2
+ * What a publish target tells a release train (#5165): the names it publishes
3
+ * and needs, qualified by kind so the train can order members across target
4
+ * kinds, and the wait before the next layer reveals.
5
+ *
6
+ * A name is `<kind>:<name>`, the name in the form its registry compares:
7
+ *
8
+ * | Kind | Name |
9
+ * |---|---|
10
+ * | `npm` | the package name, as written |
11
+ * | `oci` | the repository, lowercased, with no tag or digest, and Docker Hub's `docker.io/` (and `library/`) left off |
12
+ * | `pypi` | the project name normalized as PEP 503 does |
13
+ * | `cargo` | the crate name, lowercased, `_` as `-` |
14
+ * | `maven` | `<groupId>:<artifactId>` |
15
+ * | `nuget` | the package id, lowercased |
16
+ * | `rubygems` | the gem name |
17
+ * | `marketplace` | `<publisher>.<name>`, lowercased |
18
+ * | `mcp` | the server's name in `server.json` |
19
+ * | `forge`, `homebrew`, `index`, `tauri-updater` | where it publishes: the repository, and the formula or manifest name |
20
+ *
21
+ * So an MCP Registry entry that lists an npm package needs `npm:<package>`,
22
+ * and an image an mcp entry lists is `oci:<repository>` in both.
23
+ */
24
+ import { type PublishContextBase, type PublishDeps } from "./release-publish.js";
25
+ export type TrainNameKind = "npm" | "oci" | "pypi" | "cargo" | "marketplace" | "mcp" | "forge" | "homebrew" | "index" | "tauri-updater" | "maven" | "nuget" | "rubygems";
26
+ /** An image reference's repository, as a train compares it: lowercased, no tag or digest, no `docker.io/` or `library/`. */
27
+ export declare function ociRepositoryName(ref: string): string;
28
+ /** `<kind>:<name>`, the name in the form its registry compares. */
29
+ export declare function trainName(kind: TrainNameKind, name: string): string;
30
+ /** The project names a wheel or sdist's `Requires-Dist` lines need, leaving out those under an extra. */
31
+ export declare function pypiRequirements(metadata: ReadonlyArray<readonly [string, string]>): string[];
32
+ /**
33
+ * A label's version as a Python distribution's file name spells it (PEP
34
+ * 440, loosely): `1.4.0-rc.1` is `1.4.0rc1`, `2.0.0-beta.2` is `2.0.0b2`.
35
+ */
36
+ export declare function pep440Version(version: string): string;
37
+ /** The version in a wheel's or sdist's file name, or null when it names none chant can read. */
38
+ export declare function pypiFileVersion(file: string): {
39
+ name: string;
40
+ version: string;
41
+ } | null;
42
+ /** How often a train's wait asks a destination again. */
43
+ export declare const TRAIN_VISIBLE_POLL_MS = 10000;
44
+ /** How long a train waits for a destination to serve a reveal before it stops (#5165). */
45
+ export declare const TRAIN_VISIBLE_WAIT_MS: number;
46
+ /**
47
+ * Ask `check` until it says what the reveal published is served, every
48
+ * {@link TRAIN_VISIBLE_POLL_MS}, with a line about once a minute; stop with
49
+ * `code` after `capMs`. `check` returns the names still missing.
50
+ */
51
+ export declare function waitUntilServed(ctx: Pick<PublishContextBase, "log">, deps: Pick<PublishDeps, "sleep" | "now">, o: {
52
+ what: string;
53
+ code: string;
54
+ check: () => Promise<string[]>;
55
+ capMs?: number;
56
+ fix?: string;
57
+ }): Promise<void>;