@intentius/chant 0.124.99 → 0.124.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/bin/chant +3 -3
  2. package/dist/action-pins.d.ts +2 -0
  3. package/dist/action-pins.js +3 -0
  4. package/dist/ci-detect.d.ts +13 -0
  5. package/dist/ci-detect.js +12 -0
  6. package/dist/ci-system.d.ts +66 -0
  7. package/dist/ci-system.js +61 -0
  8. package/dist/cli/commands/carve-emit.js +2 -2
  9. package/dist/cli/commands/check-lexicon-plugin.d.ts +2 -2
  10. package/dist/cli/commands/check-lexicon-plugin.js +3 -3
  11. package/dist/cli/commands/check-lexicon.js +4 -4
  12. package/dist/cli/commands/init-lexicon/templates/project.d.ts +1 -1
  13. package/dist/cli/commands/init-lexicon/templates/project.js +4 -4
  14. package/dist/cli/commands/init.d.ts +13 -0
  15. package/dist/cli/commands/init.js +30 -2
  16. package/dist/cli/handlers/build.js +27 -0
  17. package/dist/cli/handlers/release-doctor.d.ts +12 -0
  18. package/dist/cli/handlers/release-doctor.js +118 -0
  19. package/dist/cli/handlers/release-init.d.ts +10 -0
  20. package/dist/cli/handlers/release-init.js +342 -0
  21. package/dist/cli/handlers/release.d.ts +50 -1
  22. package/dist/cli/handlers/release.js +688 -30
  23. package/dist/cli/handlers/run-generate.js +11 -0
  24. package/dist/cli/main.d.ts +2 -0
  25. package/dist/cli/main.js +45 -97
  26. package/dist/cli/parse-args.js +55 -0
  27. package/dist/cli/registry.d.ts +18 -0
  28. package/dist/cli/release-commands/artifacts.d.ts +3 -0
  29. package/dist/cli/release-commands/artifacts.js +14 -0
  30. package/dist/cli/release-commands/candidates.d.ts +3 -0
  31. package/dist/cli/release-commands/candidates.js +16 -0
  32. package/dist/cli/release-commands/changed.d.ts +3 -0
  33. package/dist/cli/release-commands/changed.js +14 -0
  34. package/dist/cli/release-commands/compose.d.ts +3 -0
  35. package/dist/cli/release-commands/compose.js +16 -0
  36. package/dist/cli/release-commands/cut.d.ts +3 -0
  37. package/dist/cli/release-commands/cut.js +49 -0
  38. package/dist/cli/release-commands/doctor.d.ts +3 -0
  39. package/dist/cli/release-commands/doctor.js +14 -0
  40. package/dist/cli/release-commands/export.d.ts +3 -0
  41. package/dist/cli/release-commands/export.js +12 -0
  42. package/dist/cli/release-commands/images.d.ts +3 -0
  43. package/dist/cli/release-commands/images.js +13 -0
  44. package/dist/cli/release-commands/index.d.ts +8 -0
  45. package/dist/cli/release-commands/index.js +52 -0
  46. package/dist/cli/release-commands/init.d.ts +3 -0
  47. package/dist/cli/release-commands/init.js +16 -0
  48. package/dist/cli/release-commands/list.d.ts +3 -0
  49. package/dist/cli/release-commands/list.js +10 -0
  50. package/dist/cli/release-commands/next.d.ts +3 -0
  51. package/dist/cli/release-commands/next.js +13 -0
  52. package/dist/cli/release-commands/publish.d.ts +3 -0
  53. package/dist/cli/release-commands/publish.js +22 -0
  54. package/dist/cli/release-commands/stamp.d.ts +3 -0
  55. package/dist/cli/release-commands/stamp.js +15 -0
  56. package/dist/cli/release-commands/status.d.ts +3 -0
  57. package/dist/cli/release-commands/status.js +17 -0
  58. package/dist/cli/release-commands/tag.d.ts +3 -0
  59. package/dist/cli/release-commands/tag.js +12 -0
  60. package/dist/cli/release-commands/types.d.ts +20 -0
  61. package/dist/cli/release-commands/types.js +1 -0
  62. package/dist/cli/release-commands/verify.d.ts +3 -0
  63. package/dist/cli/release-commands/verify.js +15 -0
  64. package/dist/cli/release-commands/workflow.d.ts +3 -0
  65. package/dist/cli/release-commands/workflow.js +13 -0
  66. package/dist/codegen/pinned-upgrade.js +1 -1
  67. package/dist/components/capability-plugin.d.ts +1 -1
  68. package/dist/components/capability-plugin.js +1 -1
  69. package/dist/components/cli-support.d.ts +1 -1
  70. package/dist/components/cli-support.js +1 -1
  71. package/dist/config-environments.d.ts +8 -1
  72. package/dist/config-environments.js +2 -0
  73. package/dist/config.d.ts +299 -6
  74. package/dist/config.js +102 -5
  75. package/dist/dead-guards.d.ts +5 -1
  76. package/dist/dead-guards.js +34 -23
  77. package/dist/discovery/sandbox/driver.js +1 -1
  78. package/dist/discovery/specifier-resolve.js +1 -1
  79. package/dist/floor-table.d.ts +3 -1
  80. package/dist/floor-table.data.js +23 -3
  81. package/dist/floor-table.js +4 -3
  82. package/dist/forge-remote.d.ts +13 -0
  83. package/dist/forge-remote.js +15 -0
  84. package/dist/lexicon.d.ts +41 -2
  85. package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +62 -0
  86. package/dist/lifecycle/__fixtures__/publish-fakes.js +270 -3
  87. package/dist/lifecycle/publish-attachments.d.ts +2 -1
  88. package/dist/lifecycle/publish-attachments.js +19 -2
  89. package/dist/lifecycle/publish-cargo.d.ts +99 -0
  90. package/dist/lifecycle/publish-cargo.js +412 -0
  91. package/dist/lifecycle/publish-credentials.d.ts +1 -1
  92. package/dist/lifecycle/publish-credentials.js +8 -0
  93. package/dist/lifecycle/publish-declaration.d.ts +199 -4
  94. package/dist/lifecycle/publish-declaration.js +200 -9
  95. package/dist/lifecycle/publish-forge.d.ts +45 -2
  96. package/dist/lifecycle/publish-forge.js +434 -34
  97. package/dist/lifecycle/publish-git-ssh.d.ts +15 -0
  98. package/dist/lifecycle/publish-git-ssh.js +30 -4
  99. package/dist/lifecycle/publish-github.d.ts +40 -2
  100. package/dist/lifecycle/publish-github.js +100 -3
  101. package/dist/lifecycle/publish-homebrew.d.ts +7 -9
  102. package/dist/lifecycle/publish-homebrew.js +34 -197
  103. package/dist/lifecycle/publish-index.d.ts +141 -0
  104. package/dist/lifecycle/publish-index.js +719 -0
  105. package/dist/lifecycle/publish-marketplace.js +77 -0
  106. package/dist/lifecycle/publish-mcp-registry.d.ts +66 -0
  107. package/dist/lifecycle/publish-mcp-registry.js +306 -0
  108. package/dist/lifecycle/publish-npm.js +165 -2
  109. package/dist/lifecycle/publish-oci.d.ts +34 -1
  110. package/dist/lifecycle/publish-oci.js +246 -7
  111. package/dist/lifecycle/publish-pypi.d.ts +136 -0
  112. package/dist/lifecycle/publish-pypi.js +657 -0
  113. package/dist/lifecycle/publish-record.d.ts +6 -3
  114. package/dist/lifecycle/publish-record.js +6 -3
  115. package/dist/lifecycle/publish-signing.d.ts +147 -0
  116. package/dist/lifecycle/publish-signing.js +257 -0
  117. package/dist/lifecycle/publish-targets.d.ts +27 -1
  118. package/dist/lifecycle/publish-targets.js +80 -0
  119. package/dist/lifecycle/publish-tauri.js +43 -0
  120. package/dist/lifecycle/publish-train-names.d.ts +54 -0
  121. package/dist/lifecycle/publish-train-names.js +118 -0
  122. package/dist/lifecycle/publish-verify.d.ts +121 -0
  123. package/dist/lifecycle/publish-verify.js +130 -0
  124. package/dist/lifecycle/query.js +8 -0
  125. package/dist/lifecycle/release-artifacts.d.ts +212 -0
  126. package/dist/lifecycle/release-artifacts.js +571 -0
  127. package/dist/lifecycle/release-changelog.d.ts +13 -1
  128. package/dist/lifecycle/release-changelog.js +35 -2
  129. package/dist/lifecycle/release-cut.d.ts +58 -3
  130. package/dist/lifecycle/release-cut.js +132 -34
  131. package/dist/lifecycle/release-doctor.d.ts +113 -0
  132. package/dist/lifecycle/release-doctor.js +996 -0
  133. package/dist/lifecycle/release-green.d.ts +86 -0
  134. package/dist/lifecycle/release-green.js +286 -0
  135. package/dist/lifecycle/release-init.d.ts +255 -0
  136. package/dist/lifecycle/release-init.js +859 -0
  137. package/dist/lifecycle/release-intents.d.ts +73 -0
  138. package/dist/lifecycle/release-intents.js +128 -0
  139. package/dist/lifecycle/release-next.d.ts +111 -0
  140. package/dist/lifecycle/release-next.js +252 -0
  141. package/dist/lifecycle/release-prerelease.d.ts +19 -0
  142. package/dist/lifecycle/release-prerelease.js +30 -0
  143. package/dist/lifecycle/release-publish.d.ts +256 -10
  144. package/dist/lifecycle/release-publish.js +246 -34
  145. package/dist/lifecycle/release-status-change.d.ts +226 -0
  146. package/dist/lifecycle/release-status-change.js +478 -0
  147. package/dist/lifecycle/release-status.d.ts +11 -0
  148. package/dist/lifecycle/release-status.js +1 -1
  149. package/dist/lifecycle/release-store.d.ts +73 -2
  150. package/dist/lifecycle/release-store.js +32 -1
  151. package/dist/lifecycle/release-tag.d.ts +142 -0
  152. package/dist/lifecycle/release-tag.js +323 -0
  153. package/dist/lifecycle/release-verify.d.ts +73 -1
  154. package/dist/lifecycle/release-verify.js +117 -2
  155. package/dist/lifecycle/release-version-formats.d.ts +73 -0
  156. package/dist/lifecycle/release-version-formats.js +570 -0
  157. package/dist/lifecycle/release-version.d.ts +58 -10
  158. package/dist/lifecycle/release-version.js +164 -36
  159. package/dist/lifecycle/release-workstation.d.ts +3 -2
  160. package/dist/lifecycle/release-workstation.js +3 -2
  161. package/dist/module-source.d.ts +2 -2
  162. package/dist/module-source.js +8 -8
  163. package/dist/op/generate-pipeline.js +1 -1
  164. package/dist/pr-forge-base.js +4 -2
  165. package/dist/pr-forge.d.ts +20 -2
  166. package/dist/pr-forge.js +46 -10
  167. package/dist/release-floors.d.ts +10 -1
  168. package/dist/release-floors.js +10 -1
  169. package/dist/tool-pins.d.ts +38 -0
  170. package/dist/tool-pins.js +54 -0
  171. package/dist/ts-loader.d.ts +1 -1
  172. package/dist/ts-loader.js +6 -6
  173. package/dist/wave-runtime.mjs +337 -334
  174. package/dist/workspace/ci-forge.d.ts +17 -0
  175. package/dist/workspace/ci-forge.js +17 -0
  176. package/dist/workspace/ci-init.js +1 -1
  177. package/dist/workspace/composites.schema.json +1 -0
  178. package/dist/workspace/declaration.d.ts +8 -0
  179. package/dist/workspace/declaration.js +12 -0
  180. package/dist/workspace/declaration.schema.json +8 -0
  181. package/dist/workspace/environments.d.ts +2 -0
  182. package/dist/workspace/environments.js +1 -1
  183. package/dist/workspace/identity-gate-rule.d.ts +61 -5
  184. package/dist/workspace/identity-gate-rule.js +81 -12
  185. package/dist/workspace/member-pipeline.d.ts +2 -1
  186. package/dist/workspace/member-pipeline.js +5 -2
  187. package/dist/workspace/reason-codes.d.ts +6 -0
  188. package/dist/workspace/reason-codes.js +8 -1
  189. package/dist/workspace/release-changed.d.ts +179 -0
  190. package/dist/workspace/release-changed.js +625 -0
  191. package/dist/workspace/release-changed.schema.json +206 -0
  192. package/dist/workspace/release-steps/artifacts.d.ts +7 -0
  193. package/dist/workspace/release-steps/artifacts.js +45 -0
  194. package/dist/workspace/release-steps/builds.d.ts +12 -0
  195. package/dist/workspace/release-steps/builds.js +38 -0
  196. package/dist/workspace/release-steps/doctor.d.ts +8 -0
  197. package/dist/workspace/release-steps/doctor.js +14 -0
  198. package/dist/workspace/release-steps/goreleaser.d.ts +16 -0
  199. package/dist/workspace/release-steps/goreleaser.js +36 -0
  200. package/dist/workspace/release-steps/green.d.ts +3 -0
  201. package/dist/workspace/release-steps/green.js +6 -0
  202. package/dist/workspace/release-steps/images.d.ts +22 -0
  203. package/dist/workspace/release-steps/images.js +59 -0
  204. package/dist/workspace/release-steps/index.d.ts +9 -0
  205. package/dist/workspace/release-steps/index.js +46 -0
  206. package/dist/workspace/release-steps/pypi.d.ts +15 -0
  207. package/dist/workspace/release-steps/pypi.js +21 -0
  208. package/dist/workspace/release-steps/qemu.d.ts +21 -0
  209. package/dist/workspace/release-steps/qemu.js +35 -0
  210. package/dist/workspace/release-steps/signing.d.ts +18 -0
  211. package/dist/workspace/release-steps/signing.js +30 -0
  212. package/dist/workspace/release-steps/stamp.d.ts +3 -0
  213. package/dist/workspace/release-steps/stamp.js +4 -0
  214. package/dist/workspace/release-steps/targets.d.ts +31 -0
  215. package/dist/workspace/release-steps/targets.js +40 -0
  216. package/dist/workspace/release-steps/types.d.ts +104 -0
  217. package/dist/workspace/release-steps/types.js +2 -0
  218. package/dist/workspace/release-steps/verify.d.ts +3 -0
  219. package/dist/workspace/release-steps/verify.js +4 -0
  220. package/dist/workspace/release-toolchains.d.ts +59 -0
  221. package/dist/workspace/release-toolchains.js +133 -0
  222. package/dist/workspace/release-train-workflow.d.ts +29 -0
  223. package/dist/workspace/release-train-workflow.js +85 -0
  224. package/dist/workspace/release-train.d.ts +3 -1
  225. package/dist/workspace/release-train.js +20 -3
  226. package/dist/workspace/release-workflow.d.ts +160 -61
  227. package/dist/workspace/release-workflow.js +539 -193
  228. package/dist/workspace/releases.schema.json +70 -1
  229. package/dist/workspace/search-contract.d.ts +1 -1
  230. package/dist/workspace/security.js +9 -2
  231. package/dist/workspace/train-cut.d.ts +182 -0
  232. package/dist/workspace/train-cut.js +482 -0
  233. package/dist/workspace/train-prepare.d.ts +61 -0
  234. package/dist/workspace/train-prepare.js +267 -0
  235. package/dist/workspace/train-publish.d.ts +177 -0
  236. package/dist/workspace/train-publish.js +575 -0
  237. package/dist/workspace/train-range-labels.d.ts +33 -0
  238. package/dist/workspace/train-range-labels.js +109 -0
  239. package/dist/workspace/trust/seal.d.ts +13 -3
  240. package/dist/workspace/trust/seal.js +14 -4
  241. package/dist/workspace/work-cli.d.ts +3 -2
  242. package/dist/workspace/work-cli.js +3 -2
  243. package/dist/workspace/workspace-ledger.d.ts +14 -1
  244. package/dist/workspace/workspace-ledger.js +33 -7
  245. package/package.json +26 -26
@@ -16,9 +16,11 @@
16
16
  * --allow-unsigned (#4049), and with a target a checkout that is not
17
17
  * the release's commit; warns with no OIDC provenance, and refuses
18
18
  * under --require-provenance; attaches SBOMs and provenance (#4049)
19
- * release verify <label|digest> [--json]
19
+ * release verify <label|digest> [--sigstore [--assets <dir>]] [--json]
20
20
  * check the release's signature offline against .chant/allowed_signers
21
21
  * at the release's commit (#4049)
22
+ * release changed [--at <sha>] [--bump-member <member>=<level>]... [--json]
23
+ * the members to release at a commit, with their dependency closure (#5134)
22
24
  * release candidates [--env <env>] [--lane <name>] [--forge-issues] [--json]
23
25
  * the green commits of trunk a release can be cut from, each with what it
24
26
  * would ship, and what each environment runs (#4168 4.2)
@@ -32,6 +34,9 @@
32
34
  * `--json` prints the read contract's `releases` document
33
35
  * release export <label|digest> --env <env> [-o <dir>] [--json]
34
36
  * write the files the release recorded for <env>, checked against their digests (#4046)
37
+ * release deprecate|yank|restore <label|digest> [--yes] [--reason <text>] [--replacement <label>] [--forge-release prerelease|draft|delete] [--actor <name>] [--sign [<key file>]] [--json]
38
+ * set a published release's status and act on each target that can
39
+ * (#5163, ../../lifecycle/release-status-change.ts): a dry run unless --yes
35
40
  * release compile --env <env> [--build <command>] [--artifacts --component <a,b>] --json
36
41
  * internal: what the cut runs in a child process per environment
37
42
  *
@@ -40,13 +45,18 @@
40
45
  * ../../lifecycle/release-publish.ts. A declaration whose `identity.gates`
41
46
  * names a `release` gate requires a signed cut by an actor in its class (#4031).
42
47
  */
43
- import { execFileSync } from "node:child_process";
48
+ import { execFileSync, spawnSync } from "node:child_process";
44
49
  import { cpSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
45
50
  import { tmpdir } from "node:os";
46
51
  import { dirname, join, relative, resolve } from "node:path";
47
52
  import { formatBold, formatError, formatSuccess, formatWarning } from "../format.js";
48
53
  import { parseParamFlags } from "../build-params-cli.js";
49
- const USAGE = "chant release cut [<label>] [--at <sha>] [--yes] [--build <command>] [--param <k=v>] [--image <component>=<repository>@sha256:<hex>] [--params-file <file>] [--src <dir>] [-o <file>] [--lexicon <name>] [--actor <name>] [--sign [<key file>]] [--channel <tag>] [--lane <name>] [--override-green] [--json] | release publish <label|digest> [--yes] [--allow-unsigned] [--require-provenance] [--json] | release verify <label|digest> [--json] | release images <label|digest> [--no-build] [-o <file>] [--json] | release candidates [--env <env>] [--lane <name>] [--forge-issues] [--json] | release compose <name> [--base <label|sha>] (--pr <n> | --work <id>)... [--yes] [--json] | release list [--json] | release export <label|digest> --env <env> [-o <dir>] [--json]";
54
+ import { prereleaseNote, prereleaseOf } from "../../lifecycle/release-prerelease.js";
55
+ import { releaseUsage } from "../release-commands/index.js";
56
+ /** The usage line printed with a refusal, built from ../release-commands (#5196). */
57
+ export const USAGE = releaseUsage();
58
+ /** The label `release cut` takes for the one `release next` computes (#5159). */
59
+ const AUTO_LABEL = "auto";
50
60
  /** The build inputs `release cut` and `release compile` share. */
51
61
  function compileInputs(ctx, params, projectDir = resolve("."), releaseLabel) {
52
62
  const { args } = ctx;
@@ -97,11 +107,62 @@ async function laneOf(ctx, cwd) {
97
107
  return undefined;
98
108
  }
99
109
  }
110
+ /** The member's `release.artifacts` (#5151), or none when the config declares none. */
111
+ async function releaseArtifactsOf(cwd) {
112
+ const { loadChantConfig } = await import("../../config.js");
113
+ return (await loadChantConfig(cwd)).config.release?.artifacts ?? [];
114
+ }
115
+ /** The member's `release.workflow.builds` (#5152), which a `release.artifacts` entry's `builtBy` names (#5183). */
116
+ async function releaseBuildJobsOf(cwd) {
117
+ const { loadChantConfig } = await import("../../config.js");
118
+ return (await loadChantConfig(cwd)).config.release?.workflow?.builds ?? [];
119
+ }
100
120
  /** The member's `release.images` (#4657), or none when the config declares none. A Dockerfile entry (#4819) keeps its form, so its prepare command runs. */
101
121
  async function releaseImagesOf(cwd) {
102
122
  const { loadChantConfig } = await import("../../config.js");
103
123
  return (await loadChantConfig(cwd)).config.release?.images ?? [];
104
124
  }
125
+ /**
126
+ * The green gate `release.green` names (#5149), or undefined for the default.
127
+ * A config that can't be loaded reads as naming none.
128
+ */
129
+ async function greenOf(cwd) {
130
+ try {
131
+ const { loadChantConfig } = await import("../../config.js");
132
+ return (await loadChantConfig(cwd)).config.release?.green;
133
+ }
134
+ catch {
135
+ return undefined;
136
+ }
137
+ }
138
+ /**
139
+ * The `release.publish` targets an artifact release records (#5149): read
140
+ * only when the member declares no environments, since a release cut from
141
+ * environments records its compile targets instead.
142
+ */
143
+ async function artifactPublishesOf(cwd) {
144
+ const { readMemberPromotionOrder } = await import("../../workspace/promotion-order.js");
145
+ if (((await readMemberPromotionOrder(cwd)) ?? []).length > 0)
146
+ return undefined;
147
+ const { releasePublishTargets } = await import("../../lifecycle/release-publish.js");
148
+ return (await releasePublishTargets(cwd)).map((t) => ({ target: t.key, kind: t.kind, destination: t.destination }));
149
+ }
150
+ /** How a cut's green gate reads in a line (#5149). */
151
+ export function describeGreen(green) {
152
+ if (!green)
153
+ return "no green gate recorded";
154
+ if (green.source === "chant")
155
+ return `green by ${green.tag.slice(0, green.tag.lastIndexOf("/"))} tag`;
156
+ if (green.source === "forge-checks")
157
+ return `green by ${green.checks.length} ${green.forge} check(s): ${green.checks.join(", ")}`;
158
+ return "no green gate (release.green: none)";
159
+ }
160
+ /** The warning a cut under `release.green: "none"` prints (#5149). */
161
+ const GREEN_NONE_WARNING = 'release.green is "none": this cut checked no CI result for the commit, and the release records that it had no green gate';
162
+ async function releaseTagOf(cwd) {
163
+ const { loadChantConfig } = await import("../../config.js");
164
+ return (await loadChantConfig(cwd)).config.release?.tag;
165
+ }
105
166
  async function releaseVersionOf(cwd) {
106
167
  const { loadChantConfig } = await import("../../config.js");
107
168
  return (await loadChantConfig(cwd)).config.release?.version;
@@ -191,6 +252,87 @@ export async function runReleaseImages(ctx) {
191
252
  }
192
253
  return 0;
193
254
  }
255
+ /**
256
+ * `release artifacts <label|digest> [--no-build] [--from <dir>] [-o <dir>] [--json]`
257
+ * (#5151): the files `release.artifacts` declares, checked against the
258
+ * digests the release records, from the release's commit checked out here.
259
+ * Without a flag it builds them again; `--no-build` checks the files on
260
+ * disk; `--from <dir>` first copies them from a directory where the cut job
261
+ * staged them. `-o <dir>` stages the checked files in a directory, at their
262
+ * paths in the member, for the next job. A file missing or with another
263
+ * digest is refused.
264
+ */
265
+ export async function runReleaseArtifacts(ctx) {
266
+ const { args } = ctx;
267
+ const ref = args.extraPositional;
268
+ const fail = (code, message, fix) => {
269
+ if (args.json)
270
+ console.log(JSON.stringify({ ref: ref ?? null, error: { code, message, ...(fix ? { fix } : {}) } }, null, 2));
271
+ else
272
+ console.error(formatError({ message: `${message} [${code}]`, ...(fix ? { hint: fix } : {}) }));
273
+ return 1;
274
+ };
275
+ if (!ref)
276
+ return fail("release-not-named", "release artifacts needs a release, by label or digest", USAGE);
277
+ const cwd = resolve(".");
278
+ const { resolveRelease } = await import("../../lifecycle/release-store.js");
279
+ const { artifactFileProblems, buildReleaseArtifacts, copyArtifactFiles, releaseArtifactFiles, ReleaseArtifactError } = await import("../../lifecycle/release-artifacts.js");
280
+ const { getHeadCommit } = await import("../../lifecycle/git.js");
281
+ const found = await resolveRelease(ref, { cwd });
282
+ if (!found)
283
+ return fail("release-not-found", `no release is labelled or digested "${ref}" in this member`, "Fetch chant/lifecycle (git fetch origin chant/lifecycle:chant/lifecycle), then list them with: chant release list");
284
+ const { release, label } = found;
285
+ const head = await getHeadCommit({ cwd });
286
+ if (head !== release.commit)
287
+ return fail("release-artifacts-wrong-commit", `the release was cut from ${release.commit.slice(0, 12)}, and this checkout is at ${head.slice(0, 12)}, so its files would not be the release's`, `Check out the release's commit: git checkout ${release.commit}`);
288
+ const declared = await releaseArtifactsOf(cwd);
289
+ if (declared.length === 0)
290
+ return fail("release-artifacts-not-declared", "this member's chant.config.ts has no release.artifacts, so there is nothing to check", "Declare the files the cut builds: release: { artifacts: [{ name: \"cli\", build: \"make dist\", outputs: [\"dist/cli\"] }] }");
291
+ const files = releaseArtifactFiles(release, declared.map((d) => d.name));
292
+ const recordedNames = new Set(files.map((f) => f.component));
293
+ const missing = declared.filter((d) => !recordedNames.has(d.name)).map((d) => d.name);
294
+ if (missing.length > 0)
295
+ return fail("release-artifact-not-recorded", `release.artifacts names ${missing.join(", ")}, which release ${release.releaseDigest} does not record`, "Cut a new release, so its cut builds every file the config declares.");
296
+ const from = args.migrateFrom;
297
+ try {
298
+ if (from !== undefined)
299
+ copyArtifactFiles(files, resolve(from), cwd);
300
+ else if (!args.noBuild) {
301
+ const images = await releaseImagesOf(cwd);
302
+ const built = buildReleaseArtifacts({ artifacts: declared, cwd, sourceDateEpoch: commitTime(cwd, release.commit), label, imageNames: images.map((i) => i.name), builds: await releaseBuildJobsOf(cwd) });
303
+ const recorded = new Set(files.map((f) => f.path));
304
+ const extra = built.filter((b) => !recorded.has(b.path)).map((b) => b.path);
305
+ if (extra.length > 0)
306
+ return fail("release-artifact-digest-mismatch", `the build wrote ${extra.join(", ")}, which release ${release.releaseDigest} does not record`, "A build of the release's commit must write the files the cut wrote. Cut a new release.");
307
+ }
308
+ }
309
+ catch (err) {
310
+ if (err instanceof ReleaseArtifactError)
311
+ return fail(err.code, err.message, err.fix);
312
+ throw err;
313
+ }
314
+ const problems = artifactFileProblems(cwd, files);
315
+ const absent = problems.filter((p) => p.problem === "missing");
316
+ if (absent.length > 0)
317
+ return fail("release-artifact-missing", `${absent.map((p) => p.path).join(", ")} ${absent.length === 1 ? "is" : "are"} not here`, "Hand this job the files the cut staged (--from <dir>), or run without --no-build to build them again.");
318
+ if (problems.length > 0) {
319
+ return fail("release-artifact-digest-mismatch", problems.map((p) => `${p.path} is ${p.digest}, and the release records ${p.recorded}`).join("; "), args.noBuild || from !== undefined ? "Publish the files the cut built: hand them over unchanged, or cut a new release." : "A build of the same commit must write the same bytes: set every timestamp from SOURCE_DATE_EPOCH and leave out build paths (go build -trimpath).");
320
+ }
321
+ let staged = null;
322
+ if (args.output) {
323
+ staged = resolve(args.output);
324
+ copyArtifactFiles(files, cwd, staged);
325
+ }
326
+ if (args.json)
327
+ console.log(JSON.stringify({ releaseDigest: release.releaseDigest, label, files: files.map((f) => ({ name: f.component, path: f.path, digest: f.digest })), staged }, null, 2));
328
+ else {
329
+ for (const f of files)
330
+ console.error(` ${f.component} ${f.path} ${f.digest}`);
331
+ const how = from !== undefined ? `Copied from ${from} and checked` : args.noBuild ? "Checked" : "Built and checked";
332
+ console.error(formatSuccess(`${how} ${files.length} file(s) against release ${label ?? release.releaseDigest}${staged ? `, and staged them in ${relative(cwd, staged) || staged}` : ""}`));
333
+ }
334
+ return 0;
335
+ }
194
336
  /**
195
337
  * `release stamp <label> [--json]` (#4840): write the label into the files
196
338
  * `release.version` names, as the cut does before its build, and leave them
@@ -213,11 +355,25 @@ export async function runReleaseStamp(ctx) {
213
355
  const cwd = resolve(".");
214
356
  const config = await releaseVersionOf(cwd);
215
357
  if (!config)
216
- return fail("release-version-not-declared", "this member's chant.config.ts has no release.version, so there is nothing to stamp", "Name the package directories: release: { version: { packages: [\"packages/cli\"] } }");
217
- const { stampReleaseVersion, ReleaseVersionError } = await import("../../lifecycle/release-version.js");
358
+ return fail("release-version-not-declared", "this member's chant.config.ts has no release.version, so there is nothing to stamp", "Name the package directories or the files: release: { version: { packages: [\"packages/cli\"] } } or { version: { files: [\"Cargo.toml\"] } }");
359
+ const { stampReleaseVersion, ReleaseVersionError, ownNames } = await import("../../lifecycle/release-version.js");
360
+ if (args.train !== undefined && config.ranges !== "train")
361
+ return fail("release-ranges-not-train", `--train names a train, and this member's release.version.ranges is ${config.ranges ?? "unset"}`, 'Set release.version.ranges to "train", or leave --train out.');
218
362
  let files;
219
363
  try {
220
- files = stampReleaseVersion({ cwd, config, label }).files;
364
+ let train;
365
+ if (args.train !== undefined) {
366
+ const { trainLabels, TrainLabelsError } = await import("../../workspace/train-range-labels.js");
367
+ try {
368
+ train = await trainLabels(cwd, args.train, ownNames(cwd, config), label);
369
+ }
370
+ catch (err) {
371
+ if (err instanceof TrainLabelsError)
372
+ return fail(err.code, err.message, err.fix);
373
+ throw err;
374
+ }
375
+ }
376
+ files = stampReleaseVersion({ cwd, config, label, ...(train ? { train } : {}) }).files;
221
377
  }
222
378
  catch (err) {
223
379
  if (err instanceof ReleaseVersionError)
@@ -230,6 +386,70 @@ export async function runReleaseStamp(ctx) {
230
386
  console.error(formatSuccess(`Stamped ${label} into ${files.join(", ")}`));
231
387
  return 0;
232
388
  }
389
+ /**
390
+ * `release tag <label|digest|tag> [--json]` (#5150): the tag `release.tag`
391
+ * gives a release of this member, found by its label, its digest, or the tag
392
+ * itself. The ledger names the release: a tag is matched by rendering the
393
+ * template for each label the member's ledger holds, never parsed. The
394
+ * publish job of `chant release workflow` reads the label of the tag that
395
+ * started it this way.
396
+ */
397
+ export async function runReleaseTag(ctx) {
398
+ const { args } = ctx;
399
+ const ref = args.extraPositional ?? null;
400
+ const fail = (code, message, fix) => {
401
+ if (args.json)
402
+ console.log(JSON.stringify({ ref, error: { code, message, ...(fix ? { fix } : {}) } }, null, 2));
403
+ else
404
+ console.error(formatError({ message: `${message} [${code}]`, ...(fix ? { hint: fix } : {}) }));
405
+ return 1;
406
+ };
407
+ if (ref === null)
408
+ return fail("release-not-named", "release tag needs a release, by label, digest or tag", "chant release tag <label|digest|tag> [--json]");
409
+ const cwd = resolve(".");
410
+ const { fetchLifecycle } = await import("../../lifecycle/git.js");
411
+ const { resolveRelease, readCuts } = await import("../../lifecycle/release-store.js");
412
+ const t = await import("../../lifecycle/release-tag.js");
413
+ await fetchLifecycle({ cwd }).catch(() => false);
414
+ let tags;
415
+ try {
416
+ tags = await t.memberTags(cwd);
417
+ }
418
+ catch (err) {
419
+ if (err instanceof t.ReleaseTagError)
420
+ return fail(err.code, err.message, err.fix);
421
+ throw err;
422
+ }
423
+ let found = await resolveRelease(ref, { cwd });
424
+ if (!found) {
425
+ const labels = (await readCuts({ cwd })).cuts.map((c) => c.label).filter((l) => l !== null);
426
+ const label = t.labelOfTag(tags.template, tags.place, ref, new Set(labels));
427
+ if (label !== null)
428
+ found = await resolveRelease(label, { cwd });
429
+ }
430
+ if (!found)
431
+ return fail("release-not-found", `no release of this member is labelled, digested or tagged "${ref}"`, "Fetch chant/lifecycle (git fetch origin chant/lifecycle:chant/lifecycle), then list them with: chant release list");
432
+ const { release, label } = found;
433
+ let tag;
434
+ let floating;
435
+ try {
436
+ tag = label !== null ? t.renderReleaseTag(tags.template, tags.place, label) : null;
437
+ floating = label !== null ? t.renderFloatingTag(tags.template, tags.place, label) : null;
438
+ }
439
+ catch (err) {
440
+ if (err instanceof t.ReleaseTagError)
441
+ return fail(err.code, err.message, err.fix);
442
+ throw err;
443
+ }
444
+ if (args.json) {
445
+ console.log(JSON.stringify({ releaseDigest: release.releaseDigest, label, commit: release.commit, tag, floating, template: tags.template.name }, null, 2));
446
+ return 0;
447
+ }
448
+ if (tag === null)
449
+ return fail("release-no-label", `${release.releaseDigest} has no label, so it has no tag`);
450
+ console.log(tag);
451
+ return 0;
452
+ }
233
453
  function describeActorSource(source) {
234
454
  switch (source) {
235
455
  case "flag":
@@ -264,7 +484,11 @@ export async function runReleaseCut(ctx) {
264
484
  console.error(formatError({ message: `the label is given twice, as "${positional}" and --label "${args.label}"`, hint: USAGE }));
265
485
  return 1;
266
486
  }
267
- const label = positional ?? args.label ?? null;
487
+ let label = positional ?? args.label ?? null;
488
+ if (args.pre !== undefined && label !== AUTO_LABEL) {
489
+ console.error(formatError({ message: "--pre names the prerelease id of a computed label, and the cut is given its label", hint: "Cut auto --pre <id>, or give the prerelease label itself, such as 1.5.0-rc.0." }));
490
+ return 1;
491
+ }
268
492
  // #4693: the reason is the override's, written by the person who overrides.
269
493
  if (args.reason !== undefined) {
270
494
  console.error(formatError({
@@ -275,7 +499,7 @@ export async function runReleaseCut(ctx) {
275
499
  }
276
500
  const dryRun = args.yes !== true;
277
501
  const cwd = resolve(".");
278
- const { spawnTargetCompiler, ReleaseCompileError } = await import("../../components/release-compile.js");
502
+ const { spawnTargetCompiler, ReleaseCompileError, RELEASE_LABEL_ENV } = await import("../../components/release-compile.js");
279
503
  const { cutRelease, planRelease, ReleaseCutError } = await import("../../lifecycle/release-cut.js");
280
504
  const { ReleaseLabelError } = await import("../../lifecycle/release-store.js");
281
505
  const { pushLifecycleRebasing, getHeadCommit } = await import("../../lifecycle/git.js");
@@ -343,6 +567,28 @@ export async function runReleaseCut(ctx) {
343
567
  const ledger = await resolveMemberLedger(cwd);
344
568
  member = ledger.members.length > 0 ? ledger.members.join("/") : null;
345
569
  }
570
+ // #5159: `auto` is the label the commits and intent files since the previous release give, and every
571
+ // labelled cut consumes the intent files that name the member.
572
+ let computed = null;
573
+ let intents = [];
574
+ {
575
+ const rn = await import("../../lifecycle/release-next.js");
576
+ try {
577
+ if (label === AUTO_LABEL) {
578
+ computed = await rn.nextRelease({ cwd, ...(commit ? { at: commit } : {}), ...(args.pre !== undefined ? { pre: args.pre } : {}) });
579
+ label = computed.label;
580
+ intents = computed.intents;
581
+ }
582
+ else if (label !== null && top && commit) {
583
+ intents = await rn.memberPendingIntents(cwd, top, commit);
584
+ }
585
+ }
586
+ catch (err) {
587
+ if (err instanceof rn.ReleaseNextError)
588
+ return fail(err.code, `no release was cut: ${err.message}`, err.fix);
589
+ throw err;
590
+ }
591
+ }
346
592
  // The signing key is resolved now, so a dry run shows a key that can't be read.
347
593
  let publicKey = null;
348
594
  if (args.sign !== undefined) {
@@ -370,7 +616,6 @@ export async function runReleaseCut(ctx) {
370
616
  return 1;
371
617
  }
372
618
  const actor = who.actor;
373
- const tag = label !== null && commit !== null && top ? { name: ws.releaseTagName(member, label), state: ws.checkReleaseTag(top, ws.releaseTagName(member, label), commit) } : null;
374
619
  const ci = resolveCiRun(process.env);
375
620
  const params = parseParamFlags(args.param);
376
621
  // #4694: images built elsewhere, handed to the cut by digest, one per component.
@@ -390,6 +635,13 @@ export async function runReleaseCut(ctx) {
390
635
  if (args.at !== undefined && top && commit)
391
636
  checkout = at.checkoutCommit(top, cwd, commit);
392
637
  const cutCwd = checkout?.memberDir ?? cwd;
638
+ // #5150: the tag from release.tag in the commit's own config, refused when another member's template can render it.
639
+ const tagsMod = await import("../../lifecycle/release-tag.js");
640
+ const tags = top ? await tagsMod.memberTags(cwd, { config: await releaseTagOf(cutCwd), top }) : null;
641
+ if (tags)
642
+ await tagsMod.checkTagCollisions(cwd, tags);
643
+ const tagName = (l) => tagsMod.renderReleaseTag(tags.template, tags.place, l);
644
+ const tag = label !== null && commit !== null && top ? { name: tagName(label), state: ws.checkReleaseTag(top, tagName(label), commit) } : null;
393
645
  const versionConfig = await releaseVersionOf(cutCwd);
394
646
  // #4657: the images release.images declares are built first, and their digests handed to the build command.
395
647
  const declaredImages = await releaseImagesOf(cutCwd);
@@ -411,6 +663,30 @@ export async function runReleaseCut(ctx) {
411
663
  }
412
664
  }
413
665
  : undefined;
666
+ // #5151: the files release.artifacts declares, built after the images and recorded as assets.
667
+ const declaredArtifacts = await releaseArtifactsOf(cutCwd);
668
+ const buildJobs = await releaseBuildJobsOf(cutCwd);
669
+ const buildArtifacts = declaredArtifacts.length > 0
670
+ ? async (at) => {
671
+ const { buildReleaseArtifacts, isPrebuilt, ReleaseArtifactError } = await import("../../lifecycle/release-artifacts.js");
672
+ // #5183: under --at, files built before the cut are read from this checkout, which must hold the commit cut.
673
+ const prebuilt = declaredArtifacts.filter(isPrebuilt);
674
+ if (checkout && prebuilt.length > 0) {
675
+ const here = await getHeadCommit({ cwd });
676
+ if (here !== at) {
677
+ throw new ReleaseCutError("release-artifact-wrong-commit", `no release was cut: release.artifacts ${prebuilt.map((a) => `"${a.name}"`).join(", ")} ${prebuilt.length === 1 ? "is" : "are"} read from this checkout, which is at ${here.slice(0, 12)}, and the cut is of ${at.slice(0, 12)}, so the files might not be that commit's`, `Check out the commit being cut and build the files there: git checkout ${at}`);
678
+ }
679
+ }
680
+ try {
681
+ return buildReleaseArtifacts({ artifacts: declaredArtifacts, cwd: cutCwd, sourceDateEpoch: commitTime(cutCwd, at), label, imageNames: declaredImages.map((d) => d.name), builds: buildJobs, ...(checkout ? { prebuiltFrom: cwd } : {}) });
682
+ }
683
+ catch (err) {
684
+ if (!(err instanceof ReleaseArtifactError))
685
+ throw err;
686
+ throw new ReleaseCutError(err.code, `no release was cut: ${err.message}`, err.fix);
687
+ }
688
+ }
689
+ : undefined;
414
690
  // #4840: release.version stamps the label into package.json once the cut has found the tree clean.
415
691
  const stamp = versionConfig
416
692
  ? async () => {
@@ -428,6 +704,24 @@ export async function runReleaseCut(ctx) {
428
704
  : undefined;
429
705
  // #4692: the lane is the commit's own config's under --at.
430
706
  const lane = await laneOf(ctx, cutCwd);
707
+ // #5149: the green gate, and for a member with no environments what release.publish publishes.
708
+ const greenSource = await greenOf(cutCwd);
709
+ const publishes = await artifactPublishesOf(cutCwd);
710
+ const buildCommand = args.buildCommand;
711
+ const build = publishes !== undefined && buildCommand
712
+ ? () => {
713
+ const env = { ...process.env };
714
+ delete env[RELEASE_LABEL_ENV];
715
+ delete env.CHANT_RELEASE_DIGESTS;
716
+ if (label !== null)
717
+ env[RELEASE_LABEL_ENV] = label;
718
+ if (digestsFile)
719
+ env.CHANT_RELEASE_DIGESTS = digestsFile;
720
+ const run = spawnSync(buildCommand, { cwd: cutCwd, shell: true, stdio: ["ignore", 2, 2], env });
721
+ if (run.status !== 0)
722
+ throw new ReleaseCompileError(`the build command exited ${run.status ?? "with a signal"}: ${buildCommand}`);
723
+ }
724
+ : undefined;
431
725
  const request = {
432
726
  cwd: cutCwd,
433
727
  compiler,
@@ -440,7 +734,12 @@ export async function runReleaseCut(ctx) {
440
734
  ...(args.overrideGreen ? { overrideGreen: true } : {}),
441
735
  ...(Object.keys(images).length > 0 ? { images } : {}),
442
736
  ...(buildImages ? { buildImages } : {}),
737
+ ...(buildArtifacts ? { buildArtifacts } : {}),
443
738
  ...(stamp ? { stamp } : {}),
739
+ ...(greenSource ? { green: greenSource } : {}),
740
+ ...(publishes ? { publishes } : {}),
741
+ ...(build ? { build } : {}),
742
+ ...(intents.length > 0 ? { intents: intents.map(({ path, added, bump }) => ({ path, added, bump })) } : {}),
444
743
  };
445
744
  if (dryRun) {
446
745
  const plan = await planRelease(request);
@@ -462,9 +761,12 @@ export async function runReleaseCut(ctx) {
462
761
  trunk,
463
762
  composed: composed ?? null,
464
763
  channel: args.channel ?? null,
764
+ prerelease: prereleaseOf(plan.label) !== null,
465
765
  at: args.at !== undefined ? { ref: args.at, commit } : null,
466
766
  sign: args.sign !== undefined ? { key: publicKey !== null ? publicKey.split(" ")[0] : null, readable: publicKey !== null } : null,
467
767
  tag: tag ? { name: tag.name, exists: tag.state === "present" } : null,
768
+ computed: computed ? { from: computed.from, bump: computed.bump, alreadyCut: computed.alreadyCut, commits: computed.commits.length } : null,
769
+ intents: intents.map(({ path, bump }) => ({ path, bump })),
468
770
  publish: { targets: Array.isArray(publishTargets) ? publishTargets : [], provenance },
469
771
  next: [sameWithYes(process.argv.slice(2))],
470
772
  };
@@ -474,10 +776,14 @@ export async function runReleaseCut(ctx) {
474
776
  }
475
777
  const name = plan.label ? formatBold(plan.label) : "an unlabelled release";
476
778
  const greenIn = plan.override
477
- ? `not green: no ${plan.override.tag.slice(0, plan.override.tag.lastIndexOf("/"))} tag`
779
+ ? `not green: ${plan.override.tag.startsWith("forge-checks/") ? "its forge checks did not pass" : `no ${plan.override.tag.slice(0, plan.override.tag.lastIndexOf("/"))} tag`}`
478
780
  : plan.lane !== null
479
781
  ? `green in lane ${plan.lane}`
480
- : "green";
782
+ : plan.green?.source === "forge-checks"
783
+ ? `green by its ${plan.green.forge} checks`
784
+ : plan.green?.source === "none"
785
+ ? "no green gate"
786
+ : "green";
481
787
  const where = composed
482
788
  ? ` (on ${trunk.remote}/${composed.branch}, composed on ${composed.base.slice(0, 12)} from ${composed.sources.length} trunk commit(s), ${greenIn})`
483
789
  : trunk
@@ -486,6 +792,18 @@ export async function runReleaseCut(ctx) {
486
792
  console.log(`Dry run: cut ${name} from commit ${plan.commit.slice(0, 12)}${where}`);
487
793
  if (args.channel)
488
794
  console.log(` channel ${args.channel}: a publish moves ${args.channel}, not latest`);
795
+ if (prereleaseOf(plan.label))
796
+ console.log(` prerelease: ${prereleaseNote(plan.label, args.channel)}`);
797
+ if (computed && !computed.alreadyCut)
798
+ console.log(` label from release next: ${computed.bump ?? "the prerelease's version"} from ${computed.from.label}, ${computed.commits.length} commit(s) and ${computed.intents.length} intent file(s) since`);
799
+ for (const i of intents)
800
+ console.log(` consumes ${i.path} (${i.bump})`);
801
+ if (plan.green)
802
+ console.log(` gate: ${describeGreen(plan.green)}`);
803
+ if (plan.green?.source === "none")
804
+ console.error(formatWarning({ message: GREEN_NONE_WARNING }));
805
+ if (plan.publishes)
806
+ console.log(` an artifact release: no environment is compiled, and it records ${plan.publishes.length} publish target(s)`);
489
807
  if (plan.override)
490
808
  console.log(` under the override by ${plan.override.by} at ${plan.override.at}${plan.override.sealed ? ", sealed" : ""}: ${plan.override.reason}; the cut spends it`);
491
809
  if (plan.alreadyCut)
@@ -509,7 +827,7 @@ export async function runReleaseCut(ctx) {
509
827
  console.log(` ${h.component}: image ${h.ref}, handed to the cut, not built`);
510
828
  console.log(` digest ${plan.releaseDigest ?? "decided when the artifacts are built"}`);
511
829
  console.log("What will be published where:");
512
- if (plan.publishSteps.length === 0)
830
+ if (plan.publishSteps.length === 0 && !plan.publishes)
513
831
  console.log(" no component declares a publish step");
514
832
  for (const p of plan.publishSteps) {
515
833
  console.log(` ${p.component}: ${p.kind}${p.to ? ` to ${p.to}` : ""} in ${p.envs.join(", ")}, by that environment's deploy (chant components promote --release ${deployRef})`);
@@ -533,6 +851,14 @@ export async function runReleaseCut(ctx) {
533
851
  // publish job) finds them.
534
852
  if (checkout && declaredImages.length > 0)
535
853
  copyImageArchives((await import("../../lifecycle/release-images.js")).resolveReleaseImages(declaredImages), cutCwd, cwd);
854
+ // #5151: the files too, so `release artifacts -o` in the same job stages them for the publish job. The files
855
+ // built before the cut (#5183) came from here; only what the cut packed from them is copied back.
856
+ if (checkout && declaredArtifacts.length > 0) {
857
+ const { copyArtifactFiles, isPrebuilt, releaseArtifactFiles } = await import("../../lifecycle/release-artifacts.js");
858
+ const asFound = declaredArtifacts.filter((a) => isPrebuilt(a) && a.archive === undefined).map((a) => a.name);
859
+ const copied = declaredArtifacts.map((a) => a.name).filter((n) => !asFound.includes(n));
860
+ copyArtifactFiles(releaseArtifactFiles(result.release, copied), cutCwd, cwd, { missingOk: true });
861
+ }
536
862
  // #4965: the record must be on the remote before the release is tagged. The release workflow pushes the tag
537
863
  // right after the cut, and a tag whose record never landed spends the label: the publish job finds no release.
538
864
  // A refused push is tried again; one that never lands stops the cut here, untagged and non-zero.
@@ -547,7 +873,7 @@ export async function runReleaseCut(ctx) {
547
873
  let tagged = null;
548
874
  let tagWarning;
549
875
  if (result.label !== null && top) {
550
- const name = ws.releaseTagName(member, result.label);
876
+ const name = tagName(result.label);
551
877
  try {
552
878
  const state = ws.checkReleaseTag(top, name, result.release.commit);
553
879
  if (state === "absent")
@@ -567,7 +893,7 @@ export async function runReleaseCut(ctx) {
567
893
  noComponents: result.release.targets.every((t) => t.templates.every((tpl) => tpl.component === null)) && result.release.artifactDigests.length === 0,
568
894
  });
569
895
  if (args.json) {
570
- console.log(JSON.stringify({ dryRun: false, release: result.release, label: result.label, cut: result.cut, stored: result.stored, reused: result.reused, handed: result.handed, actor, actorSource: who.source, tag: tagged, composed: composed ?? null, channel: args.channel ?? null, lane: lane ?? null, next }, null, 2));
896
+ console.log(JSON.stringify({ dryRun: false, release: result.release, label: result.label, cut: result.cut, stored: result.stored, reused: result.reused, handed: result.handed, actor, actorSource: who.source, tag: tagged, composed: composed ?? null, channel: args.channel ?? null, prerelease: prereleaseOf(result.label) !== null, lane: lane ?? null, next }, null, 2));
571
897
  }
572
898
  else {
573
899
  const name = result.label ? formatBold(result.label) : "unlabelled release";
@@ -578,11 +904,19 @@ export async function runReleaseCut(ctx) {
578
904
  console.error(` commit ${result.release.commit}${composed ? `, composed on ${composed.base.slice(0, 12)} on ${composed.branch}` : ""}${lane !== undefined ? `, green in lane ${lane}` : ""}`);
579
905
  if (args.channel)
580
906
  console.error(` channel ${args.channel}`);
907
+ if (prereleaseOf(result.label))
908
+ console.error(` prerelease: ${prereleaseNote(result.label, args.channel)}`);
909
+ for (const i of result.cut?.intents ?? [])
910
+ console.error(` consumed ${i.path} (${i.bump})`);
581
911
  if (result.cut?.override)
582
912
  console.error(` not green: cut under the override by ${result.cut.override.by}: ${result.cut.override.reason}`);
913
+ if (result.cut?.green)
914
+ console.error(` gate: ${describeGreen(result.cut.green)}`);
915
+ if (result.release.publishes)
916
+ console.error(` publishes: ${result.release.publishes.map((p) => `${p.kind} to ${p.destination}`).join("; ") || "nothing"}`);
583
917
  if (result.cut)
584
918
  console.error(` ${result.cut.signature ? `signed by ${result.cut.actor}` : `not signed; actor ${result.cut.actor}`}, run ${result.cut.runId}`);
585
- console.error(` artifacts ${result.release.artifactDigests.length}, targets ${result.release.targets.map((t) => `${t.env} (${t.templates.length} template${t.templates.length === 1 ? "" : "s"})`).join(", ")}`);
919
+ console.error(` artifacts ${result.release.artifactDigests.length}, ${result.release.publishes ? "no environment (an artifact release)" : `targets ${result.release.targets.map((t) => `${t.env} (${t.templates.length} template${t.templates.length === 1 ? "" : "s"})`).join(", ")}`}`);
586
920
  for (const r of result.reused)
587
921
  console.error(` ${r.component}: artifacts unchanged, carried from ${r.from}`);
588
922
  for (const h of result.handed)
@@ -598,9 +932,13 @@ export async function runReleaseCut(ctx) {
598
932
  console.error(formatWarning({ message: push.pushWarning }));
599
933
  if (tagWarning)
600
934
  console.error(formatWarning({ message: tagWarning }));
935
+ if (result.cut?.green?.source === "none")
936
+ console.error(formatWarning({ message: GREEN_NONE_WARNING }));
601
937
  return 0;
602
938
  }
603
939
  catch (err) {
940
+ if (err instanceof (await import("../../lifecycle/release-tag.js")).ReleaseTagError)
941
+ return fail(err.code, `no release was cut: ${err.message}`, err.fix);
604
942
  if (err instanceof ws.WorkstationCheckError || err instanceof ReleaseCutError || err instanceof at.CutAtError) {
605
943
  // #4693: a request for an override goes where the person who answers it reads.
606
944
  if (err instanceof ReleaseCutError && err.recorded) {
@@ -661,7 +999,7 @@ export async function runReleasePublish(ctx) {
661
999
  const prepared = await preparePublish({ cwd, ref, allowUnsigned: args.allowUnsigned === true, requireProvenance: args.requireProvenance === true });
662
1000
  if ("refusal" in prepared)
663
1001
  return fail(prepared.refusal.code, prepared.refusal.message, prepared.refusal.fix);
664
- const { release, label, signature, provenance, warning, signatureWarning, targets, redactor } = prepared;
1002
+ const { release, label, signature, provenance, warning, signatureWarning, gateWarning, signingWarning, targets, redactor } = prepared;
665
1003
  const name = label ?? release.releaseDigest;
666
1004
  const deploySteps = release.targets.map((t) => t.env);
667
1005
  const say = (line) => console.error(redactor.redact(line));
@@ -669,13 +1007,19 @@ export async function runReleasePublish(ctx) {
669
1007
  const errorOf = (err) => err instanceof PublishTargetError ? { code: err.code, message: err.message, ...(err.fix ? { fix: err.fix } : {}) } : { code: "publish-failed", message: err instanceof Error ? err.message : String(err) };
670
1008
  if (!args.json) {
671
1009
  say(`${dryRun ? "Dry run: publish" : "Publishing"} ${formatBold(name)} (${release.releaseDigest}) from commit ${release.commit.slice(0, 12)}`);
672
- say(` ${signature.status === "verified" ? `signed by ${signature.actor}` : signature.status === "unsigned" ? "not signed" : `signature unverified: ${signature.reason}`}`);
1010
+ say(` ${signature.status === "verified" ? `signed by ${signature.actor}, green gate ${signature.gate}` : signature.status === "unsigned" ? "not signed" : `signature unverified: ${signature.reason}`}`);
673
1011
  }
674
1012
  // The warnings go to stderr with --json too, before any target runs.
675
1013
  if (signatureWarning)
676
1014
  console.error(formatWarning({ message: signatureWarning }));
1015
+ if (gateWarning)
1016
+ console.error(formatWarning({ message: gateWarning }));
677
1017
  if (warning)
678
1018
  console.error(formatWarning({ message: warning }));
1019
+ if (signingWarning)
1020
+ console.error(formatWarning({ message: signingWarning }));
1021
+ if (prepared.signing && !args.json)
1022
+ say(` signing images and forge assets with Sigstore (${prepared.signing.signer.name}) as ${prepared.signing.identity.identity}, issuer ${prepared.signing.identity.issuer}`);
679
1023
  // #4168 4.3: a release cut with --channel moves that tag, not latest.
680
1024
  const pctx = publishContext(prepared, { cwd, tag: prepared.channel, log: (line) => (args.json ? undefined : console.error(` ${line}`)) });
681
1025
  // Every target is planned before any publishes, so a missing file or credential stops the publish with nothing sent.
@@ -683,7 +1027,7 @@ export async function runReleasePublish(ctx) {
683
1027
  const planned = [];
684
1028
  for (const target of targets) {
685
1029
  try {
686
- planned.push({ kind: target.kind, name: target.name, destination: target.destination, progress: progressOf(progress, target), items: await target.plan(pctx) });
1030
+ planned.push({ kind: target.kind, name: target.name, destination: target.destination, progress: progressOf(progress, target), ...(target.revealsLast ? { revealsLast: true } : {}), items: await target.plan(pctx) });
687
1031
  }
688
1032
  catch (err) {
689
1033
  const e = errorOf(err);
@@ -698,7 +1042,31 @@ export async function runReleasePublish(ctx) {
698
1042
  ? ` Each environment deploys the files the release recorded: chant release export ${name} --env ${deploySteps[0]}`
699
1043
  : ` A component's publish steps run in each environment's deploy of the release: chant components promote --release ${name} --to ${deploySteps[0]}`;
700
1044
  };
701
- const base = { releaseDigest: release.releaseDigest, label, commit: release.commit, signature, provenance, warnings: [signatureWarning, warning].filter((w) => w !== null) };
1045
+ const pre = prereleaseOf(label);
1046
+ if (pre && !args.json)
1047
+ say(` prerelease: ${prereleaseNote(label, prepared.channel ?? undefined)}`);
1048
+ const floating = prepared.floating ?? null;
1049
+ // #5157: release.verify runs between the stages and the reveals; a target whose stage is visible is out of its reach.
1050
+ const verifySteps = targets.length > 0 ? (prepared.verify ?? []) : [];
1051
+ const { unstagedForVerify, unstagedWarning } = await import("../../lifecycle/publish-verify.js");
1052
+ const unstaged = verifySteps.length > 0 ? unstagedForVerify(targets) : [];
1053
+ const verifyWarning = unstaged.length > 0 ? unstagedWarning(unstaged) : null;
1054
+ if (verifyWarning)
1055
+ console.error(formatWarning({ message: verifyWarning }));
1056
+ const base = {
1057
+ releaseDigest: release.releaseDigest,
1058
+ label,
1059
+ prerelease: pre !== null,
1060
+ ...(pre ? { distTag: prepared.channel ?? pre.distTag } : {}),
1061
+ commit: release.commit,
1062
+ signature,
1063
+ provenance,
1064
+ warnings: [signatureWarning, gateWarning, warning, signingWarning, verifyWarning].filter((w) => w !== null),
1065
+ signing: prepared.signing ? { identity: prepared.signing.identity, signer: prepared.signing.signer.name } : null,
1066
+ ...(floating ? { floating } : {}),
1067
+ ...(verifySteps.length > 0 ? { verify: { steps: verifySteps, unstaged } } : {}),
1068
+ };
1069
+ const floatingLine = (f, done) => f.move ? ` floating tag ${f.name}: ${done ? "moved" : "moves"} to ${f.commit.slice(0, 12)} once every target has revealed` : ` floating tag ${f.name}: left where it is, since ${f.reason}`;
702
1070
  if (dryRun) {
703
1071
  const next = [sameWithYes(process.argv.slice(2))];
704
1072
  if (args.json) {
@@ -709,12 +1077,19 @@ export async function runReleasePublish(ctx) {
709
1077
  out("What would be published where:");
710
1078
  if (planned.length === 0)
711
1079
  out(" nothing: this member declares no publish target (release.publish in chant.config.ts)");
1080
+ if (floating)
1081
+ out(floatingLine(floating, false));
712
1082
  for (const p of planned) {
713
1083
  const earlier = p.progress === "revealed" ? " (published by an earlier run; skipped)" : p.progress === "staged" ? " (staged by an earlier run; only revealed)" : "";
714
- out(` ${p.name}${provenance.oidc && p.kind === "npm" ? ", with --provenance" : ""}${earlier}:`);
1084
+ out(` ${p.name}${provenance.oidc && p.kind === "npm" ? ", with --provenance" : ""}${p.revealsLast ? ", revealed after every other target" : ""}${earlier}:`);
715
1085
  for (const i of p.items)
716
1086
  out(` ${describeItem(i)}`);
717
1087
  }
1088
+ if (verifySteps.length > 0) {
1089
+ out(" verify, after every target has staged and before any reveals (release.verify):");
1090
+ for (const v of verifySteps)
1091
+ out(` ${v.name === v.run ? v.run : `${v.name}: ${v.run}`}`);
1092
+ }
718
1093
  say(`Dry run: nothing was published. Run again with --yes to publish: ${next[0]}`);
719
1094
  const hint = planned.length === 0 ? promoteHint() : null;
720
1095
  if (hint)
@@ -725,24 +1100,36 @@ export async function runReleasePublish(ctx) {
725
1100
  say(" every target stages first, and none is visible until all have staged");
726
1101
  let run;
727
1102
  try {
728
- run = await runPublish({ cwd, release, label, targets, ctx: pctx, say: (line) => (args.json ? undefined : say(line)) });
1103
+ run = await runPublish({ cwd, release, label, targets, ctx: pctx, verify: verifySteps, say: (line) => (args.json ? undefined : say(line)) });
729
1104
  }
730
1105
  catch (err) {
731
1106
  if (err instanceof PublishRunError) {
732
1107
  const again = sameWithYes(process.argv.slice(2));
733
- const where = err.step === "stage"
1108
+ const where = err.step !== "reveal" && err.revealed.length === 0
734
1109
  ? `nothing is visible yet${err.staged.length > 0 ? `; staged: ${err.staged.join(", ")}` : ""}`
735
- : `revealed: ${err.revealed.length > 0 ? err.revealed.join(", ") : "none"}; staged and not yet revealed: ${err.staged.filter((t) => !err.revealed.includes(t)).join(", ")}`;
1110
+ : `revealed: ${err.revealed.length > 0 ? err.revealed.join(", ") : "none"}; staged and not yet revealed: ${err.staged.filter((t) => !err.revealed.includes(t)).join(", ") || "none"}`;
1111
+ if (args.json)
1112
+ console.log(redactor.redact(JSON.stringify({ dryRun: false, ...base, status: "failed", code: err.code, step: err.step, staged: err.staged, revealed: err.revealed }, null, 2)));
736
1113
  return failed(err.code, `${err.message}; ${where}`, `${err.fix ? `${err.fix} ` : ""}Run the same command again to resume; what went out is not published again: ${again}`);
737
1114
  }
738
1115
  const e = errorOf(err);
739
1116
  return failed(e.code, e.message, e.fix);
740
1117
  }
741
1118
  const { published } = run;
1119
+ // #5150: the floating tag moves only once every target has revealed; a target that refused with a warning leaves it.
1120
+ let floatingWarning = null;
1121
+ if (floating?.move) {
1122
+ if (published.some((p) => p.warning))
1123
+ floatingWarning = `the floating tag ${floating.name} was not moved, since a target refused the release`;
1124
+ else
1125
+ floatingWarning = (await import("../../lifecycle/release-publish.js")).moveFloatingTag(cwd, floating);
1126
+ }
1127
+ if (floatingWarning)
1128
+ console.error(formatWarning({ message: floatingWarning }));
742
1129
  if (run.recordWarning && targets.length > 0)
743
1130
  console.error(formatWarning({ message: redactor.redact(`${run.recordWarning}. A resume asks the registries what is already there.`) }));
744
1131
  if (args.json) {
745
- console.log(redactor.redact(JSON.stringify({ dryRun: false, ...base, targets: planned, published, resumed: run.resumed, environments: deploySteps }, null, 2)));
1132
+ console.log(redactor.redact(JSON.stringify({ dryRun: false, ...base, targets: planned, published, resumed: run.resumed, ...(run.verify ? { verified: run.verify } : {}), environments: deploySteps, ...(floating ? { floatingMoved: floating.move && floatingWarning === null } : {}) }, null, 2)));
746
1133
  return 0;
747
1134
  }
748
1135
  if (targets.length === 0) {
@@ -758,11 +1145,21 @@ export async function runReleasePublish(ctx) {
758
1145
  const refused = published.filter((p) => p.warning);
759
1146
  console.error(formatSuccess(`Published ${name} to ${published.length - refused.length} target(s)${refused.length > 0 ? `; ${refused.length} refused it, with a warning` : ""}`));
760
1147
  }
1148
+ if (floating && !floatingWarning)
1149
+ say(floatingLine(floating, true));
761
1150
  return 0;
762
1151
  }
763
1152
  /** One item a target publishes, for a line: what, where, and the SBOM or attachment it is (#4049). */
764
1153
  function describeItem(i) {
765
- const what = i.attachment === "sbom" ? `${i.name} (SBOM)` : i.attachment === "provenance" ? `${i.name} (provenance)` : i.name;
1154
+ const what = i.attachment === "sbom"
1155
+ ? `${i.name} (SBOM)`
1156
+ : i.attachment === "provenance"
1157
+ ? `${i.name} (provenance)`
1158
+ : i.attachment === "signature"
1159
+ ? `${i.name} (Sigstore signature)`
1160
+ : i.attachment === "attestation"
1161
+ ? `${i.name} (SLSA provenance, Sigstore)`
1162
+ : i.name;
766
1163
  if (i.notes !== undefined)
767
1164
  return `${i.name} to ${i.destination}:\n${i.notes.trimEnd().split("\n").map((l) => ` ${l}`.trimEnd()).join("\n")}`;
768
1165
  return `${what} to ${i.destination}${i.sbom ? `, carrying ${i.sbom}` : ""}`;
@@ -780,7 +1177,7 @@ export async function runReleaseVerify(ctx) {
780
1177
  console.error(formatError({ message: "release verify needs a release", hint: USAGE }));
781
1178
  return 1;
782
1179
  }
783
- const { verifyRelease, verificationCode } = await import("../../lifecycle/release-verify.js");
1180
+ const { verifyRelease, verificationCode, verifySigstore, recordedSignatures } = await import("../../lifecycle/release-verify.js");
784
1181
  const result = await verifyRelease({ cwd: resolve("."), ref });
785
1182
  if ("error" in result) {
786
1183
  if (args.json)
@@ -796,22 +1193,43 @@ export async function runReleaseVerify(ctx) {
796
1193
  code = "release-pin-unknown";
797
1194
  result.reason = pins;
798
1195
  }
1196
+ // #5164: --sigstore checks the bundles the publish recorded; without it, verify stays offline and says how many there are.
1197
+ const sigstore = args.sigstore ? await verifySigstore({ cwd: resolve("."), releaseDigest: result.releaseDigest, ...(args.assets ? { assetsDir: args.assets } : {}) }) : null;
1198
+ const recorded = sigstore ? sigstore.checks.length : (await recordedSignatures(resolve("."), result.releaseDigest)).length;
1199
+ if (!code && sigstore && sigstore.status !== "verified") {
1200
+ code = sigstore.status === "none" ? "release-sigstore-unsigned" : "release-sigstore-unverified";
1201
+ result.reason = sigstore.reason;
1202
+ }
799
1203
  if (args.json) {
800
- console.log(JSON.stringify({ ...result, ...(code ? { error: { code, message: result.reason } } : {}) }, null, 2));
1204
+ console.log(JSON.stringify({ ...result, ...(sigstore ? { sigstore } : { sigstore: { recorded } }), ...(code ? { error: { code, message: result.reason } } : {}) }, null, 2));
801
1205
  return code ? 1 : 0;
802
1206
  }
803
1207
  const name = result.label ? `${formatBold(result.label)} (${result.releaseDigest})` : result.releaseDigest;
804
1208
  for (const c of result.cuts) {
805
1209
  console.log(` cut by ${c.actor} at ${c.timestamp}: ${c.signatureCheck.status}${c.signatureCheck.key ? ` (${c.signatureCheck.key})` : ""}`);
1210
+ // #5149: what let the commit be cut; #5177: whether the cut's signature covers it.
1211
+ console.log(` ${c.override ? `not green: cut under the override by ${c.override.by}: ${c.override.reason}` : describeGreen(c.green)} (gate ${c.signatureCheck.status === "verified" ? c.signatureCheck.gate : "unsigned"})`);
806
1212
  }
1213
+ for (const c of sigstore?.checks ?? [])
1214
+ console.log(` ${c.name} (${c.target}): ${c.status}, ${c.reason}`);
1215
+ if (!sigstore && recorded > 0)
1216
+ console.error(` the publish recorded ${recorded} Sigstore signature(s); check them with: chant release verify ${result.label ?? result.releaseDigest} --sigstore`);
807
1217
  if (code) {
808
1218
  console.error(formatError({
809
1219
  message: `${name} does not verify: ${result.reason} [${code}]`,
810
- hint: code === "release-digest-mismatch" ? "Do not publish or deploy it; cut the release again." : code === "release-pin-unknown" ? "Build the package from the digests the release records: chant release images <label>, then the build with CHANT_RELEASE_DIGESTS set." : `Cut it again signed with a key ${result.signers.path} lists: chant release cut ${result.label ?? "<label>"} --sign --yes`,
1220
+ hint: code === "release-digest-mismatch"
1221
+ ? "Do not publish or deploy it; cut the release again."
1222
+ : code === "release-sigstore-unsigned"
1223
+ ? "Publish it from CI with release.signing on, or drop --sigstore."
1224
+ : code === "release-sigstore-unverified"
1225
+ ? "Download the release's assets into a directory and pass it as --assets; install cosign 3 or set CHANT_COSIGN; a bundle that failed was not signed by the identity shown."
1226
+ : code === "release-pin-unknown" ? "Build the package from the digests the release records: chant release images <label>, then the build with CHANT_RELEASE_DIGESTS set." : `Cut it again signed with a key ${result.signers.path} lists: chant release cut ${result.label ?? "<label>"} --sign --yes`,
811
1227
  }));
812
1228
  return 1;
813
1229
  }
814
- console.error(formatSuccess(`Verified ${name}: ${result.reason}`));
1230
+ console.error(formatSuccess(`Verified ${name}: ${result.reason}; green gate ${result.gate.status}${sigstore ? `; ${sigstore.reason}` : ""}`));
1231
+ if (result.gate.status === "unsigned")
1232
+ console.error(` ${result.gate.reason}`);
815
1233
  return 0;
816
1234
  }
817
1235
  /** The first package built here that pins an image digest release `digest` does not record (#4657), said in a sentence, or null. */
@@ -890,6 +1308,91 @@ export async function runReleaseCandidates(ctx) {
890
1308
  console.error(`Cut one: chant release cut <label> --at <sha>${doc.lane !== null && ctx.args.lane !== undefined ? ` --lane ${doc.lane}` : ""}`);
891
1309
  return 0;
892
1310
  }
1311
+ /**
1312
+ * `release next [--at <sha>] [--pre <id>] [--json]` (#5159): the label the
1313
+ * next release of this member carries, from the conventional commits and
1314
+ * the intent files since its previous release. The label alone goes to
1315
+ * stdout, so a script can read it; why goes to stderr.
1316
+ */
1317
+ export async function runReleaseNext(ctx) {
1318
+ const { args } = ctx;
1319
+ const cwd = resolve(".");
1320
+ const rn = await import("../../lifecycle/release-next.js");
1321
+ const { fetchLifecycle } = await import("../../lifecycle/git.js");
1322
+ await fetchLifecycle({ cwd }).catch(() => false);
1323
+ let doc;
1324
+ try {
1325
+ doc = await rn.nextRelease({ cwd, ...(args.at ? { at: args.at } : {}), ...(args.pre !== undefined ? { pre: args.pre } : {}) });
1326
+ }
1327
+ catch (err) {
1328
+ if (!(err instanceof rn.ReleaseNextError))
1329
+ throw err;
1330
+ if (args.json)
1331
+ console.log(JSON.stringify({ error: { code: err.code, message: err.message, ...(err.fix ? { fix: err.fix } : {}) } }, null, 2));
1332
+ else
1333
+ console.error(formatError({ message: `${err.message} [${err.code}]`, ...(err.fix ? { hint: err.fix } : {}) }));
1334
+ return 1;
1335
+ }
1336
+ let tag = null;
1337
+ try {
1338
+ const t = await import("../../lifecycle/release-tag.js");
1339
+ const tags = await t.memberTags(cwd);
1340
+ tag = t.renderReleaseTag(tags.template, tags.place, doc.label);
1341
+ }
1342
+ catch {
1343
+ tag = null;
1344
+ }
1345
+ if (args.json) {
1346
+ console.log(JSON.stringify({ ...doc, tag }, null, 2));
1347
+ return 0;
1348
+ }
1349
+ console.log(doc.label);
1350
+ if (doc.alreadyCut) {
1351
+ console.error(` ${doc.at.slice(0, 12)} is already released as ${doc.label}`);
1352
+ return 0;
1353
+ }
1354
+ const n = doc.commits.length;
1355
+ console.error(` ${doc.bump ?? "the prerelease's version"} from ${doc.from.label} (${doc.from.source === "tag" ? `the tag ${doc.from.tag}, ` : ""}${doc.from.commit.slice(0, 12)}): ${n} commit${n === 1 ? "" : "s"}${doc.intents.length > 0 ? `, ${doc.intents.length} intent file${doc.intents.length === 1 ? "" : "s"}` : ""}`);
1356
+ for (const c of doc.commits.filter((c) => c.bump !== "patch"))
1357
+ console.error(` ${c.bump} ${c.sha.slice(0, 7)} ${c.subject}`);
1358
+ for (const i of doc.intents)
1359
+ console.error(` ${i.bump} ${i.path}`);
1360
+ if (tag)
1361
+ console.error(` tag ${tag}`);
1362
+ return 0;
1363
+ }
1364
+ /**
1365
+ * `release changed [--at <sha>] [--bump-member <member>=<level>]... [--json]`
1366
+ * (#5134): the members a release at a commit has to cut, in publish order,
1367
+ * each with why. `--json` prints the read contract's `release-changed` document.
1368
+ */
1369
+ export async function runReleaseChanged(ctx) {
1370
+ const { releaseChangedDocument } = await import("../../workspace/release-changed.js");
1371
+ const doc = await releaseChangedDocument({
1372
+ cwd: resolve("."),
1373
+ ...(ctx.args.at ? { at: ctx.args.at } : {}),
1374
+ ...(ctx.args.bumpMember ? { bump: ctx.args.bumpMember } : {}),
1375
+ });
1376
+ if (ctx.args.json) {
1377
+ console.log(JSON.stringify(doc, null, 2));
1378
+ return "error" in doc ? 1 : 0;
1379
+ }
1380
+ if ("error" in doc) {
1381
+ console.error(formatError({ message: `${doc.error.message} [${doc.error.code}]`, hint: USAGE }));
1382
+ return 1;
1383
+ }
1384
+ if (doc.members.length === 0) {
1385
+ console.log(`Nothing to release at ${doc.at.slice(0, 12)}.`);
1386
+ return 0;
1387
+ }
1388
+ for (const m of doc.members) {
1389
+ const why = m.reason.member !== null ? `${m.reason.code} ${m.reason.member}` : m.reason.code;
1390
+ const label = m.next !== null ? `${m.last?.label ?? "?"} -> ${m.next}` : "no release yet";
1391
+ const from = m.next !== null && m.bumpFrom !== "flag" ? `; ${m.bump} from ${m.bumpFrom === "default" ? "no feat or breaking commit" : m.bumpFrom}` : "";
1392
+ console.log(`layer ${m.layer} ${m.member} ${label} (${why}${from})`);
1393
+ }
1394
+ return 0;
1395
+ }
893
1396
  export async function runReleaseList(ctx) {
894
1397
  const { releasesDocument } = await import("../../workspace/releases.js");
895
1398
  const doc = await releasesDocument({ cwd: resolve(".") });
@@ -907,8 +1410,12 @@ export async function runReleaseList(ctx) {
907
1410
  console.error("No releases. Cut one from a green commit: chant release cut <label>");
908
1411
  return 0;
909
1412
  }
1413
+ // #5163: a deprecated or yanked release says so at the end of its line.
1414
+ const { readReleaseStatus, latestReleaseStatus } = await import("../../lifecycle/release-status.js");
1415
+ const statuses = new Map([...latestReleaseStatus((await readReleaseStatus("_releases", { cwd: resolve(".") }).catch(() => ({ records: [] }))).records).values()].map((r) => [r.digest, r]));
910
1416
  for (const r of doc.releases) {
911
1417
  const where = r.environments.map((e) => e.env).join(", ") || "not deployed from the release";
1418
+ const status = statuses.get(r.releaseDigest);
912
1419
  // #4031: the newest cut's signature, as the policy at base judges it.
913
1420
  const newest = r.cuts.at(-1);
914
1421
  const signature = newest ? (newest.signatureCheck.status === "verified" ? `signed by ${newest.actor}` : newest.signatureCheck.status) : "-";
@@ -916,7 +1423,9 @@ export async function runReleaseList(ctx) {
916
1423
  // #4692: a release cut from a lane's green tag names the lane.
917
1424
  const lane = r.cuts.find((c) => c.lane !== undefined)?.lane;
918
1425
  const overridden = r.cuts.some((c) => c.override !== undefined);
919
- console.log(`${(r.label ?? "-").padEnd(16)} ${r.releaseDigest} ${r.commit.slice(0, 12)} ${signature} ${where}${lane !== undefined ? ` lane ${lane}` : ""}${overridden ? " not green" : ""}${r.revoked ? " revoked" : ""}`);
1426
+ console.log(`${(r.label ?? "-").padEnd(16)} ${r.releaseDigest} ${r.commit.slice(0, 12)} ${signature} ${where}${lane !== undefined ? ` lane ${lane}` : ""}${overridden ? " not green" : ""}${r.revoked ? " revoked" : ""}${status && status.status !== "active" ? ` ${status.status}` : ""}`);
1427
+ if (status && status.status !== "active")
1428
+ console.error(` ${r.label ?? r.releaseDigest}: ${status.status} by ${status.actor} at ${status.timestamp}${status.reason ? `: ${status.reason}` : ""}${status.replacement ? `; use ${status.replacement}` : ""}`);
920
1429
  if (newest?.signatureCheck.status === "unverified")
921
1430
  console.error(` ${r.label ?? r.releaseDigest}: ${newest.signatureCheck.reason}`);
922
1431
  // #4693: a release cut under an override says the commit was not green.
@@ -930,6 +1439,155 @@ export async function runReleaseList(ctx) {
930
1439
  }
931
1440
  return 0;
932
1441
  }
1442
+ /**
1443
+ * `release deprecate|yank|restore <label|digest> [--yes] ...` (#5163): plan
1444
+ * the status change and what each publish target does about it, print it,
1445
+ * and with `--yes` write the status record and act, resumably. A target that
1446
+ * can't do something says so with a code, as a warning, and the rest go on.
1447
+ */
1448
+ export async function runReleaseStatusChange(ctx, verb) {
1449
+ const { args } = ctx;
1450
+ const ref = args.extraPositional;
1451
+ const fail = (code, message, fix) => {
1452
+ if (args.json)
1453
+ console.log(JSON.stringify({ ref: ref ?? null, error: { code, message, ...(fix ? { fix } : {}) } }, null, 2));
1454
+ else
1455
+ console.error(formatError({ message: `${message} [${code}]`, ...(fix ? { hint: fix } : {}) }));
1456
+ return 1;
1457
+ };
1458
+ if (!ref)
1459
+ return fail("release-not-named", `release ${verb} needs a release, by label or digest`, USAGE);
1460
+ if (args.forgeRelease !== undefined && verb !== "yank")
1461
+ return fail("release-status-flag-invalid", `--forge-release says how a yank leaves the forge release, and release ${verb} is not a yank`);
1462
+ if (args.replacement !== undefined && verb === "restore")
1463
+ return fail("release-status-flag-invalid", "--replacement names the release to use instead of a deprecated or yanked one, and a restore sets neither");
1464
+ const cwd = resolve(".");
1465
+ const dryRun = args.yes !== true;
1466
+ const { fetchLifecycle } = await import("../../lifecycle/git.js");
1467
+ await fetchLifecycle({ cwd }).catch(() => false);
1468
+ // The actor, as a cut finds it: --actor, the signer of --sign's key, the CI's actor, git, $USER.
1469
+ const ws = await import("../../lifecycle/release-workstation.js");
1470
+ const { scopeSource } = await import("../../workspace/write-scope.js");
1471
+ const { releaseRuleFrom } = await import("../../workspace/identity.js");
1472
+ let publicKey = null;
1473
+ if (args.sign !== undefined) {
1474
+ const { resolveSigningKey, SealError } = await import("../../workspace/trust/seal.js");
1475
+ try {
1476
+ const key = resolveSigningKey(args.sign, cwd);
1477
+ try {
1478
+ if (!existsSync(key.file))
1479
+ return fail("release-signer-refused", `nothing was changed: the signing key ${key.file} does not exist`);
1480
+ publicKey = ws.publicKeyOf(key.file);
1481
+ }
1482
+ finally {
1483
+ key.cleanup();
1484
+ }
1485
+ }
1486
+ catch (err) {
1487
+ if (!(err instanceof SealError))
1488
+ throw err;
1489
+ return fail("release-signer-refused", `nothing was changed: ${err.message}`);
1490
+ }
1491
+ }
1492
+ const who = ws.resolveCutActor({ cwd, ...(args.actor ? { explicit: args.actor } : {}), publicKey, signers: releaseRuleFrom(scopeSource(cwd)).rule.signers.signers });
1493
+ if (!who)
1494
+ return fail("release-actor-unknown", "nothing was changed: no actor could be found", "Pass --actor explicitly, or set git's user.email, GITHUB_ACTOR, GITLAB_USER_LOGIN or USER.");
1495
+ const { prepareStatusChange, runStatusChange, StatusRunError } = await import("../../lifecycle/release-status-change.js");
1496
+ const { PublishTargetError } = await import("../../lifecycle/release-publish.js");
1497
+ let plan;
1498
+ try {
1499
+ plan = await prepareStatusChange({
1500
+ cwd,
1501
+ ref,
1502
+ verb,
1503
+ actor: who.actor,
1504
+ ...(args.reason !== undefined ? { reason: args.reason } : {}),
1505
+ ...(args.replacement !== undefined ? { replacement: args.replacement } : {}),
1506
+ ...(args.forgeRelease !== undefined ? { forgeYank: args.forgeRelease } : {}),
1507
+ sign: args.sign !== undefined,
1508
+ log: (line) => (args.json ? undefined : console.error(` ${line}`)),
1509
+ });
1510
+ }
1511
+ catch (err) {
1512
+ if (err instanceof PublishTargetError)
1513
+ return fail(err.code, err.message, err.fix);
1514
+ throw err;
1515
+ }
1516
+ if ("refusal" in plan)
1517
+ return fail(plan.refusal.code, plan.refusal.message, plan.refusal.fix);
1518
+ const name = plan.label ?? plan.release.releaseDigest;
1519
+ const say = (line) => console.error(plan.redactor.redact(line));
1520
+ const refusals = (actions) => actions.filter((a) => a.refused);
1521
+ const describe = (a) => (a.refused ? `refused: ${a.what}: ${a.refused.message} [${a.refused.code}]${a.refused.fix ? ` ${a.refused.fix}` : ""}` : a.already ? `already so: ${a.what}` : a.what);
1522
+ const base = {
1523
+ verb,
1524
+ status: plan.status,
1525
+ releaseDigest: plan.release.releaseDigest,
1526
+ label: plan.label,
1527
+ actor: plan.actor,
1528
+ reason: plan.reason,
1529
+ replacement: plan.replacement,
1530
+ current: plan.current.status,
1531
+ resumes: plan.resumes !== null,
1532
+ undeclared: plan.undeclared,
1533
+ };
1534
+ const targetsDoc = plan.targets.map((t) => ({ kind: t.kind, name: t.name, destination: t.destination, ...(t.skip ? { skip: t.skip } : {}), done: t.done, head: t.head ? { releaseDigest: t.head.releaseDigest, label: t.head.label } : null, actions: t.actions }));
1535
+ if (dryRun) {
1536
+ const next = [sameWithYes(process.argv.slice(2))];
1537
+ if (args.json) {
1538
+ console.log(plan.redactor.redact(JSON.stringify({ dryRun: true, ...base, targets: targetsDoc, next }, null, 2)));
1539
+ return 0;
1540
+ }
1541
+ const out = (line) => console.log(plan.redactor.redact(line));
1542
+ say(`Dry run: ${verb} ${formatBold(name)} (${plan.release.releaseDigest}), now ${plan.current.status}${plan.resumes ? `; resumes the change ${plan.resumes.actor} recorded at ${plan.resumes.timestamp}` : ""}`);
1543
+ out(`The status record: ${plan.status}${plan.reason ? `, because ${plan.reason}` : ""}${plan.replacement ? `, use ${plan.replacement}` : ""}, by ${plan.actor}${plan.signed ? ", signed" : ""}`);
1544
+ out("What each target would do:");
1545
+ if (plan.targets.length === 0)
1546
+ out(" nothing: this member declares no publish target (release.publish in chant.config.ts)");
1547
+ for (const t of plan.targets) {
1548
+ if (t.skip) {
1549
+ out(` ${t.name}: nothing, ${t.skip}`);
1550
+ continue;
1551
+ }
1552
+ out(` ${t.name}${t.done ? " (done by an earlier run; skipped)" : ""}:`);
1553
+ for (const a of t.actions)
1554
+ out(` ${describe(a)}`);
1555
+ }
1556
+ for (const u of plan.undeclared)
1557
+ say(formatWarning({ message: `${name} was published to ${u}, which release.publish no longer declares, so it is not changed there` }));
1558
+ say(`Dry run: nothing was changed. Run again with --yes: ${next[0]}`);
1559
+ return 0;
1560
+ }
1561
+ let run;
1562
+ try {
1563
+ run = await runStatusChange(plan, { cwd, ...(args.sign !== undefined ? { sign: args.sign } : {}), say: (line) => (args.json ? undefined : say(line)) });
1564
+ }
1565
+ catch (err) {
1566
+ if (err instanceof StatusRunError) {
1567
+ return fail(err.code, `${err.message}; done: ${err.done.length > 0 ? err.done.join(", ") : "none"}`, `${err.fix ? `${err.fix} ` : ""}Run the same command again to resume; a target already done is skipped: ${sameWithYes(process.argv.slice(2))}`);
1568
+ }
1569
+ if (err instanceof PublishTargetError)
1570
+ return fail(err.code, err.message, err.fix);
1571
+ throw err;
1572
+ }
1573
+ if (run.recordWarning)
1574
+ console.error(formatWarning({ message: plan.redactor.redact(run.recordWarning) }));
1575
+ const refused = run.results.flatMap((r) => refusals(r.actions).map((a) => ({ target: r.name, ...a })));
1576
+ if (args.json) {
1577
+ console.log(plan.redactor.redact(JSON.stringify({ dryRun: false, ...base, record: run.record, written: run.written, targets: targetsDoc, results: run.results }, null, 2)));
1578
+ return 0;
1579
+ }
1580
+ for (const r of run.results)
1581
+ for (const a of r.actions)
1582
+ if (!a.refused)
1583
+ say(` ${r.name}: ${describe(a)}`);
1584
+ for (const a of refused)
1585
+ console.error(formatWarning({ message: plan.redactor.redact(`${a.target}: ${describe(a)}`) }));
1586
+ for (const u of plan.undeclared)
1587
+ console.error(formatWarning({ message: `${name} was published to ${u}, which release.publish no longer declares, so it was not changed there` }));
1588
+ console.error(formatSuccess(`${name} is ${plan.status}${run.written ? "" : " (the change recorded earlier, resumed)"}; ${run.results.length} target(s) acted on${refused.length > 0 ? `, ${refused.length} action(s) refused` : ""}`));
1589
+ return 0;
1590
+ }
933
1591
  /**
934
1592
  * `release export <label|digest> --env <env> [-o <dir>]` (#4046): write each
935
1593
  * file the release's target for <env> records, at the path it was compiled to,