@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
@@ -0,0 +1,206 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://intentius.io/chant/schemas/workspace/release-changed/v1/release-changed.schema.json",
4
+ "title": "chant release changed output",
5
+ "description": "What `chant release changed --json` prints (#5134): the members of a workspace of separately released members that a release at a commit has to cut, in publish order, each with why. A member is `paths-changed` when paths changed since its last release (minus `changes.ignore` and generated files) or it has none; the closure adds each changed dependency of a member (`needed-by`) and each dependent whose last published range does not admit a member's next label (`range-broken-by`). It reads local refs and tags and never fetches. Version 1 of the read contract. Readers ignore fields they do not know; a field is only ever added within a version. The codes are a closed list, each in the one closed list of `reason-codes.ts`. Contract version 1 of this document is written by chant 0.124.100 and newer.",
6
+ "oneOf": [
7
+ {
8
+ "$ref": "#/$defs/result"
9
+ },
10
+ {
11
+ "$ref": "#/$defs/failure"
12
+ }
13
+ ],
14
+ "$defs": {
15
+ "result": {
16
+ "type": "object",
17
+ "required": [
18
+ "$schema",
19
+ "contract",
20
+ "chant",
21
+ "at",
22
+ "members"
23
+ ],
24
+ "properties": {
25
+ "$schema": {
26
+ "const": "https://intentius.io/chant/schemas/workspace/release-changed/v1/release-changed.schema.json"
27
+ },
28
+ "contract": {
29
+ "const": 1
30
+ },
31
+ "chant": {
32
+ "type": "string"
33
+ },
34
+ "error": false,
35
+ "at": {
36
+ "type": "string",
37
+ "description": "The full sha the read was made at."
38
+ },
39
+ "members": {
40
+ "type": "array",
41
+ "description": "In publish order: layer, then name.",
42
+ "items": {
43
+ "$ref": "#/$defs/member"
44
+ }
45
+ }
46
+ }
47
+ },
48
+ "failure": {
49
+ "type": "object",
50
+ "required": [
51
+ "$schema",
52
+ "contract",
53
+ "chant",
54
+ "error"
55
+ ],
56
+ "properties": {
57
+ "$schema": {
58
+ "const": "https://intentius.io/chant/schemas/workspace/release-changed/v1/release-changed.schema.json"
59
+ },
60
+ "contract": {
61
+ "const": 1
62
+ },
63
+ "chant": {
64
+ "type": "string"
65
+ },
66
+ "error": {
67
+ "type": "object",
68
+ "required": [
69
+ "code",
70
+ "message"
71
+ ],
72
+ "properties": {
73
+ "code": {
74
+ "enum": [
75
+ "not-a-git-repository",
76
+ "declaration-missing",
77
+ "revision-unknown",
78
+ "bump-invalid",
79
+ "ledger-unreadable",
80
+ "intent-invalid"
81
+ ]
82
+ },
83
+ "message": {
84
+ "type": "string"
85
+ }
86
+ }
87
+ }
88
+ },
89
+ "description": "Exit code 1."
90
+ },
91
+ "member": {
92
+ "type": "object",
93
+ "required": [
94
+ "member",
95
+ "layer",
96
+ "reason",
97
+ "last",
98
+ "bump",
99
+ "next",
100
+ "paths"
101
+ ],
102
+ "properties": {
103
+ "member": {
104
+ "type": "string"
105
+ },
106
+ "layer": {
107
+ "type": "integer",
108
+ "minimum": 0,
109
+ "description": "The dependency layer; members of one layer publish together, after every earlier layer."
110
+ },
111
+ "reason": {
112
+ "type": "object",
113
+ "required": [
114
+ "code",
115
+ "member"
116
+ ],
117
+ "properties": {
118
+ "code": {
119
+ "enum": [
120
+ "paths-changed",
121
+ "needed-by",
122
+ "range-broken-by",
123
+ "intent-pending"
124
+ ]
125
+ },
126
+ "member": {
127
+ "type": [
128
+ "string",
129
+ "null"
130
+ ],
131
+ "description": "The member that needs this one (`needed-by`) or whose next label breaks its range (`range-broken-by`); null for `paths-changed`."
132
+ }
133
+ }
134
+ },
135
+ "last": {
136
+ "type": [
137
+ "object",
138
+ "null"
139
+ ],
140
+ "description": "The member's last release, or null when it has none.",
141
+ "required": [
142
+ "label",
143
+ "commit",
144
+ "source"
145
+ ],
146
+ "properties": {
147
+ "label": {
148
+ "type": [
149
+ "string",
150
+ "null"
151
+ ]
152
+ },
153
+ "commit": {
154
+ "type": "string"
155
+ },
156
+ "source": {
157
+ "enum": [
158
+ "ledger",
159
+ "legacy"
160
+ ],
161
+ "description": "A cut in the member's ledger, or a legacy tag named by `release.legacyTags`."
162
+ }
163
+ }
164
+ },
165
+ "bump": {
166
+ "enum": [
167
+ "major",
168
+ "minor",
169
+ "patch"
170
+ ],
171
+ "description": "The bump applied to the last label: `--bump-member`, else patch."
172
+ },
173
+ "next": {
174
+ "type": [
175
+ "string",
176
+ "null"
177
+ ],
178
+ "description": "The label a release would carry, or null when there is no last label to bump."
179
+ },
180
+ "paths": {
181
+ "type": "array",
182
+ "items": {
183
+ "type": "string"
184
+ },
185
+ "description": "The changed paths that count, from the outermost workspace root. Empty for a member taken only by the closure."
186
+ },
187
+ "bumpFrom": {
188
+ "enum": [
189
+ "flag",
190
+ "commits",
191
+ "intents",
192
+ "default"
193
+ ],
194
+ "description": "Added within contract version 1 by #5159. Where bump came from: flag for --bump-member, commits or intents for the higher of the conventional commits over paths since the last release and the pending intent files (commits when they tie), default for a patch when neither gives one."
195
+ },
196
+ "intents": {
197
+ "type": "array",
198
+ "items": {
199
+ "type": "string"
200
+ },
201
+ "description": "Added within contract version 1 by #5159. The intent files under .chant/release/ that name the member and that no cut of it consumed, by path from the repository root."
202
+ }
203
+ }
204
+ }
205
+ }
206
+ }
@@ -0,0 +1,7 @@
1
+ import type { ReleaseWorkflowForge } from "../release-workflow.js";
2
+ import type { ReleaseWorkflowFeature } from "./types.js";
3
+ /** The workflow artifact the cut job hands the files `release.artifacts` built on in (#5151). */
4
+ export declare const RELEASE_ARTIFACTS_ARTIFACT = "chant-release-artifacts";
5
+ /** Where a job stages, and the publish job finds, the files the cut built (#5151): outside the checkout on GitHub and Forgejo; GitLab keeps job artifacts only inside the project directory, so its publish job moves them out first. */
6
+ export declare const RELEASE_ARTIFACTS_STAGE: Record<ReleaseWorkflowForge, string>;
7
+ export declare const artifactsFeature: ReleaseWorkflowFeature;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * `release.artifacts` (#5151). In a dispatched release the cut job stages the
3
+ * files it built (`chant release artifacts --no-build -o`) and hands them to
4
+ * the publish job as the workflow artifact {@link RELEASE_ARTIFACTS_ARTIFACT},
5
+ * which checks them against the record (`--from`) after its build. On a
6
+ * release tag the publish job builds them again and checks them.
7
+ */
8
+ import { ACTION_PINS, usesRef } from "../../action-pins.js";
9
+ /** The workflow artifact the cut job hands the files `release.artifacts` built on in (#5151). */
10
+ export const RELEASE_ARTIFACTS_ARTIFACT = "chant-release-artifacts";
11
+ /** Where a job stages, and the publish job finds, the files the cut built (#5151): outside the checkout on GitHub and Forgejo; GitLab keeps job artifacts only inside the project directory, so its publish job moves them out first. */
12
+ export const RELEASE_ARTIFACTS_STAGE = {
13
+ github: "$RUNNER_TEMP/chant-release-artifacts",
14
+ forgejo: "$RUNNER_TEMP/chant-release-artifacts",
15
+ gitlab: "$CI_PROJECT_DIR/.chant-release-artifacts",
16
+ };
17
+ export const artifactsFeature = {
18
+ name: "artifacts",
19
+ steps: (c) => {
20
+ if (!c.artifacts)
21
+ return [];
22
+ if (c.shape !== "dispatch")
23
+ return c.job === "publish" ? [{ slot: "beforeBuild", order: 20, items: [`${c.chant} release artifacts ${c.label}`] }] : [];
24
+ const gitlab = c.forge === "gitlab";
25
+ if (c.job === "cut") {
26
+ const stage = `${c.chant} release artifacts ${c.label} --no-build -o "${RELEASE_ARTIFACTS_STAGE[c.forge]}"`;
27
+ if (gitlab)
28
+ return [{ slot: "afterCut", order: 10, items: [stage] }, { slot: "artifactPaths", order: 20, items: [{ lines: [' - ".chant-release-artifacts/"'] }] }];
29
+ const upload = usesRef(c.forge === "forgejo" ? ACTION_PINS.uploadArtifact3 : ACTION_PINS.uploadArtifact4);
30
+ return [{ slot: "afterCut", order: 10, items: [stage, { lines: [` - uses: ${upload}`, " with:", ` name: ${RELEASE_ARTIFACTS_ARTIFACT}`, " path: ${{ runner.temp }}/chant-release-artifacts", " if-no-files-found: error", " retention-days: 1"] }] }];
31
+ }
32
+ if (gitlab) {
33
+ return [
34
+ // The staged files leave the checkout, which the publish finds as the cut left it.
35
+ { slot: "afterCheckout", order: 10, items: ['mv "$CI_PROJECT_DIR/.chant-release-artifacts" /tmp/chant-release-artifacts'] },
36
+ { slot: "afterBuild", order: 10, items: [`${c.chant} release artifacts ${c.label} --from /tmp/chant-release-artifacts`] },
37
+ ];
38
+ }
39
+ const download = usesRef(c.forge === "forgejo" ? ACTION_PINS.downloadArtifact3 : ACTION_PINS.downloadArtifact4);
40
+ return [
41
+ { slot: "beforeBuild", order: 20, items: [{ lines: [` - uses: ${download}`, " with:", ` name: ${RELEASE_ARTIFACTS_ARTIFACT}`, " path: ${{ runner.temp }}/chant-release-artifacts"] }] },
42
+ { slot: "afterBuild", order: 10, items: [`${c.chant} release artifacts ${c.label} --from "${RELEASE_ARTIFACTS_STAGE[c.forge]}"`] },
43
+ ];
44
+ },
45
+ };
@@ -0,0 +1,12 @@
1
+ import { type ReleaseBuildConfig } from "../release-toolchains.js";
2
+ import type { ReleaseWorkflowFeature } from "./types.js";
3
+ /** The shell line that packs a build job's outputs into its archive (#5152): tar keeps each file's path and mode, which an upload of the files would not. */
4
+ export declare function packLine(b: ReleaseBuildConfig): string;
5
+ /**
6
+ * The shell line that unpacks a build's archive into the project root (#5152).
7
+ * In the cut, `-k` refuses a file that is already there, so a build cannot
8
+ * replace a file of the commit, and two builds cannot write one path.
9
+ */
10
+ export declare function unpackLine(archive: string, cut: boolean): string;
11
+ /** The restore: in the cut before `release cut`, in the publish before the stamp. GitLab hands the archive into the project directory, so it is moved out after, and the publish finds the tree as the cut left it. */
12
+ export declare const buildsFeature: ReleaseWorkflowFeature;
@@ -0,0 +1,38 @@
1
+ /** `release.workflow.builds` (#5152): the cut and publish jobs unpack each build job's archive into the project root. */
2
+ import { ACTION_PINS, usesRef } from "../../action-pins.js";
3
+ import { releaseBuildArchive, releaseBuildArtifact } from "../release-toolchains.js";
4
+ /** The shell line that packs a build job's outputs into its archive (#5152): tar keeps each file's path and mode, which an upload of the files would not. */
5
+ export function packLine(b) {
6
+ return `tar -cf ${releaseBuildArchive(b.name)} -- ${b.outputs.join(" ")}`;
7
+ }
8
+ /**
9
+ * The shell line that unpacks a build's archive into the project root (#5152).
10
+ * In the cut, `-k` refuses a file that is already there, so a build cannot
11
+ * replace a file of the commit, and two builds cannot write one path.
12
+ */
13
+ export function unpackLine(archive, cut) {
14
+ return `tar -x${cut ? "k" : ""}f ${archive}`;
15
+ }
16
+ /** The restore: in the cut before `release cut`, in the publish before the stamp. GitLab hands the archive into the project directory, so it is moved out after, and the publish finds the tree as the cut left it. */
17
+ export const buildsFeature = {
18
+ name: "builds",
19
+ steps: (c) => {
20
+ if (c.shape !== "dispatch" || c.builds.length === 0)
21
+ return [];
22
+ const cut = c.job === "cut";
23
+ const items = c.forge === "gitlab"
24
+ ? c.builds.flatMap((b) => [unpackLine(releaseBuildArchive(b.name), cut), `mv ${releaseBuildArchive(b.name)} /tmp/`])
25
+ : [
26
+ {
27
+ lines: c.builds.flatMap((b) => [
28
+ ` - uses: ${usesRef(c.forge === "forgejo" ? ACTION_PINS.downloadArtifact3 : ACTION_PINS.downloadArtifact4)}`,
29
+ " with:",
30
+ ` name: ${releaseBuildArtifact(b.name)}`,
31
+ " path: ${{ runner.temp }}/chant-release-builds",
32
+ ` - run: ${unpackLine(`"$RUNNER_TEMP/chant-release-builds/${releaseBuildArchive(b.name)}"`, cut)}`,
33
+ ]),
34
+ },
35
+ ];
36
+ return [cut ? { slot: "beforeCut", order: 10, items } : { slot: "prepare", order: 27, items }];
37
+ },
38
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * `chant release doctor` (#5161) in the release workflow: in a dispatched
3
+ * release's cut job before the cut, unless `release.workflow.doctor` is
4
+ * false, and in a tag-triggered publish job before the build under
5
+ * `doctor: true`.
6
+ */
7
+ import type { ReleaseWorkflowFeature } from "./types.js";
8
+ export declare const doctorFeature: ReleaseWorkflowFeature;
@@ -0,0 +1,14 @@
1
+ export const doctorFeature = {
2
+ name: "doctor",
3
+ steps: (c) => {
4
+ if (!c.doctor)
5
+ return [];
6
+ const items = [`${c.chant} release doctor`];
7
+ if (c.shape !== "dispatch")
8
+ return c.job === "publish" ? [{ slot: "prepare", order: 10, items }] : [];
9
+ if (c.job !== "cut")
10
+ return [];
11
+ // GitLab's cut runs it after the fetches, with the forge-checks token exported.
12
+ return c.forge === "gitlab" ? [{ slot: "beforeCut", order: 30, items }] : [{ slot: "prepare", order: 10, items }];
13
+ },
14
+ };
@@ -0,0 +1,16 @@
1
+ import type { ReleasePipelineConfig, ReleaseWorkflowForge } from "../release-workflow.js";
2
+ import { type ReleaseWorkflowFeature } from "./types.js";
3
+ /**
4
+ * What a job that builds goreleaser entries runs first (#5151): Go from the
5
+ * member's `go.mod` (GitHub and Forgejo, unless `release.workflow.setup`
6
+ * names `actions/setup-go`), then the pinned goreleaser, downloaded, checked
7
+ * by SHA-256 and named by `CHANT_GORELEASER`. A config that sets
8
+ * `CHANT_GORELEASER` in `release.workflow.env` gets no install. GitLab
9
+ * jobs run in the project's image, which brings its own Go.
10
+ */
11
+ export declare function goreleaserSetup(forge: ReleaseWorkflowForge, root: string | null, p: ReleasePipelineConfig): {
12
+ github: string[];
13
+ gitlab: string[];
14
+ };
15
+ /** In the job that builds the files: a dispatched release's cut, or a tag's publish. */
16
+ export declare const goreleaserFeature: ReleaseWorkflowFeature;
@@ -0,0 +1,36 @@
1
+ /** goreleaser for the `release.artifacts` entries it builds (#5151). */
2
+ import { ACTION_PINS, usesRef } from "../../action-pins.js";
3
+ import { TOOL_PINS, toolInstallLine } from "../../tool-pins.js";
4
+ import { RELEASE_RUNNER_PLATFORM } from "./types.js";
5
+ /**
6
+ * What a job that builds goreleaser entries runs first (#5151): Go from the
7
+ * member's `go.mod` (GitHub and Forgejo, unless `release.workflow.setup`
8
+ * names `actions/setup-go`), then the pinned goreleaser, downloaded, checked
9
+ * by SHA-256 and named by `CHANT_GORELEASER`. A config that sets
10
+ * `CHANT_GORELEASER` in `release.workflow.env` gets no install. GitLab
11
+ * jobs run in the project's image, which brings its own Go.
12
+ */
13
+ export function goreleaserSetup(forge, root, p) {
14
+ const install = p.env?.CHANT_GORELEASER === undefined;
15
+ if (forge === "gitlab") {
16
+ return { github: [], gitlab: install ? [`${toolInstallLine(TOOL_PINS.goreleaser, RELEASE_RUNNER_PLATFORM, "/tmp/goreleaser")} && export CHANT_GORELEASER=/tmp/goreleaser/goreleaser`] : [] };
17
+ }
18
+ const go = (p.setup ?? []).some((s) => "uses" in s && /^actions\/setup-go@/.test(s.uses))
19
+ ? []
20
+ : [` - uses: ${usesRef(ACTION_PINS.setupGo7)}`, " with:", ` go-version-file: ${root ? `${root}/` : ""}go.mod`];
21
+ const line = `${toolInstallLine(TOOL_PINS.goreleaser, RELEASE_RUNNER_PLATFORM, "$RUNNER_TEMP/goreleaser")} && echo "CHANT_GORELEASER=$RUNNER_TEMP/goreleaser/goreleaser" >> "$GITHUB_ENV"`;
22
+ return { github: [...go, ...(install ? [` - name: goreleaser ${TOOL_PINS.goreleaser.version}`, ` run: ${JSON.stringify(line)}`] : [])], gitlab: [] };
23
+ }
24
+ /** In the job that builds the files: a dispatched release's cut, or a tag's publish. */
25
+ export const goreleaserFeature = {
26
+ name: "goreleaser",
27
+ steps: (c) => {
28
+ if (!c.artifacts || c.input.goreleaser !== true)
29
+ return [];
30
+ if (c.job !== (c.shape === "dispatch" ? "cut" : "publish"))
31
+ return [];
32
+ const g = goreleaserSetup(c.forge, c.root, c.pipeline);
33
+ const items = c.forge !== "gitlab" ? [{ lines: g.github }] : c.shape === "dispatch" ? g.gitlab : [{ lines: g.gitlab.map((l) => ` - ${JSON.stringify(l)}`) }];
34
+ return [{ slot: "prepare", order: 20, items }];
35
+ },
36
+ };
@@ -0,0 +1,3 @@
1
+ /** `release.green: "forge-checks"` (#5149): GitLab's cut asks the forge for the commit's checks with the release token unless a token of its own is set. */
2
+ import type { ReleaseWorkflowFeature } from "./types.js";
3
+ export declare const greenFeature: ReleaseWorkflowFeature;
@@ -0,0 +1,6 @@
1
+ export const greenFeature = {
2
+ name: "green",
3
+ steps: (c) => c.green === "forge-checks" && c.shape === "dispatch" && c.job === "cut" && c.forge === "gitlab"
4
+ ? [{ slot: "beforeCut", order: 20, items: ['export CHANT_GITLAB_TOKEN="${CHANT_GITLAB_TOKEN:-$CHANT_RELEASE_TOKEN}"'] }]
5
+ : [],
6
+ };
@@ -0,0 +1,22 @@
1
+ import type { ReleaseWorkflowForge } from "../release-workflow.js";
2
+ import type { ReleaseWorkflowFeature } from "./types.js";
3
+ /** Where `chant release images` writes the digests the publish job's build reads (#4657), by default and at a workstation. */
4
+ export declare const RELEASE_DIGESTS_FILE = ".chant/release-digests.json";
5
+ /**
6
+ * Where a generated publish job writes the digests: the runner's temp
7
+ * directory, outside the checkout, so `chant release publish` finds the tree
8
+ * as the cut left it (#4853). A repository that commits files under `.chant/`
9
+ * can't ignore the directory, and a digests file there made the publish
10
+ * refuse with `release-worktree-dirty`.
11
+ */
12
+ export declare const RELEASE_DIGESTS_PATHS: Record<ReleaseWorkflowForge, string>;
13
+ /** The workflow artifact the cut job hands its image archives on in. */
14
+ export declare const RELEASE_IMAGES_ARTIFACT = "chant-release-images";
15
+ /**
16
+ * In a dispatched release the cut job hands the archives to the publish job,
17
+ * which checks them against the recorded digests (`release images
18
+ * --no-build`) rather than building them again, so a moved package mirror
19
+ * between the two jobs cannot change what is published. On a tag the publish
20
+ * job builds them again from the release.
21
+ */
22
+ export declare const imagesFeature: ReleaseWorkflowFeature;
@@ -0,0 +1,59 @@
1
+ /** `release.images` (#4657): the publish job builds the images again, or checks the archives the cut handed on, before its build. */
2
+ import { ACTION_PINS, usesRef } from "../../action-pins.js";
3
+ /** Where `chant release images` writes the digests the publish job's build reads (#4657), by default and at a workstation. */
4
+ export const RELEASE_DIGESTS_FILE = ".chant/release-digests.json";
5
+ /**
6
+ * Where a generated publish job writes the digests: the runner's temp
7
+ * directory, outside the checkout, so `chant release publish` finds the tree
8
+ * as the cut left it (#4853). A repository that commits files under `.chant/`
9
+ * can't ignore the directory, and a digests file there made the publish
10
+ * refuse with `release-worktree-dirty`.
11
+ */
12
+ export const RELEASE_DIGESTS_PATHS = {
13
+ github: "$RUNNER_TEMP/chant-release-digests.json",
14
+ forgejo: "$RUNNER_TEMP/chant-release-digests.json",
15
+ gitlab: "/tmp/chant-release-digests.json",
16
+ };
17
+ /** The workflow artifact the cut job hands its image archives on in. */
18
+ export const RELEASE_IMAGES_ARTIFACT = "chant-release-images";
19
+ /** The directory every path is under, which the artifact actions store the files relative to. */
20
+ function commonDir(paths) {
21
+ const dirs = paths.map((p) => p.split("/").slice(0, -1));
22
+ const first = dirs[0] ?? [];
23
+ let n = 0;
24
+ while (n < first.length && dirs.every((d) => d[n] === first[n]))
25
+ n++;
26
+ return first.slice(0, n).join("/") || ".";
27
+ }
28
+ /**
29
+ * In a dispatched release the cut job hands the archives to the publish job,
30
+ * which checks them against the recorded digests (`release images
31
+ * --no-build`) rather than building them again, so a moved package mirror
32
+ * between the two jobs cannot change what is published. On a tag the publish
33
+ * job builds them again from the release.
34
+ */
35
+ export const imagesFeature = {
36
+ name: "images",
37
+ steps: (c) => {
38
+ if (!c.images)
39
+ return [];
40
+ const gitlab = c.forge === "gitlab";
41
+ const handed = c.archives.length > 0;
42
+ if (c.job === "cut") {
43
+ if (!handed)
44
+ return [];
45
+ if (gitlab)
46
+ return [{ slot: "artifactPaths", order: 10, items: [{ lines: c.archives.map((a) => ` - ${JSON.stringify(a)}`) }] }];
47
+ const upload = usesRef(c.forge === "forgejo" ? ACTION_PINS.uploadArtifact3 : ACTION_PINS.uploadArtifact4);
48
+ const lines = [` - uses: ${upload}`, " with:", ` name: ${RELEASE_IMAGES_ARTIFACT}`, " path: |", ...c.archives.map((a) => ` ${a}`), " if-no-files-found: error", " retention-days: 1"];
49
+ return [{ slot: "afterCut", order: 20, items: [{ lines }] }];
50
+ }
51
+ const digests = RELEASE_DIGESTS_PATHS[c.forge];
52
+ const build = [`${c.chant} release images ${c.label}${handed ? " --no-build" : ""} -o "${digests}"`, gitlab ? `export CHANT_RELEASE_DIGESTS="${digests}"` : `echo "CHANT_RELEASE_DIGESTS=${digests}" >> "$GITHUB_ENV"`];
53
+ const download = usesRef(c.forge === "forgejo" ? ACTION_PINS.downloadArtifact3 : ACTION_PINS.downloadArtifact4);
54
+ return [
55
+ ...(handed && !gitlab ? [{ slot: "prepare", order: 24, items: [{ lines: [` - uses: ${download}`, " with:", ` name: ${RELEASE_IMAGES_ARTIFACT}`, ` path: ${commonDir(c.archives)}`] }] }] : []),
56
+ { slot: "beforeBuild", order: 10, items: build },
57
+ ];
58
+ },
59
+ };
@@ -0,0 +1,9 @@
1
+ import type { OpSetupStep } from "../../lexicon.js";
2
+ import type { ReleaseStepContext, ReleaseStepItem, ReleaseStepSlot, ReleaseWorkflowContext, ReleaseWorkflowFeature } from "./types.js";
3
+ export type * from "./types.js";
4
+ /** Every feature, alphabetically by file. */
5
+ export declare const RELEASE_WORKFLOW_FEATURES: readonly ReleaseWorkflowFeature[];
6
+ /** The setup steps of the cut and publish jobs: the features' and `release.workflow.setup` (order 20), lowest order first. */
7
+ export declare function releaseSetupSteps(c: ReleaseWorkflowContext, features?: readonly ReleaseWorkflowFeature[]): OpSetupStep[];
8
+ /** One job's steps by slot, each slot's in order (lowest first, ties in list order). */
9
+ export declare function releaseJobSteps(c: ReleaseStepContext, features?: readonly ReleaseWorkflowFeature[]): (slot: ReleaseStepSlot) => ReleaseStepItem[];
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The features of the release workflow (#5196), one file each. The frame in
3
+ * ../release-workflow.ts asks each for its setup steps and its steps in the
4
+ * cut and publish jobs; where they land is in the feature, so adding one adds
5
+ * a file here and a line to the list below, kept in alphabetical order.
6
+ */
7
+ import { artifactsFeature } from "./artifacts.js";
8
+ import { buildsFeature } from "./builds.js";
9
+ import { doctorFeature } from "./doctor.js";
10
+ import { goreleaserFeature } from "./goreleaser.js";
11
+ import { greenFeature } from "./green.js";
12
+ import { imagesFeature } from "./images.js";
13
+ import { pypiFeature } from "./pypi.js";
14
+ import { qemuFeature } from "./qemu.js";
15
+ import { signingFeature } from "./signing.js";
16
+ import { stampFeature } from "./stamp.js";
17
+ import { targetsFeature } from "./targets.js";
18
+ import { verifyFeature } from "./verify.js";
19
+ /** Every feature, alphabetically by file. */
20
+ export const RELEASE_WORKFLOW_FEATURES = [
21
+ artifactsFeature,
22
+ buildsFeature,
23
+ doctorFeature,
24
+ goreleaserFeature,
25
+ greenFeature,
26
+ imagesFeature,
27
+ pypiFeature,
28
+ qemuFeature,
29
+ signingFeature,
30
+ stampFeature,
31
+ targetsFeature,
32
+ verifyFeature,
33
+ ];
34
+ /** The setup steps of the cut and publish jobs: the features' and `release.workflow.setup` (order 20), lowest order first. */
35
+ export function releaseSetupSteps(c, features = RELEASE_WORKFLOW_FEATURES) {
36
+ const parts = [{ order: 20, steps: c.pipeline.setup ?? [] }, ...features.flatMap((f) => f.setup?.(c) ?? [])];
37
+ return parts.sort((a, b) => a.order - b.order).flatMap((p) => p.steps);
38
+ }
39
+ /** One job's steps by slot, each slot's in order (lowest first, ties in list order). */
40
+ export function releaseJobSteps(c, features = RELEASE_WORKFLOW_FEATURES) {
41
+ const placed = features.flatMap((f) => f.steps?.(c) ?? []);
42
+ return (slot) => placed
43
+ .filter((p) => p.slot === slot)
44
+ .sort((a, b) => a.order - b.order)
45
+ .flatMap((p) => p.items);
46
+ }
@@ -0,0 +1,15 @@
1
+ /** PyPI trusted publishing on GitLab: the ID token the `pypi` target reads. */
2
+ import type { ReleaseWorkflowTarget } from "../release-workflow.js";
3
+ import type { ReleaseWorkflowFeature } from "./types.js";
4
+ /**
5
+ * The audience of the `PYPI_ID_TOKEN` a GitLab publish job needs, or null
6
+ * when no `pypi` target uses trusted publishing: `pypi`, or `testpypi` for
7
+ * a target on TestPyPI. A target that sets `auth: "token"`, or another index
8
+ * with its own URLs, takes a token only. With `auth` unset the target uses
9
+ * trusted publishing when its token's variable is not set, which the
10
+ * generator can't see, so the job gets the token; declaring it costs nothing.
11
+ * The first such target names the audience.
12
+ */
13
+ export declare function pypiIdTokenAudience(targets: ReadonlyArray<ReleaseWorkflowTarget>): "pypi" | "testpypi" | null;
14
+ /** `PYPI_ID_TOKEN` in the GitLab publish job's `id_tokens`, beside `SIGSTORE_ID_TOKEN`. GitHub and Forgejo ask for the token at run time from `id-token: write`, which the job already has. */
15
+ export declare const pypiFeature: ReleaseWorkflowFeature;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The audience of the `PYPI_ID_TOKEN` a GitLab publish job needs, or null
3
+ * when no `pypi` target uses trusted publishing: `pypi`, or `testpypi` for
4
+ * a target on TestPyPI. A target that sets `auth: "token"`, or another index
5
+ * with its own URLs, takes a token only. With `auth` unset the target uses
6
+ * trusted publishing when its token's variable is not set, which the
7
+ * generator can't see, so the job gets the token; declaring it costs nothing.
8
+ * The first such target names the audience.
9
+ */
10
+ export function pypiIdTokenAudience(targets) {
11
+ const t = targets.find((x) => x.type === "pypi" && x.auth !== "token" && x.uploadUrl === undefined);
12
+ return t ? (t.index === "testpypi" ? "testpypi" : "pypi") : null;
13
+ }
14
+ /** `PYPI_ID_TOKEN` in the GitLab publish job's `id_tokens`, beside `SIGSTORE_ID_TOKEN`. GitHub and Forgejo ask for the token at run time from `id-token: write`, which the job already has. */
15
+ export const pypiFeature = {
16
+ name: "pypi",
17
+ steps: (c) => {
18
+ const aud = c.forge === "gitlab" && c.job === "publish" ? pypiIdTokenAudience(c.input.publish ?? []) : null;
19
+ return aud ? [{ slot: "idTokens", order: 10, items: [{ lines: [" PYPI_ID_TOKEN:", ` aud: ${aud}`] }] }] : [];
20
+ },
21
+ };
@@ -0,0 +1,21 @@
1
+ import type { OpSetupStep } from "../../lexicon.js";
2
+ import type { ReleasePipelineConfig, ReleaseWorkflowForge } from "../release-workflow.js";
3
+ import { type ReleaseWorkflowFeature } from "./types.js";
4
+ /** The binfmt image a GitLab job installs QEMU's handlers with (#4876): the repository, which a config's own setup line is recognised by. */
5
+ export declare const RELEASE_BINFMT_IMAGE: string;
6
+ /** The architectures among `platforms` the runner can't run, as QEMU names them (`linux/arm/v7` is `arm`), each once. */
7
+ export declare function qemuArchitectures(platforms: readonly string[]): string[];
8
+ /**
9
+ * QEMU's binfmt setup for the platforms `release.images` builds that the
10
+ * runner can't, such as `linux/arm64` on an amd64 runner (#4876), so no
11
+ * product names it in `release.workflow.setup`. GitHub and Forgejo get
12
+ * `docker/setup-qemu-action` at its pin; GitLab a `docker run --privileged`
13
+ * of {@link RELEASE_BINFMT_IMAGE} by the digest `IMAGE_PINS.binfmt` records
14
+ * (#4941, ../../image-pins.ts), which `chant release workflow` notes needs
15
+ * an executor that runs privileged containers. A config whose `setup` names
16
+ * the action or the binfmt image already gets nothing more, so its file
17
+ * renders as it did.
18
+ */
19
+ export declare function qemuSetup(forge: ReleaseWorkflowForge, platforms: readonly string[], p: ReleasePipelineConfig): OpSetupStep[];
20
+ /** Before the config's own setup, where the products named it. */
21
+ export declare const qemuFeature: ReleaseWorkflowFeature;
@@ -0,0 +1,35 @@
1
+ /** QEMU for the platforms `release.images` builds that the runner can't (#4876). */
2
+ import { ACTION_PINS, usesRef } from "../../action-pins.js";
3
+ import { IMAGE_PINS, imageRef } from "../../image-pins.js";
4
+ import { RELEASE_RUNNER_PLATFORM } from "./types.js";
5
+ /** The binfmt image a GitLab job installs QEMU's handlers with (#4876): the repository, which a config's own setup line is recognised by. */
6
+ export const RELEASE_BINFMT_IMAGE = IMAGE_PINS.binfmt.repository;
7
+ /** The architectures among `platforms` the runner can't run, as QEMU names them (`linux/arm/v7` is `arm`), each once. */
8
+ export function qemuArchitectures(platforms) {
9
+ return [...new Set(platforms.filter((p) => p.split("/").slice(0, 2).join("/") !== RELEASE_RUNNER_PLATFORM).map((p) => p.split("/")[1] ?? p))].sort();
10
+ }
11
+ /**
12
+ * QEMU's binfmt setup for the platforms `release.images` builds that the
13
+ * runner can't, such as `linux/arm64` on an amd64 runner (#4876), so no
14
+ * product names it in `release.workflow.setup`. GitHub and Forgejo get
15
+ * `docker/setup-qemu-action` at its pin; GitLab a `docker run --privileged`
16
+ * of {@link RELEASE_BINFMT_IMAGE} by the digest `IMAGE_PINS.binfmt` records
17
+ * (#4941, ../../image-pins.ts), which `chant release workflow` notes needs
18
+ * an executor that runs privileged containers. A config whose `setup` names
19
+ * the action or the binfmt image already gets nothing more, so its file
20
+ * renders as it did.
21
+ */
22
+ export function qemuSetup(forge, platforms, p) {
23
+ const archs = qemuArchitectures(platforms);
24
+ if (archs.length === 0)
25
+ return [];
26
+ const named = (p.setup ?? []).some((s) => ("uses" in s ? /^docker\/setup-qemu-action@/.test(s.uses) : s.run.includes(RELEASE_BINFMT_IMAGE)));
27
+ if (named)
28
+ return [];
29
+ return forge === "gitlab" ? [{ run: `docker run --privileged --rm ${imageRef(IMAGE_PINS.binfmt)} --install ${archs.join(",")}` }] : [{ uses: usesRef(ACTION_PINS.dockerSetupQemu4), with: { platforms: archs.join(",") } }];
30
+ }
31
+ /** Before the config's own setup, where the products named it. */
32
+ export const qemuFeature = {
33
+ name: "qemu",
34
+ setup: (c) => (c.images ? { order: 10, steps: qemuSetup(c.forge, c.input.imagePlatforms ?? [], c.pipeline) } : null),
35
+ };