@intentius/chant 0.124.71 → 0.124.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ci-commit.d.ts +29 -0
- package/dist/ci-commit.d.ts.map +1 -1
- package/dist/ci-commit.js +30 -1
- package/dist/ci-estate/delivery.d.ts +75 -2
- package/dist/ci-estate/delivery.d.ts.map +1 -1
- package/dist/ci-estate/delivery.js +129 -0
- package/dist/ci-estate.d.ts +3 -1
- package/dist/ci-estate.d.ts.map +1 -1
- package/dist/ci-estate.js +4 -1
- package/dist/ci-product.d.ts +1 -1
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +1 -1
- package/dist/cli/handlers/commit.d.ts.map +1 -1
- package/dist/cli/handlers/commit.js +5 -2
- package/dist/cli/handlers/notify-relay.d.ts.map +1 -1
- package/dist/cli/handlers/notify-relay.js +22 -2
- package/dist/config.d.ts +14 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +7 -0
- package/dist/lexicon.d.ts +17 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/publish-forge.d.ts.map +1 -1
- package/dist/lifecycle/publish-forge.js +1 -2
- package/dist/lifecycle/release-images.d.ts.map +1 -1
- package/dist/lifecycle/release-images.js +1 -2
- package/dist/notify-relay.d.ts +41 -1
- package/dist/notify-relay.d.ts.map +1 -1
- package/dist/notify-relay.js +40 -0
- package/dist/notify.d.ts +16 -3
- package/dist/notify.d.ts.map +1 -1
- package/dist/notify.js +16 -10
- package/dist/op/activities/activity-contracts.d.ts +4 -4
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/wave-runtime.mjs +237 -237
- package/dist/workspace/release-workflow.d.ts +24 -0
- package/dist/workspace/release-workflow.d.ts.map +1 -1
- package/dist/workspace/release-workflow.js +61 -8
- package/package.json +1 -1
- package/src/ci-commit.ts +45 -1
- package/src/ci-estate/__fixtures__/terragucci-dora.json +1305 -0
- package/src/ci-estate/delivery.ts +186 -2
- package/src/ci-estate/records-delivery.test.ts +55 -0
- package/src/ci-estate.ts +10 -0
- package/src/ci-product.ts +1 -0
- package/src/cli/handlers/commit.ts +4 -1
- package/src/cli/handlers/notify-relay.ts +21 -2
- package/src/config.ts +7 -0
- package/src/lexicon.ts +16 -0
- package/src/lifecycle/publish-forge.ts +1 -2
- package/src/lifecycle/release-images.ts +1 -2
- package/src/notify-relay.test.ts +55 -1
- package/src/notify-relay.ts +49 -1
- package/src/notify.ts +25 -12
- package/src/release-floors.ts +1 -1
- package/src/workspace/release-workflow.test.ts +49 -1
- package/src/workspace/release-workflow.ts +91 -7
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SecurityGroup } from "./security.js";
|
|
2
|
+
import type { OpSetupStep } from "../lexicon.js";
|
|
2
3
|
export declare const RELEASE_WORKFLOW_FORGES: readonly ["github", "forgejo", "gitlab"];
|
|
3
4
|
export type ReleaseWorkflowForge = (typeof RELEASE_WORKFLOW_FORGES)[number];
|
|
4
5
|
/** Where each forge's publish workflow is written, relative to the repository root. */
|
|
@@ -17,6 +18,29 @@ export interface ReleasePipelineConfig {
|
|
|
17
18
|
chant?: string;
|
|
18
19
|
/** Shell lines run after the publish, with `CHANT_RELEASE_LABEL` set: steps that need a published release. */
|
|
19
20
|
after?: string[];
|
|
21
|
+
/**
|
|
22
|
+
* Scopes added to the workflow's `contents: write` and `id-token: write`
|
|
23
|
+
* (#4751), such as `{ packages: "write" }` for an `oci` target that pushes to
|
|
24
|
+
* GHCR with the run's token. A scope already granted is refused. GitHub and
|
|
25
|
+
* Forgejo only; GitLab has no `permissions:` and refuses it by name.
|
|
26
|
+
*/
|
|
27
|
+
permissions?: Record<string, "read" | "write">;
|
|
28
|
+
/**
|
|
29
|
+
* Variables for the cut and publish jobs (#4751), such as an `oci` target's
|
|
30
|
+
* `OCI_USERNAME: "${{ github.actor }}"` and `OCI_PASSWORD: "${{ github.token }}"`.
|
|
31
|
+
* A value may be a forge expression: it goes in the job's `env:` (GitLab:
|
|
32
|
+
* `variables:`), never on a `run:` line.
|
|
33
|
+
*/
|
|
34
|
+
env?: Record<string, string>;
|
|
35
|
+
/**
|
|
36
|
+
* Steps the cut and publish jobs run after the install (#4751): `{ run }`,
|
|
37
|
+
* or `{ uses, with }` on GitHub and Forgejo, such as QEMU's binfmt handlers
|
|
38
|
+
* for a two-platform image build, or a newer npm. GitLab takes `run` steps
|
|
39
|
+
* as script lines and refuses `uses` by name.
|
|
40
|
+
*/
|
|
41
|
+
setup?: OpSetupStep[];
|
|
42
|
+
/** Where the workflow is written, from the repository root, such as `.github/workflows/publish.yml` for an npm trusted publisher that names that file. Default {@link RELEASE_WORKFLOW_FILES}. */
|
|
43
|
+
file?: string;
|
|
20
44
|
}
|
|
21
45
|
export interface ReleaseWorkflowInput {
|
|
22
46
|
forge: ReleaseWorkflowForge;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"release-workflow.d.ts","sourceRoot":"","sources":["../../src/workspace/release-workflow.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"release-workflow.d.ts","sourceRoot":"","sources":["../../src/workspace/release-workflow.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,eAAO,MAAM,uBAAuB,YAAI,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAU,CAAC;AAChF,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5E,uFAAuF;AACvF,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,oBAAoB,EAAE,MAAM,CAKvE,CAAC;AAEF,yGAAyG;AACzG,MAAM,WAAW,qBAAqB;IACpC,8HAA8H;IAC9H,OAAO,CAAC,EAAE,KAAK,GAAG,UAAU,CAAC;IAC7B,iLAAiL;IACjL,IAAI,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;IAC7B,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yJAAyJ;IACzJ,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACvB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8GAA8G;IAC9G,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;IAC/C;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC;IACtB,kMAAkM;IAClM,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,oBAAoB,CAAC;IAC5B,+DAA+D;IAC/D,MAAM,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC;IACnC,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yFAAyF;IACzF,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IACjC,6FAA6F;IAC7F,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,qDAAqD;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,+DAA+D;AAC/D,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,aAAa,CAAC,GAAG,MAAM,EAAE,CAEzE;AAED,6FAA6F;AAC7F,eAAO,MAAM,oBAAoB,gCAAgC,CAAC;AAOlE,iEAAiE;AACjE,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CA8FzE;AAkOD,wFAAwF;AACxF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,OAAO,iBAAiB,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA6DvG"}
|
|
@@ -58,8 +58,9 @@ export function renderReleaseWorkflow(input) {
|
|
|
58
58
|
const flags = publishFlags(input.groups).join(" ");
|
|
59
59
|
const after = p.after ?? [];
|
|
60
60
|
const images = input.images === true;
|
|
61
|
+
const extra = jobExtras(p, input.forge);
|
|
61
62
|
if (p.trigger === "dispatch") {
|
|
62
|
-
const o = { chant, install, build, root, verify, flags, after, images, gate: p.gate ?? "last-green", ...(input.lane ? { lane: input.lane } : {}) };
|
|
63
|
+
const o = { chant, install, build, root, verify, flags, after, images, extra, gate: p.gate ?? "last-green", ...(input.lane ? { lane: input.lane } : {}) };
|
|
63
64
|
return input.forge === "gitlab" ? renderGitlabDispatch(o) : renderGithubDispatch(o);
|
|
64
65
|
}
|
|
65
66
|
// #4657: the images are built from the release, so chant/lifecycle is fetched before them and the build after.
|
|
@@ -74,9 +75,11 @@ export function renderReleaseWorkflow(input) {
|
|
|
74
75
|
" id_tokens:",
|
|
75
76
|
" SIGSTORE_ID_TOKEN:",
|
|
76
77
|
" aud: sigstore",
|
|
78
|
+
...(extra.gitlabVariables.length > 0 ? [" variables:", ...extra.gitlabVariables] : []),
|
|
77
79
|
" script:",
|
|
78
80
|
...(root ? [` - cd ${root}`] : []),
|
|
79
81
|
` - ${install}`,
|
|
82
|
+
...extra.gitlabScript.map((l) => ` - ${l}`),
|
|
80
83
|
...(images ? [...fetches, ...imageLines(label, `export CHANT_RELEASE_DIGESTS="$PWD/${RELEASE_DIGESTS_FILE}"`).map((l) => ` - ${l}`)] : []),
|
|
81
84
|
...(build ? [` - ${build}`] : []),
|
|
82
85
|
...(images ? [] : fetches),
|
|
@@ -98,13 +101,16 @@ export function renderReleaseWorkflow(input) {
|
|
|
98
101
|
"permissions:",
|
|
99
102
|
" contents: write",
|
|
100
103
|
" id-token: write",
|
|
104
|
+
...extra.permissions,
|
|
101
105
|
"jobs:",
|
|
102
106
|
" publish:",
|
|
103
107
|
" runs-on: ubuntu-latest",
|
|
104
108
|
...(root ? [" defaults:", " run:", ` working-directory: ${root}`] : []),
|
|
109
|
+
...extra.githubEnv([]),
|
|
105
110
|
" steps:",
|
|
106
111
|
...githubSetup(),
|
|
107
112
|
` - run: ${install}`,
|
|
113
|
+
...extra.githubSteps,
|
|
108
114
|
...(images ? [...fetches, ...imageLines(label, `echo "CHANT_RELEASE_DIGESTS=$PWD/${RELEASE_DIGESTS_FILE}" >> "$GITHUB_ENV"`).map((l) => ` - run: ${l}`)] : []),
|
|
109
115
|
...(build ? [` - run: ${build}`] : []),
|
|
110
116
|
...(images ? [] : fetches),
|
|
@@ -116,6 +122,48 @@ export function renderReleaseWorkflow(input) {
|
|
|
116
122
|
}
|
|
117
123
|
return tagComments(`${lines.join("\n")}\n`);
|
|
118
124
|
}
|
|
125
|
+
/** `release.workflow`'s `permissions`, `env` and `setup` (#4751) as lines of the forge's file. Empty for a config without them, so its file is what it was. */
|
|
126
|
+
function jobExtras(p, forge) {
|
|
127
|
+
const permissions = Object.entries(p.permissions ?? {});
|
|
128
|
+
const env = Object.entries(p.env ?? {});
|
|
129
|
+
const setup = p.setup ?? [];
|
|
130
|
+
const where = "release.workflow";
|
|
131
|
+
for (const [k, v] of env)
|
|
132
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(k) || typeof v !== "string")
|
|
133
|
+
throw new Error(`${where}.env: ${JSON.stringify(k)} is not a variable name with a string value`);
|
|
134
|
+
if (forge === "gitlab") {
|
|
135
|
+
if (permissions.length > 0)
|
|
136
|
+
throw new Error(`${where}.permissions: GitLab has no permissions: block; a GitLab job's token scopes are the project's`);
|
|
137
|
+
const uses = setup.find((s) => "uses" in s);
|
|
138
|
+
if (uses)
|
|
139
|
+
throw new Error(`${where}.setup: "${uses.uses}" is an action, and a GitLab job runs script lines; give it as { run }`);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
for (const [k, v] of permissions) {
|
|
143
|
+
if (k === "contents" || k === "id-token")
|
|
144
|
+
throw new Error(`${where}.permissions: ${k} is already granted (contents: write, id-token: write)`);
|
|
145
|
+
if (!/^[a-z][a-z-]*$/.test(k) || (v !== "read" && v !== "write"))
|
|
146
|
+
throw new Error(`${where}.permissions: ${k}: ${String(v)} is not a scope and read or write`);
|
|
147
|
+
}
|
|
148
|
+
for (const s of setup)
|
|
149
|
+
if (!("uses" in s) && s.run.trim() === "")
|
|
150
|
+
throw new Error(`${where}.setup: a run step is empty`);
|
|
151
|
+
}
|
|
152
|
+
const q = (v) => JSON.stringify(v);
|
|
153
|
+
const map = (indent, entries) => entries.map(([k, v]) => `${indent}${k}: ${q(v)}`);
|
|
154
|
+
const githubSteps = setup.flatMap((s) => [
|
|
155
|
+
"uses" in s ? ` - uses: ${s.uses}` : ` - run: ${q(s.run)}`,
|
|
156
|
+
...("uses" in s && s.with && Object.keys(s.with).length > 0 ? [" with:", ...map(" ", Object.entries(s.with))] : []),
|
|
157
|
+
...(s.env && Object.keys(s.env).length > 0 ? [" env:", ...map(" ", Object.entries(s.env))] : []),
|
|
158
|
+
]);
|
|
159
|
+
return {
|
|
160
|
+
permissions: permissions.map(([k, v]) => ` ${k}: ${v}`),
|
|
161
|
+
githubEnv: (base) => (base.length + env.length > 0 ? [" env:", ...base, ...map(" ", env)] : []),
|
|
162
|
+
githubSteps,
|
|
163
|
+
gitlabVariables: map(" ", env),
|
|
164
|
+
gitlabScript: setup.flatMap((s) => ("uses" in s ? [] : [...Object.entries(s.env ?? {}).map(([k, v]) => `export ${k}=${q(v)}`), s.run])),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
119
167
|
/** The checkout and node setup a GitHub or Forgejo job starts with; `ref` checks out that commit. */
|
|
120
168
|
function githubSetup(ref) {
|
|
121
169
|
return [
|
|
@@ -167,6 +215,7 @@ function renderGithubDispatch(o) {
|
|
|
167
215
|
"permissions:",
|
|
168
216
|
" contents: write",
|
|
169
217
|
" id-token: write",
|
|
218
|
+
...o.extra.permissions,
|
|
170
219
|
"concurrency:",
|
|
171
220
|
" group: chant-release",
|
|
172
221
|
" cancel-in-progress: false",
|
|
@@ -189,20 +238,22 @@ function renderGithubDispatch(o) {
|
|
|
189
238
|
" needs: gate",
|
|
190
239
|
" runs-on: ubuntu-latest",
|
|
191
240
|
...defaults,
|
|
192
|
-
|
|
193
|
-
` CHANT_RELEASE_COMMIT: ${commit}`,
|
|
241
|
+
...o.extra.githubEnv([` CHANT_RELEASE_COMMIT: ${commit}`]),
|
|
194
242
|
" steps:",
|
|
195
243
|
...githubSetup(commit),
|
|
196
244
|
` - run: ${o.install}`,
|
|
245
|
+
...o.extra.githubSteps,
|
|
197
246
|
...fetches,
|
|
198
247
|
...block(cutScript(o, '"$RUNNER_TEMP/chant-cut.json"')),
|
|
199
248
|
" publish:",
|
|
200
249
|
" needs: [gate, cut]",
|
|
201
250
|
" runs-on: ubuntu-latest",
|
|
202
251
|
...defaults,
|
|
252
|
+
...o.extra.githubEnv([]),
|
|
203
253
|
" steps:",
|
|
204
254
|
...githubSetup(commit),
|
|
205
255
|
` - run: ${o.install}`,
|
|
256
|
+
...o.extra.githubSteps,
|
|
206
257
|
...fetches,
|
|
207
258
|
...(o.images ? [` - run: ${o.chant} release images "$CHANT_RELEASE_LABEL" -o ${RELEASE_DIGESTS_FILE}`, ` - run: echo "CHANT_RELEASE_DIGESTS=$PWD/${RELEASE_DIGESTS_FILE}" >> "$GITHUB_ENV"`] : []),
|
|
208
259
|
...(o.build ? [` - run: ${o.build}`] : []),
|
|
@@ -229,12 +280,13 @@ function renderGitlabDispatch(o) {
|
|
|
229
280
|
'export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=http.extraheader GIT_CONFIG_VALUE_0="AUTHORIZATION: basic $chant_auth"',
|
|
230
281
|
"unset chant_auth",
|
|
231
282
|
];
|
|
232
|
-
const job = (name, needs, script, extra = []) => [
|
|
283
|
+
const job = (name, needs, script, extra = [], vars = []) => [
|
|
233
284
|
`${name}:`,
|
|
234
285
|
" rules:",
|
|
235
286
|
' - if: $CHANT_RELEASE_LABEL && $CI_PIPELINE_SOURCE =~ /^(web|api|trigger)$/',
|
|
236
287
|
" variables:",
|
|
237
288
|
' GIT_DEPTH: "0"',
|
|
289
|
+
...vars,
|
|
238
290
|
...(needs.length > 0 ? [` needs: [${needs.join(", ")}]`] : []),
|
|
239
291
|
...extra,
|
|
240
292
|
" script:",
|
|
@@ -244,19 +296,20 @@ function renderGitlabDispatch(o) {
|
|
|
244
296
|
const lines = [
|
|
245
297
|
...job("chant-release-gate", [], [...cd, o.install, fetches[0], ...gateScript(o, "$CI_COMMIT_SHA"), 'echo "CHANT_RELEASE_COMMIT=$commit" > "$CI_PROJECT_DIR/chant-release-gate.env"'], [" artifacts:", " reports:", " dotenv: chant-release-gate.env"]),
|
|
246
298
|
"",
|
|
247
|
-
...job("chant-release-cut", ["chant-release-gate"], [...checkout, ...cd, o.install, ...fetches, ...auth, ...cutScript(o, "/tmp/chant-cut.json")]),
|
|
299
|
+
...job("chant-release-cut", ["chant-release-gate"], [...checkout, ...cd, o.install, ...o.extra.gitlabScript, ...fetches, ...auth, ...cutScript(o, "/tmp/chant-cut.json")], [], o.extra.gitlabVariables),
|
|
248
300
|
"",
|
|
249
301
|
...job("chant-release-publish", ["chant-release-gate", "chant-release-cut"], [
|
|
250
302
|
...checkout,
|
|
251
303
|
...cd,
|
|
252
304
|
o.install,
|
|
305
|
+
...o.extra.gitlabScript,
|
|
253
306
|
...fetches,
|
|
254
307
|
...auth,
|
|
255
308
|
...(o.images ? [`${o.chant} release images "$CHANT_RELEASE_LABEL" -o ${RELEASE_DIGESTS_FILE}`, `export CHANT_RELEASE_DIGESTS="$PWD/${RELEASE_DIGESTS_FILE}"`] : []),
|
|
256
309
|
...(o.build ? [o.build] : []),
|
|
257
310
|
...(o.verify ? [`${o.chant} release verify "$CHANT_RELEASE_LABEL"`] : []),
|
|
258
311
|
`${o.chant} release publish "$CHANT_RELEASE_LABEL" ${o.flags}`,
|
|
259
|
-
], [" id_tokens:", " SIGSTORE_ID_TOKEN:", " aud: sigstore"]),
|
|
312
|
+
], [" id_tokens:", " SIGSTORE_ID_TOKEN:", " aud: sigstore"], o.extra.gitlabVariables),
|
|
260
313
|
];
|
|
261
314
|
if (o.after.length > 0)
|
|
262
315
|
lines.push("", ...job("chant-release-after", ["chant-release-gate", "chant-release-publish"], [...checkout, ...cd, o.install, ...o.after]));
|
|
@@ -318,7 +371,7 @@ export async function runReleaseWorkflow(ctx) {
|
|
|
318
371
|
...(args.buildCommand ? { build: args.buildCommand } : {}),
|
|
319
372
|
...(args.ciChant ? { chant: args.ciChant } : {}),
|
|
320
373
|
});
|
|
321
|
-
const target = args.output ? resolve(process.cwd(), args.output) : join(repoRoot, RELEASE_WORKFLOW_FILES[forge]);
|
|
374
|
+
const target = args.output ? resolve(process.cwd(), args.output) : join(repoRoot, release?.workflow?.file ?? RELEASE_WORKFLOW_FILES[forge]);
|
|
322
375
|
const parts = ["chant", "release", "workflow", "--forge", forge];
|
|
323
376
|
if (args.ciInstall)
|
|
324
377
|
parts.push("--install", args.ciInstall);
|
|
@@ -335,7 +388,7 @@ export async function runReleaseWorkflow(ctx) {
|
|
|
335
388
|
const what = release?.workflow?.trigger === "dispatch" ? "cuts and publishes a release started by hand with its label, from a green commit" : "publishes the release a release/** tag names";
|
|
336
389
|
console.log(formatSuccess(`Wrote ${shown}: ${what}${extras.length > 0 ? `, and ${extras.join(" and ")}` : ""}.`));
|
|
337
390
|
if (forge === "gitlab")
|
|
338
|
-
console.log(`Include it from .gitlab-ci.yml: include: [{ local: ${RELEASE_WORKFLOW_FILES.gitlab} }]`);
|
|
391
|
+
console.log(`Include it from .gitlab-ci.yml: include: [{ local: ${release?.workflow?.file ?? RELEASE_WORKFLOW_FILES.gitlab} }]`);
|
|
339
392
|
if (forge === "gitlab" && release?.workflow?.trigger === "dispatch")
|
|
340
393
|
console.log("The cut and publish jobs push with CHANT_RELEASE_TOKEN: a project access token with write_repository, as a masked CI/CD variable.");
|
|
341
394
|
return 0;
|
package/package.json
CHANGED
package/src/ci-commit.ts
CHANGED
|
@@ -37,7 +37,10 @@ import type { PrForge } from "./pr-forge";
|
|
|
37
37
|
import { NEXT_RELEASE } from "./release-floors";
|
|
38
38
|
|
|
39
39
|
/** The first chant with the commit job and the scheduled Op spec's `commit` (#4722). Products feature-detect on it. */
|
|
40
|
-
export const CI_COMMIT_FLOOR =
|
|
40
|
+
export const CI_COMMIT_FLOOR = "0.124.71";
|
|
41
|
+
|
|
42
|
+
/** The first chant with a commit job after a check that runs on push, `jobToken` and `after` (#4749). Products feature-detect on it. */
|
|
43
|
+
export const CI_COMMIT_PUSH_FLOOR = NEXT_RELEASE;
|
|
41
44
|
|
|
42
45
|
/** What starts a commit run: a person's comment, or a check job's finding. */
|
|
43
46
|
export type CommitTrigger = "comment" | "check";
|
|
@@ -79,6 +82,19 @@ export interface OpCommitSpec {
|
|
|
79
82
|
* its parents are the head and the base tip.
|
|
80
83
|
*/
|
|
81
84
|
mergeBase?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* GitHub and Forgejo (#4749): push with the job's own token, so `tokenEnv`
|
|
87
|
+
* may be left out. Such a push starts no workflow run, so the new head gets
|
|
88
|
+
* no plan from it; `after` is where a product does what that run would
|
|
89
|
+
* have done. Refused on GitLab, where a job token cannot push.
|
|
90
|
+
*/
|
|
91
|
+
jobToken?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Shell lines the push job runs once it has pushed a commit (#4749), with
|
|
94
|
+
* `CHANT_COMMIT_SHA` set to it, such as a product taking the plan locks of
|
|
95
|
+
* the new head. Not run when nothing was pushed.
|
|
96
|
+
*/
|
|
97
|
+
after?: string[];
|
|
82
98
|
}
|
|
83
99
|
|
|
84
100
|
/** A commit job's settings, every default filled and checked. */
|
|
@@ -94,6 +110,10 @@ export interface CommitSettings {
|
|
|
94
110
|
timeout: number;
|
|
95
111
|
env: string;
|
|
96
112
|
mergeBase: boolean;
|
|
113
|
+
/** Push with the job token (#4749). */
|
|
114
|
+
jobToken: boolean;
|
|
115
|
+
/** Lines the push job runs after a push (#4749). */
|
|
116
|
+
after: string[];
|
|
97
117
|
}
|
|
98
118
|
|
|
99
119
|
export const COMMIT_MAX_RUNS = 3;
|
|
@@ -131,6 +151,24 @@ export const COMMIT_BASE_REF = "refs/chant/commit-base";
|
|
|
131
151
|
export const COMMIT_DECISION_FILE = "decision.json";
|
|
132
152
|
export const COMMIT_PATCH_FILE = "change.patch";
|
|
133
153
|
export const COMMIT_RC_FILE = "rc";
|
|
154
|
+
/** What `chant commit land` leaves when it pushed (#4749): the pushed commit, which the push job's `after` lines read. */
|
|
155
|
+
export const COMMIT_PUSHED_FILE = "pushed";
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* After a check that runs on push (#4749): fetch the pushed commit, by its
|
|
159
|
+
* sha in `shaVar`, into `into` as the head. The pull request is found from
|
|
160
|
+
* the pushed branch (`resolveCommitRequest`).
|
|
161
|
+
*/
|
|
162
|
+
export function commitPushedHeadFetchLine(shaVar: string, into: string = COMMIT_HEAD_REF): string {
|
|
163
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(shaVar)) throw new AgentError(`${shaVar} is not a variable name`);
|
|
164
|
+
return `case "$${shaVar}" in *[!0-9a-f]*|'') echo "no pushed commit" >&2; exit 1 ;; esac\ngit -c protocol.version=2 fetch -q --no-tags origin "+$${shaVar}:${into}"`;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** The push job's lines after land (#4749): `after`, run only when a commit was pushed, with \`CHANT_COMMIT_SHA\` set. */
|
|
168
|
+
export function commitAfterLines(s: Pick<CommitSettings, "after">, dir: string = COMMIT_DIR): string[] {
|
|
169
|
+
if (s.after.length === 0) return [];
|
|
170
|
+
return [`if [ -s ${dir}/${COMMIT_PUSHED_FILE} ]; then`, ` export CHANT_COMMIT_SHA="$(cat ${dir}/${COMMIT_PUSHED_FILE})"`, ...s.after.map((l) => ` ${l}`), "fi"];
|
|
171
|
+
}
|
|
134
172
|
|
|
135
173
|
/** The commit identity the job's commits carry. */
|
|
136
174
|
export const COMMIT_GIT_NAME = "chant commit";
|
|
@@ -173,6 +211,10 @@ export function resolveCommitSpec(name: string, spec: OpCommitSpec, product = "c
|
|
|
173
211
|
for (const f of findings) intIn(`${where}: findings`, f, 1, 255);
|
|
174
212
|
const env = spec.env ?? "local";
|
|
175
213
|
if (!NAME.test(env)) throw new AgentError(`${where}: env is a ledger environment name`);
|
|
214
|
+
if (spec.jobToken !== undefined && typeof spec.jobToken !== "boolean") throw new AgentError(`${where}: jobToken is true or false`);
|
|
215
|
+
if (spec.jobToken && spec.tokenEnv !== undefined) throw new AgentError(`${where}: jobToken pushes with the job's own token, so leave tokenEnv out`);
|
|
216
|
+
const after = spec.after ?? [];
|
|
217
|
+
if (!Array.isArray(after) || !after.every((l) => typeof l === "string" && l.trim() !== "" && !l.includes("\n"))) throw new AgentError(`${where}: after is a list of shell lines, one command each`);
|
|
176
218
|
return {
|
|
177
219
|
name,
|
|
178
220
|
on: spec.on,
|
|
@@ -185,6 +227,8 @@ export function resolveCommitSpec(name: string, spec: OpCommitSpec, product = "c
|
|
|
185
227
|
timeout: spec.timeout === undefined ? COMMIT_TIMEOUT_MINUTES : intIn(`${where}: timeout`, spec.timeout, 1, 120),
|
|
186
228
|
env,
|
|
187
229
|
mergeBase: spec.mergeBase === true,
|
|
230
|
+
jobToken: spec.jobToken === true,
|
|
231
|
+
after: [...after],
|
|
188
232
|
};
|
|
189
233
|
}
|
|
190
234
|
|