@intentius/chant 0.124.101 → 0.124.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ci-evidence-claims.d.ts +12 -0
- package/dist/ci-evidence-claims.js +12 -0
- package/dist/cli/handlers/release-init.js +50 -18
- package/dist/cli/handlers/release.d.ts +1 -1
- package/dist/cli/handlers/release.js +12 -9
- package/dist/cli/release-commands/cut.js +4 -3
- package/dist/cli/release-commands/init.js +4 -1
- package/dist/cli/release-commands/workflow.js +4 -2
- package/dist/cloud-lister/index.d.ts +4 -1
- package/dist/cloud-lister/index.js +2 -1
- package/dist/cloud-lister/kubernetes-components.d.ts +56 -0
- package/dist/cloud-lister/kubernetes-components.js +642 -0
- package/dist/cloud-lister/kubernetes.d.ts +18 -0
- package/dist/cloud-lister/kubernetes.js +26 -1
- package/dist/cloud-lister/mask.d.ts +5 -1
- package/dist/cloud-lister/mask.js +14 -5
- package/dist/config-import.d.ts +1 -1
- package/dist/config-import.js +6 -2
- package/dist/config-sandbox.d.ts +1 -1
- package/dist/config-sandbox.js +3 -3
- package/dist/config.d.ts +75 -1
- package/dist/config.js +27 -2
- package/dist/deep-observation.js +9 -3
- package/dist/floor-table.data.js +12 -6
- package/dist/lexicon.d.ts +4 -2
- package/dist/lifecycle/__fixtures__/package-files.d.ts +32 -0
- package/dist/lifecycle/__fixtures__/package-files.js +72 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.js +5 -0
- package/dist/lifecycle/publish-credentials.d.ts +1 -1
- package/dist/lifecycle/publish-credentials.js +5 -0
- package/dist/lifecycle/publish-declaration.d.ts +123 -0
- package/dist/lifecycle/publish-declaration.js +140 -0
- package/dist/lifecycle/publish-helm.d.ts +83 -0
- package/dist/lifecycle/publish-helm.js +452 -0
- package/dist/lifecycle/publish-maven.d.ts +79 -0
- package/dist/lifecycle/publish-maven.js +364 -0
- package/dist/lifecycle/publish-mcp-registry.js +1 -2
- package/dist/lifecycle/publish-npm.d.ts +27 -1
- package/dist/lifecycle/publish-npm.js +51 -1
- package/dist/lifecycle/publish-nuget.d.ts +93 -0
- package/dist/lifecycle/publish-nuget.js +377 -0
- package/dist/lifecycle/publish-oci.d.ts +57 -1
- package/dist/lifecycle/publish-oci.js +1 -1
- package/dist/lifecycle/publish-package-files.d.ts +16 -0
- package/dist/lifecycle/publish-package-files.js +39 -0
- package/dist/lifecycle/publish-pypi.d.ts +2 -0
- package/dist/lifecycle/publish-pypi.js +1 -1
- package/dist/lifecycle/publish-rubygems.d.ts +84 -0
- package/dist/lifecycle/publish-rubygems.js +366 -0
- package/dist/lifecycle/publish-targets.d.ts +10 -0
- package/dist/lifecycle/publish-targets.js +22 -0
- package/dist/lifecycle/publish-train-names.d.ts +4 -1
- package/dist/lifecycle/publish-train-names.js +5 -0
- package/dist/lifecycle/release-artifacts.d.ts +80 -2
- package/dist/lifecycle/release-artifacts.js +242 -5
- package/dist/lifecycle/release-cut.d.ts +6 -1
- package/dist/lifecycle/release-cut.js +15 -0
- package/dist/lifecycle/release-doctor.js +208 -6
- package/dist/lifecycle/release-init-registries.d.ts +48 -0
- package/dist/lifecycle/release-init-registries.js +97 -0
- package/dist/lifecycle/release-init.d.ts +22 -2
- package/dist/lifecycle/release-init.js +132 -7
- package/dist/lifecycle/release-next.js +1 -2
- package/dist/lifecycle/release-publish.d.ts +1 -1
- package/dist/lifecycle/release-publish.js +1 -1
- package/dist/lifecycle/release-tag.js +1 -2
- package/dist/op/local-executor.d.ts +1 -1
- package/dist/op/local-executor.js +2 -2
- package/dist/op/op-waves-evidence.js +9 -2
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/sensitive-key.d.ts +12 -0
- package/dist/sensitive-key.js +52 -0
- package/dist/tool-pins.d.ts +2 -0
- package/dist/tool-pins.js +12 -0
- package/dist/ts-loader.d.ts +8 -0
- package/dist/ts-loader.js +19 -0
- package/dist/wave-runtime.mjs +325 -325
- package/dist/workspace/lexicon-outputs.d.ts +1 -1
- package/dist/workspace/lexicon-outputs.js +1 -1
- package/dist/workspace/release-steps/index.js +4 -0
- package/dist/workspace/release-steps/nfpm.d.ts +13 -0
- package/dist/workspace/release-steps/nfpm.js +29 -0
- package/dist/workspace/release-steps/nuget.d.ts +14 -0
- package/dist/workspace/release-steps/nuget.js +16 -0
- package/dist/workspace/release-steps/targets.d.ts +2 -2
- package/dist/workspace/release-steps/targets.js +3 -3
- package/dist/workspace/release-train-workflow.d.ts +7 -0
- package/dist/workspace/release-train-workflow.js +46 -10
- package/dist/workspace/release-workflow.d.ts +28 -3
- package/dist/workspace/release-workflow.js +38 -15
- package/dist/workspace/train-cut.d.ts +2 -2
- package/dist/workspace/train-cut.js +27 -5
- package/dist/workspace/train-prepare.d.ts +6 -3
- package/dist/workspace/train-prepare.js +54 -8
- package/dist/workspace/train-publish.js +2 -3
- package/dist/workspace/train-shell.d.ts +5 -0
- package/dist/workspace/train-shell.js +17 -0
- package/dist/workspace/trust/check-evidence-report.d.ts +3 -7
- package/dist/workspace/trust/check-evidence-report.js +3 -7
- package/package.json +1 -1
|
@@ -53,7 +53,7 @@ export interface OutputsPlugin {
|
|
|
53
53
|
outputs: LexiconWorkspaceOutput[];
|
|
54
54
|
gaps?: string[];
|
|
55
55
|
} | undefined;
|
|
56
|
-
workspaceLinks?: (entities: ReadonlyMap<string, Declarable>, unread?: readonly LexiconUnreadSource[]) => LexiconWorkspaceLinks | undefined
|
|
56
|
+
workspaceLinks?: (entities: ReadonlyMap<string, Declarable>, unread?: readonly LexiconUnreadSource[]) => LexiconWorkspaceLinks | undefined | Promise<LexiconWorkspaceLinks | undefined>;
|
|
57
57
|
}
|
|
58
58
|
/** Loads a lexicon plugin by name; `loadPlugin` from the CLI unless a test swaps it. */
|
|
59
59
|
export type OutputsPluginLoader = (name: string) => Promise<OutputsPlugin>;
|
|
@@ -317,7 +317,7 @@ export async function gatherLexiconLinks(root, declaration, tree, groups, kinds,
|
|
|
317
317
|
for (const { name, plugin } of member.reporting) {
|
|
318
318
|
const read = { reader: `lexicon ${name}`, links: [], gaps: member.gaps.map((message) => ({ file: where, line: 1, message })) };
|
|
319
319
|
try {
|
|
320
|
-
const report = plugin.workspaceLinks(member.entities, member.unread);
|
|
320
|
+
const report = await plugin.workspaceLinks(member.entities, member.unread);
|
|
321
321
|
if (!report)
|
|
322
322
|
continue;
|
|
323
323
|
for (const l of report.links) {
|
|
@@ -10,6 +10,8 @@ import { doctorFeature } from "./doctor.js";
|
|
|
10
10
|
import { goreleaserFeature } from "./goreleaser.js";
|
|
11
11
|
import { greenFeature } from "./green.js";
|
|
12
12
|
import { imagesFeature } from "./images.js";
|
|
13
|
+
import { nfpmFeature } from "./nfpm.js";
|
|
14
|
+
import { nugetFeature } from "./nuget.js";
|
|
13
15
|
import { pypiFeature } from "./pypi.js";
|
|
14
16
|
import { qemuFeature } from "./qemu.js";
|
|
15
17
|
import { signingFeature } from "./signing.js";
|
|
@@ -24,6 +26,8 @@ export const RELEASE_WORKFLOW_FEATURES = [
|
|
|
24
26
|
goreleaserFeature,
|
|
25
27
|
greenFeature,
|
|
26
28
|
imagesFeature,
|
|
29
|
+
nfpmFeature,
|
|
30
|
+
nugetFeature,
|
|
27
31
|
pypiFeature,
|
|
28
32
|
qemuFeature,
|
|
29
33
|
signingFeature,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReleasePipelineConfig, ReleaseWorkflowForge } from "../release-workflow.js";
|
|
2
|
+
import { type ReleaseWorkflowFeature } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* What a job that packages nfpm entries runs first: the pinned nfpm,
|
|
5
|
+
* downloaded, checked by SHA-256 and named by `CHANT_NFPM`. A config that
|
|
6
|
+
* sets `CHANT_NFPM` in `release.workflow.env` gets no install.
|
|
7
|
+
*/
|
|
8
|
+
export declare function nfpmSetup(forge: ReleaseWorkflowForge, p: ReleasePipelineConfig): {
|
|
9
|
+
github: string[];
|
|
10
|
+
gitlab: string[];
|
|
11
|
+
};
|
|
12
|
+
/** In the job that builds the files: a dispatched release's cut, or a tag's publish. */
|
|
13
|
+
export declare const nfpmFeature: ReleaseWorkflowFeature;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** nfpm for the `release.artifacts` entries it packages (#5233). */
|
|
2
|
+
import { TOOL_PINS, toolInstallLine } from "../../tool-pins.js";
|
|
3
|
+
import { RELEASE_RUNNER_PLATFORM } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* What a job that packages nfpm entries runs first: the pinned nfpm,
|
|
6
|
+
* downloaded, checked by SHA-256 and named by `CHANT_NFPM`. A config that
|
|
7
|
+
* sets `CHANT_NFPM` in `release.workflow.env` gets no install.
|
|
8
|
+
*/
|
|
9
|
+
export function nfpmSetup(forge, p) {
|
|
10
|
+
if (p.env?.CHANT_NFPM !== undefined)
|
|
11
|
+
return { github: [], gitlab: [] };
|
|
12
|
+
if (forge === "gitlab")
|
|
13
|
+
return { github: [], gitlab: [`${toolInstallLine(TOOL_PINS.nfpm, RELEASE_RUNNER_PLATFORM, "/tmp/nfpm")} && export CHANT_NFPM=/tmp/nfpm/nfpm`] };
|
|
14
|
+
const line = `${toolInstallLine(TOOL_PINS.nfpm, RELEASE_RUNNER_PLATFORM, "$RUNNER_TEMP/nfpm")} && echo "CHANT_NFPM=$RUNNER_TEMP/nfpm/nfpm" >> "$GITHUB_ENV"`;
|
|
15
|
+
return { github: [` - name: nfpm ${TOOL_PINS.nfpm.version}`, ` run: ${JSON.stringify(line)}`], gitlab: [] };
|
|
16
|
+
}
|
|
17
|
+
/** In the job that builds the files: a dispatched release's cut, or a tag's publish. */
|
|
18
|
+
export const nfpmFeature = {
|
|
19
|
+
name: "nfpm",
|
|
20
|
+
steps: (c) => {
|
|
21
|
+
if (!c.artifacts || c.input.nfpm !== true)
|
|
22
|
+
return [];
|
|
23
|
+
if (c.job !== (c.shape === "dispatch" ? "cut" : "publish"))
|
|
24
|
+
return [];
|
|
25
|
+
const n = nfpmSetup(c.forge, c.pipeline);
|
|
26
|
+
const items = c.forge !== "gitlab" ? [{ lines: n.github }] : c.shape === "dispatch" ? n.gitlab : [{ lines: n.gitlab.map((l) => ` - ${JSON.stringify(l)}`) }];
|
|
27
|
+
return [{ slot: "prepare", order: 21, items }];
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** nuget.org trusted publishing on GitLab (#5232): the ID token the `nuget` target reads. */
|
|
2
|
+
import type { ReleaseWorkflowTarget } from "../release-workflow.js";
|
|
3
|
+
import type { ReleaseWorkflowFeature } from "./types.js";
|
|
4
|
+
/** The audience nuget.org takes an OIDC ID token for. */
|
|
5
|
+
export declare const NUGET_ID_TOKEN_AUDIENCE = "https://www.nuget.org";
|
|
6
|
+
/**
|
|
7
|
+
* True when a `nuget` target may use trusted publishing: it does not set
|
|
8
|
+
* `auth: "token"` and pushes to nuget.org. With `auth` unset the target uses
|
|
9
|
+
* trusted publishing when its key's variable is not set, which the generator
|
|
10
|
+
* can't see, so the job gets the token; declaring it costs nothing.
|
|
11
|
+
*/
|
|
12
|
+
export declare function nugetIdTokenNeeded(targets: ReadonlyArray<ReleaseWorkflowTarget>): boolean;
|
|
13
|
+
/** `NUGET_ID_TOKEN` in the GitLab publish job's `id_tokens`. GitHub asks for the token at run time from `id-token: write`, which the job already has. */
|
|
14
|
+
export declare const nugetFeature: ReleaseWorkflowFeature;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** The audience nuget.org takes an OIDC ID token for. */
|
|
2
|
+
export const NUGET_ID_TOKEN_AUDIENCE = "https://www.nuget.org";
|
|
3
|
+
/**
|
|
4
|
+
* True when a `nuget` target may use trusted publishing: it does not set
|
|
5
|
+
* `auth: "token"` and pushes to nuget.org. With `auth` unset the target uses
|
|
6
|
+
* trusted publishing when its key's variable is not set, which the generator
|
|
7
|
+
* can't see, so the job gets the token; declaring it costs nothing.
|
|
8
|
+
*/
|
|
9
|
+
export function nugetIdTokenNeeded(targets) {
|
|
10
|
+
return targets.some((x) => x.type === "nuget" && x.auth !== "token" && x.pushUrl === undefined);
|
|
11
|
+
}
|
|
12
|
+
/** `NUGET_ID_TOKEN` in the GitLab publish job's `id_tokens`. GitHub asks for the token at run time from `id-token: write`, which the job already has. */
|
|
13
|
+
export const nugetFeature = {
|
|
14
|
+
name: "nuget",
|
|
15
|
+
steps: (c) => (c.forge === "gitlab" && c.job === "publish" && nugetIdTokenNeeded(c.input.publish ?? []) ? [{ slot: "idTokens", order: 20, items: [{ lines: [" NUGET_ID_TOKEN:", ` aud: ${NUGET_ID_TOKEN_AUDIENCE}`] }] }] : []),
|
|
16
|
+
};
|
|
@@ -15,8 +15,8 @@ export declare const NPM_TRUSTED_PUBLISHING_SETUP = "have=\"$(npm --version)\";
|
|
|
15
15
|
* What a GitHub release workflow needs for its targets, worked out from them
|
|
16
16
|
* (#4786), so no product wires it by hand:
|
|
17
17
|
*
|
|
18
|
-
* - an `oci` target on `ghcr.io` that
|
|
19
|
-
* job's token: `packages: write`, and `OCI_USERNAME` and `OCI_PASSWORD`
|
|
18
|
+
* - an `oci` target, or a `helm` target's `oci` (#5233), on `ghcr.io` that
|
|
19
|
+
* names no credentials pushes with the job's token: `packages: write`, and `OCI_USERNAME` and `OCI_PASSWORD`
|
|
20
20
|
* from `github.actor` and `github.token`;
|
|
21
21
|
* - an `npm` target on npmjs publishes with trusted publishing, which needs
|
|
22
22
|
* npm {@link NPM_TRUSTED_PUBLISHING_MIN}: the jobs upgrade npm when the
|
|
@@ -12,8 +12,8 @@ export const NPM_TRUSTED_PUBLISHING_SETUP = `have="$(npm --version)"; if [ "$(pr
|
|
|
12
12
|
* What a GitHub release workflow needs for its targets, worked out from them
|
|
13
13
|
* (#4786), so no product wires it by hand:
|
|
14
14
|
*
|
|
15
|
-
* - an `oci` target on `ghcr.io` that
|
|
16
|
-
* job's token: `packages: write`, and `OCI_USERNAME` and `OCI_PASSWORD`
|
|
15
|
+
* - an `oci` target, or a `helm` target's `oci` (#5233), on `ghcr.io` that
|
|
16
|
+
* names no credentials pushes with the job's token: `packages: write`, and `OCI_USERNAME` and `OCI_PASSWORD`
|
|
17
17
|
* from `github.actor` and `github.token`;
|
|
18
18
|
* - an `npm` target on npmjs publishes with trusted publishing, which needs
|
|
19
19
|
* npm {@link NPM_TRUSTED_PUBLISHING_MIN}: the jobs upgrade npm when the
|
|
@@ -26,7 +26,7 @@ export const NPM_TRUSTED_PUBLISHING_SETUP = `have="$(npm --version)"; if [ "$(pr
|
|
|
26
26
|
export function targetExtras(forge, targets, p) {
|
|
27
27
|
if (forge !== "github")
|
|
28
28
|
return {};
|
|
29
|
-
const ghcr = targets.some((t) => t.type === "oci" && /^ghcr\.io\//.test(t.repository ?? "") && !t.usernameEnv && !t.passwordEnv);
|
|
29
|
+
const ghcr = targets.some((t) => (t.type === "oci" && /^ghcr\.io\//.test(t.repository ?? "") && !t.usernameEnv && !t.passwordEnv) || (t.type === "helm" && /^ghcr\.io\//.test(t.oci?.repository ?? "") && !t.oci?.usernameEnv && !t.oci?.passwordEnv));
|
|
30
30
|
const npm = targets.some((t) => t.type === "npm" && (t.registry === undefined || /^https:\/\/registry\.npmjs\.org\/?$/.test(t.registry)));
|
|
31
31
|
const permissions = ghcr && p.permissions?.packages === undefined ? { packages: "write" } : undefined;
|
|
32
32
|
const env = ghcr ? Object.fromEntries(["OCI_USERNAME", "OCI_PASSWORD"].filter((k) => p.env?.[k] === undefined).map((k) => [k, k === "OCI_USERNAME" ? "${{ github.actor }}" : "${{ github.token }}"])) : {};
|
|
@@ -25,5 +25,12 @@ export interface TrainWorkflowInput {
|
|
|
25
25
|
}
|
|
26
26
|
/** The tag a train's cut pushes, as a GitHub tag filter: `*` stops at `/`, so a member's own tag starts nothing. */
|
|
27
27
|
export declare function trainTagFilter(env: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* The cut step's script that reads the train id from the cut's JSON. It exits
|
|
30
|
+
* 1 when the file is not JSON, or names members cut and no train, so a train
|
|
31
|
+
* that was cut and recorded is never left unpublished by a skipped job. A
|
|
32
|
+
* file that is not JSON may still hold the id, and the error names it.
|
|
33
|
+
*/
|
|
34
|
+
export declare function trainIdScript(file: string): string;
|
|
28
35
|
/** GitHub and Forgejo: the train workflow (#5154). */
|
|
29
36
|
export declare function renderTrainWorkflow(o: TrainWorkflowInput): string;
|
|
@@ -14,12 +14,19 @@
|
|
|
14
14
|
* --yes`, which picks the members, labels each past every version it
|
|
15
15
|
* already has, cuts them, records the train and pushes the member tags
|
|
16
16
|
* and `release-train/<env>/<id>` in one push. A commit with nothing to
|
|
17
|
-
* release ends the run here.
|
|
17
|
+
* release ends the run here. A cut that recorded a train and whose JSON
|
|
18
|
+
* names no train id fails the job, so the publish is never skipped
|
|
19
|
+
* silently.
|
|
18
20
|
* - publish: in a checkout of the commit, `chant workspace train prepare`
|
|
19
21
|
* (stamp each member, build the packages they need), the build, and
|
|
20
22
|
* `chant workspace train publish <env> <id> --yes`, which stages, runs the
|
|
21
23
|
* members' `release.verify`, and reveals layer by layer.
|
|
22
24
|
*
|
|
25
|
+
* Dispatched with `train`, a recorded train's id, the gate and the cut are
|
|
26
|
+
* skipped and the publish job publishes that train from its tag's commit,
|
|
27
|
+
* resuming what an earlier run staged or revealed: the way to finish a
|
|
28
|
+
* publish that stopped or was skipped, with no new cut and no tag pushed.
|
|
29
|
+
*
|
|
23
30
|
* The publish job also runs on a pushed `release-train/<env>/*` tag, so a
|
|
24
31
|
* train cut from a workstation with `chant workspace train cut <env> --yes`
|
|
25
32
|
* publishes from the same file. With the tag trigger (the default) that is
|
|
@@ -27,11 +34,33 @@
|
|
|
27
34
|
* dispatched run publishes in its own publish job.
|
|
28
35
|
*/
|
|
29
36
|
import { tagComments } from "../action-pins.js";
|
|
30
|
-
import {
|
|
37
|
+
import { gateScript, githubSetup, jobPermissions, LEDGER_FETCH_FIRST } from "./release-workflow.js";
|
|
31
38
|
/** The tag a train's cut pushes, as a GitHub tag filter: `*` stops at `/`, so a member's own tag starts nothing. */
|
|
32
39
|
export function trainTagFilter(env) {
|
|
33
40
|
return `release-train/${env}/*`;
|
|
34
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* The cut step's script that reads the train id from the cut's JSON. It exits
|
|
44
|
+
* 1 when the file is not JSON, or names members cut and no train, so a train
|
|
45
|
+
* that was cut and recorded is never left unpublished by a skipped job. A
|
|
46
|
+
* file that is not JSON may still hold the id, and the error names it.
|
|
47
|
+
*/
|
|
48
|
+
export function trainIdScript(file) {
|
|
49
|
+
const js = [
|
|
50
|
+
'const t=require("fs").readFileSync(process.argv[1],"utf8");',
|
|
51
|
+
"let d;",
|
|
52
|
+
"try{d=JSON.parse(t)}catch(e){",
|
|
53
|
+
'const m=/"id": *"(train-[^"]+)"/.exec(t);',
|
|
54
|
+
'console.error("the train cut printed more than its JSON document, so the train id can not be read ("+e.message+")."+(m?" The cut recorded "+m[1]+": dispatch this workflow with train="+m[1]+" to publish it.":" If it recorded a train, dispatch this workflow with train=<id> to publish it."));',
|
|
55
|
+
"process.exit(1)}",
|
|
56
|
+
'const id=d.train?.id??"";',
|
|
57
|
+
'if(!id&&d.released==null&&(d.members??[]).length>0){console.error("the train cut "+d.members.length+" member(s), and its JSON names no train id to publish");process.exit(1)}',
|
|
58
|
+
"process.stdout.write(id)",
|
|
59
|
+
].join("");
|
|
60
|
+
return `node -e '${js}' "${file}"`;
|
|
61
|
+
}
|
|
62
|
+
/** The ref of a train's tag, as an expression: what the publish job checks out for a dispatched `train`. */
|
|
63
|
+
const dispatchedTrainRef = (env) => `format('refs/tags/release-train/${env}/{0}', inputs.train)`;
|
|
35
64
|
/** GitHub and Forgejo: the train workflow (#5154). */
|
|
36
65
|
export function renderTrainWorkflow(o) {
|
|
37
66
|
const defaults = o.root ? [" defaults:", " run:", ` working-directory: ${o.root}`] : [];
|
|
@@ -54,32 +83,39 @@ export function renderTrainWorkflow(o) {
|
|
|
54
83
|
" required: false",
|
|
55
84
|
" default: auto",
|
|
56
85
|
" type: string",
|
|
86
|
+
" train:",
|
|
87
|
+
" description: a recorded train's id (train-...) to publish instead of cutting one; the gate and cut are skipped, and the publish resumes from its tag",
|
|
88
|
+
" required: false",
|
|
89
|
+
" default: \"\"",
|
|
90
|
+
" type: string",
|
|
57
91
|
]
|
|
58
92
|
: []),
|
|
59
93
|
" push:",
|
|
60
94
|
` tags: [${JSON.stringify(trainTagFilter(env))}]`,
|
|
61
95
|
"permissions:",
|
|
62
|
-
" contents:
|
|
63
|
-
" id-token: write",
|
|
64
|
-
...o.extra.permissions,
|
|
96
|
+
" contents: read",
|
|
65
97
|
"concurrency:",
|
|
66
98
|
" group: chant-release",
|
|
67
99
|
" cancel-in-progress: false",
|
|
68
100
|
"jobs:",
|
|
69
101
|
];
|
|
70
102
|
if (dispatch) {
|
|
71
|
-
lines.push(" gate:", " if: github.event_name == 'workflow_dispatch'", " runs-on: ubuntu-latest", ...defaults, " outputs:", " commit: ${{ steps.green.outputs.commit }}", " steps:", ...githubSetup(undefined, o.chantSetup), ...installLines, ciFetch, " - id: green", ...block([...gateScript(o, "$GITHUB_SHA"), 'echo "commit=$commit" >> "$GITHUB_OUTPUT"']), " cut:", " needs: gate", " runs-on: ubuntu-latest", ...defaults, " outputs:", " train: ${{ steps.cut.outputs.train }}", ...o.extra.githubEnv([" CHANT_RELEASE_COMMIT: ${{ needs.gate.outputs.commit }}", " CHANT_RELEASE_LEVELS: ${{ inputs.levels }}", ...(o.cutToken ?? [])]), " steps:", ...githubSetup("${{ needs.gate.outputs.commit }}", o.fullSetup), ...installLines, ...o.extra.githubSteps, ciFetch, run(LEDGER_FETCH_FIRST), " - id: cut", ...block([
|
|
103
|
+
lines.push(" gate:", " if: github.event_name == 'workflow_dispatch' && inputs.train == ''", " runs-on: ubuntu-latest", ...jobPermissions(o.extra, { contents: "read" }, "gate"), ...defaults, " outputs:", " commit: ${{ steps.green.outputs.commit }}", " steps:", ...githubSetup(undefined, o.chantSetup), ...installLines, ciFetch, " - id: green", ...block([...gateScript(o, "$GITHUB_SHA"), 'echo "commit=$commit" >> "$GITHUB_OUTPUT"']), " cut:", " needs: gate", " runs-on: ubuntu-latest", ...jobPermissions(o.extra, { contents: "write" }, "cut"), ...defaults, " outputs:", " train: ${{ steps.cut.outputs.train }}", ...o.extra.githubEnv([" CHANT_RELEASE_COMMIT: ${{ needs.gate.outputs.commit }}", " CHANT_RELEASE_LEVELS: ${{ inputs.levels }}", ...(o.cutToken ?? [])]), " steps:", ...githubSetup("${{ needs.gate.outputs.commit }}", o.fullSetup), ...installLines, ...o.extra.githubSteps, ciFetch, run(LEDGER_FETCH_FIRST), " - id: cut", ...block([
|
|
72
104
|
'git config user.name "chant release"',
|
|
73
105
|
'git config user.email "chant-release@localhost"',
|
|
74
106
|
`${o.chant} workspace train cut ${env} --at "$CHANT_RELEASE_COMMIT" --levels "\${CHANT_RELEASE_LEVELS:-auto}" --yes --json > "$RUNNER_TEMP/chant-train.json"`,
|
|
75
|
-
`
|
|
107
|
+
`train="$(${trainIdScript("$RUNNER_TEMP/chant-train.json")})" || exit 1`,
|
|
108
|
+
'echo "train=$train" >> "$GITHUB_OUTPUT"',
|
|
76
109
|
]));
|
|
77
110
|
}
|
|
78
|
-
const publishIf = dispatch ? " if: ${{ always() && (github.event_name == 'push' || (needs.cut.result == 'success' && needs.cut.outputs.train != '')) }}" : null;
|
|
111
|
+
const publishIf = dispatch ? " if: ${{ always() && (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.train != '') || (needs.cut.result == 'success' && needs.cut.outputs.train != '')) }}" : null;
|
|
112
|
+
// A dispatched `train` names the train itself, and its tag the commit to check out.
|
|
113
|
+
const dispatchedTrain = "${{ inputs.train || needs.cut.outputs.train }}";
|
|
114
|
+
const checkoutRef = `\${{ needs.gate.outputs.commit || (inputs.train != '' && ${dispatchedTrainRef(env)}) || github.sha }}`;
|
|
79
115
|
const trainFromRef = `echo "CHANT_RELEASE_TRAIN=\${CHANT_RELEASE_TRAIN:-\${GITHUB_REF_NAME#release-train/${env}/}}" >> "$GITHUB_ENV"`;
|
|
80
|
-
lines.push(" publish:", ...(dispatch ? [" needs: [gate, cut]", publishIf] : []), " runs-on: ubuntu-latest", ...defaults, ...o.extra.githubEnv([...(dispatch ? [
|
|
116
|
+
lines.push(" publish:", ...(dispatch ? [" needs: [gate, cut]", publishIf] : []), " runs-on: ubuntu-latest", ...jobPermissions(o.extra, { contents: "write", "id-token": "write" }, "publish"), ...defaults, ...o.extra.githubEnv([...(dispatch ? [` CHANT_RELEASE_TRAIN: ${dispatchedTrain}`] : []), ...o.forgeToken]), " steps:", ...githubSetup(dispatch ? checkoutRef : undefined, o.fullSetup), ...installLines, ...o.extra.githubSteps, ciFetch, ledgerFetch, run(trainFromRef), run(`${o.chant} workspace train prepare ${env} "$CHANT_RELEASE_TRAIN"`), ...(o.build ? [run(o.build)] : []), run('git config user.name "chant release"'), run('git config user.email "chant-release@localhost"'), run(`${o.chant} workspace train publish ${env} "$CHANT_RELEASE_TRAIN" ${o.flags}`));
|
|
81
117
|
if (o.after.length > 0) {
|
|
82
|
-
lines.push(" after-release:", ` needs: ${dispatch ? "[gate, cut, publish]" : "publish"}`, ...(dispatch ? [" if: ${{ always() && needs.publish.result == 'success' }}"] : []), " runs-on: ubuntu-latest", ...defaults, ...(dispatch ? [" env:",
|
|
118
|
+
lines.push(" after-release:", ` needs: ${dispatch ? "[gate, cut, publish]" : "publish"}`, ...(dispatch ? [" if: ${{ always() && needs.publish.result == 'success' }}"] : []), " runs-on: ubuntu-latest", ...jobPermissions(o.extra, { contents: "read" }, "after"), ...defaults, ...(dispatch ? [" env:", ` CHANT_RELEASE_TRAIN: ${dispatchedTrain}`] : []), " steps:", ...githubSetup(dispatch ? checkoutRef : undefined, o.fullSetup), run(trainFromRef), ...installLines, ...o.after.map(run));
|
|
83
119
|
}
|
|
84
120
|
return tagComments(`${lines.join("\n")}\n`);
|
|
85
121
|
}
|
|
@@ -124,6 +124,12 @@ export interface ReleaseWorkflowInput {
|
|
|
124
124
|
* member's `go.mod`.
|
|
125
125
|
*/
|
|
126
126
|
goreleaser?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* An entry of `release.artifacts` is packaged by nfpm (#5233): the job that
|
|
129
|
+
* builds the files installs the nfpm {@link TOOL_PINS} pin, checked by
|
|
130
|
+
* SHA-256, and names it in `CHANT_NFPM`.
|
|
131
|
+
*/
|
|
132
|
+
nfpm?: boolean;
|
|
127
133
|
/**
|
|
128
134
|
* The green gate the cut checks (#5149), `release.green` resolved. Under
|
|
129
135
|
* `forge-checks` or `none` a dispatched release's gate names the
|
|
@@ -180,8 +186,19 @@ export interface ReleaseWorkflowTarget {
|
|
|
180
186
|
registry?: string;
|
|
181
187
|
/** A `pypi` target's `auth`, `index` and `uploadUrl`. */
|
|
182
188
|
auth?: string;
|
|
183
|
-
index
|
|
189
|
+
/** A `pypi` target's index name, or a `helm` target's chart repository (#5233). */
|
|
190
|
+
index?: string | {
|
|
191
|
+
repo: string;
|
|
192
|
+
};
|
|
184
193
|
uploadUrl?: string;
|
|
194
|
+
/** A `helm` target's registry (#5233). */
|
|
195
|
+
oci?: {
|
|
196
|
+
repository: string;
|
|
197
|
+
usernameEnv?: string;
|
|
198
|
+
passwordEnv?: string;
|
|
199
|
+
};
|
|
200
|
+
/** A `nuget` target's `pushUrl` (#5232). */
|
|
201
|
+
pushUrl?: string;
|
|
185
202
|
}
|
|
186
203
|
export { RELEASE_RUNNER_PLATFORM } from "./release-steps/types.js";
|
|
187
204
|
export { NPM_TRUSTED_PUBLISHING_MIN, NPM_TRUSTED_PUBLISHING_SETUP, NPM_TRUSTED_PUBLISHING_VERSION, targetExtras } from "./release-steps/targets.js";
|
|
@@ -204,8 +221,8 @@ export declare function releaseTagFilters(tags: MemberTags): {
|
|
|
204
221
|
gitlabRule: string;
|
|
205
222
|
};
|
|
206
223
|
export interface JobExtras {
|
|
207
|
-
/**
|
|
208
|
-
permissions: string
|
|
224
|
+
/** The scopes the config and the targets add, which the jobs that need them take (#5234). */
|
|
225
|
+
permissions: Array<[string, string]>;
|
|
209
226
|
/** The job's `env:` block with `base` entries first, or nothing when there is neither. */
|
|
210
227
|
githubEnv: (base: string[]) => string[];
|
|
211
228
|
/** Steps after the install. */
|
|
@@ -215,6 +232,14 @@ export interface JobExtras {
|
|
|
215
232
|
/** GitLab: script lines after the install. */
|
|
216
233
|
gitlabScript: string[];
|
|
217
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* A job's `permissions:` block (#5234): the scopes it needs, then the config's
|
|
237
|
+
* and targets' extras it takes, one per line at the job's indent. The workflow
|
|
238
|
+
* itself grants `contents: read`, so no job holds a scope it does not name.
|
|
239
|
+
* The cut never takes `packages` (the publish pushes the images), and the
|
|
240
|
+
* extras the config set by hand go to both.
|
|
241
|
+
*/
|
|
242
|
+
export declare function jobPermissions(extra: Pick<JobExtras, "permissions">, base: Record<string, string>, job: "gate" | "cut" | "publish" | "after", indent?: string): string[];
|
|
218
243
|
/** `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. */
|
|
219
244
|
export declare function jobExtras(p: ReleasePipelineConfig, forge: ReleaseWorkflowForge): JobExtras;
|
|
220
245
|
/** The checkout and toolchain setup a GitHub or Forgejo job starts with (#5152); `ref` checks out that commit. */
|
|
@@ -223,12 +223,11 @@ export function renderReleaseWorkflow(input) {
|
|
|
223
223
|
" push:",
|
|
224
224
|
' tags: ["release/**"]',
|
|
225
225
|
"permissions:",
|
|
226
|
-
" contents:
|
|
227
|
-
" id-token: write",
|
|
228
|
-
...extra.permissions,
|
|
226
|
+
" contents: read",
|
|
229
227
|
"jobs:",
|
|
230
228
|
" publish:",
|
|
231
229
|
" runs-on: ubuntu-latest",
|
|
230
|
+
...jobPermissions(extra, { contents: "write", "id-token": "write" }, "publish"),
|
|
232
231
|
...(root ? [" defaults:", " run:", ` working-directory: ${root}`] : []),
|
|
233
232
|
...extra.githubEnv(forgeToken),
|
|
234
233
|
" steps:",
|
|
@@ -245,7 +244,7 @@ export function renderReleaseWorkflow(input) {
|
|
|
245
244
|
` - run: ${chant} release publish ${label} ${flags}`,
|
|
246
245
|
];
|
|
247
246
|
if (after.length > 0) {
|
|
248
|
-
lines.push(" after-release:", " needs: publish", " runs-on: ubuntu-latest", ...(root ? [" defaults:", " run:", ` working-directory: ${root}`] : []), " steps:", ...githubSetup(undefined, fullSetup), ' - run: echo "CHANT_RELEASE_LABEL=${GITHUB_REF_NAME#release/}" >> "$GITHUB_ENV"', ...(install ? [` - run: ${install}`] : []), ...after.map((l) => ` - run: ${l}`));
|
|
247
|
+
lines.push(" after-release:", " needs: publish", " runs-on: ubuntu-latest", ...jobPermissions(extra, { contents: "read" }, "after"), ...(root ? [" defaults:", " run:", ` working-directory: ${root}`] : []), " steps:", ...githubSetup(undefined, fullSetup), ' - run: echo "CHANT_RELEASE_LABEL=${GITHUB_REF_NAME#release/}" >> "$GITHUB_ENV"', ...(install ? [` - run: ${install}`] : []), ...after.map((l) => ` - run: ${l}`));
|
|
249
248
|
}
|
|
250
249
|
return tagComments(`${lines.join("\n")}\n`);
|
|
251
250
|
}
|
|
@@ -337,12 +336,11 @@ function renderTemplatedTagWorkflow(input, o) {
|
|
|
337
336
|
" push:",
|
|
338
337
|
` tags: [${filters.globs.map((g) => JSON.stringify(g)).join(", ")}]`,
|
|
339
338
|
"permissions:",
|
|
340
|
-
" contents:
|
|
341
|
-
" id-token: write",
|
|
342
|
-
...extra.permissions,
|
|
339
|
+
" contents: read",
|
|
343
340
|
"jobs:",
|
|
344
341
|
" publish:",
|
|
345
342
|
" runs-on: ubuntu-latest",
|
|
343
|
+
...jobPermissions(extra, { contents: "write", "id-token": "write" }, "publish"),
|
|
346
344
|
...(root ? [" defaults:", " run:", ` working-directory: ${root}`] : []),
|
|
347
345
|
...(after.length > 0 ? [" outputs:", " label: ${{ steps.label.outputs.label }}"] : []),
|
|
348
346
|
...extra.githubEnv(forgeToken),
|
|
@@ -364,10 +362,28 @@ function renderTemplatedTagWorkflow(input, o) {
|
|
|
364
362
|
run(`${chant} release publish ${label} ${flags}`),
|
|
365
363
|
];
|
|
366
364
|
if (after.length > 0) {
|
|
367
|
-
lines.push(" after-release:", " needs: publish", " runs-on: ubuntu-latest", ...(root ? [" defaults:", " run:", ` working-directory: ${root}`] : []), " env:", " CHANT_RELEASE_LABEL: ${{ needs.publish.outputs.label }}", " steps:", ...githubSetup(undefined, fullSetup), ...(install ? [run(install)] : []), ...after.map(run));
|
|
365
|
+
lines.push(" after-release:", " needs: publish", " runs-on: ubuntu-latest", ...jobPermissions(extra, { contents: "read" }, "after"), ...(root ? [" defaults:", " run:", ` working-directory: ${root}`] : []), " env:", " CHANT_RELEASE_LABEL: ${{ needs.publish.outputs.label }}", " steps:", ...githubSetup(undefined, fullSetup), ...(install ? [run(install)] : []), ...after.map(run));
|
|
368
366
|
}
|
|
369
367
|
return tagComments(`${lines.join("\n")}\n`);
|
|
370
368
|
}
|
|
369
|
+
/**
|
|
370
|
+
* A job's `permissions:` block (#5234): the scopes it needs, then the config's
|
|
371
|
+
* and targets' extras it takes, one per line at the job's indent. The workflow
|
|
372
|
+
* itself grants `contents: read`, so no job holds a scope it does not name.
|
|
373
|
+
* The cut never takes `packages` (the publish pushes the images), and the
|
|
374
|
+
* extras the config set by hand go to both.
|
|
375
|
+
*/
|
|
376
|
+
export function jobPermissions(extra, base, job, indent = " ") {
|
|
377
|
+
const scopes = { ...base };
|
|
378
|
+
if (job === "cut" || job === "publish") {
|
|
379
|
+
for (const [k, v] of extra.permissions) {
|
|
380
|
+
if (job === "cut" && k === "packages")
|
|
381
|
+
continue;
|
|
382
|
+
scopes[k] = v;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return [`${indent}permissions:`, ...Object.entries(scopes).map(([k, v]) => `${indent} ${k}: ${v}`)];
|
|
386
|
+
}
|
|
371
387
|
/** `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. */
|
|
372
388
|
export function jobExtras(p, forge) {
|
|
373
389
|
const permissions = Object.entries(p.permissions ?? {});
|
|
@@ -408,7 +424,7 @@ export function jobExtras(p, forge) {
|
|
|
408
424
|
...(s.env && Object.keys(s.env).length > 0 ? [" env:", ...map(" ", Object.entries(s.env))] : []),
|
|
409
425
|
]);
|
|
410
426
|
return {
|
|
411
|
-
permissions
|
|
427
|
+
permissions,
|
|
412
428
|
githubEnv: (base) => (base.length + env.length > 0 ? [" env:", ...base, ...map(" ", env)] : []),
|
|
413
429
|
githubSteps,
|
|
414
430
|
gitlabVariables: map(" ", env),
|
|
@@ -556,9 +572,7 @@ function renderGithubDispatch(o) {
|
|
|
556
572
|
" required: true",
|
|
557
573
|
" type: string",
|
|
558
574
|
"permissions:",
|
|
559
|
-
" contents:
|
|
560
|
-
" id-token: write",
|
|
561
|
-
...o.extra.permissions,
|
|
575
|
+
" contents: read",
|
|
562
576
|
"concurrency:",
|
|
563
577
|
" group: chant-release",
|
|
564
578
|
" cancel-in-progress: false",
|
|
@@ -567,6 +581,7 @@ function renderGithubDispatch(o) {
|
|
|
567
581
|
"jobs:",
|
|
568
582
|
" gate:",
|
|
569
583
|
" runs-on: ubuntu-latest",
|
|
584
|
+
...jobPermissions(o.extra, { contents: "read" }, "gate"),
|
|
570
585
|
...defaults,
|
|
571
586
|
" outputs:",
|
|
572
587
|
" commit: ${{ steps.green.outputs.commit }}",
|
|
@@ -582,6 +597,7 @@ function renderGithubDispatch(o) {
|
|
|
582
597
|
" cut:",
|
|
583
598
|
` needs: ${built.length > 0 ? `[gate, ${built.join(", ")}]` : "gate"}`,
|
|
584
599
|
" runs-on: ubuntu-latest",
|
|
600
|
+
...jobPermissions(o.extra, { contents: "write", ...(o.context.signing && o.context.doctor ? { "id-token": "write" } : {}) }, "cut"),
|
|
585
601
|
...defaults,
|
|
586
602
|
...o.extra.githubEnv([` CHANT_RELEASE_COMMIT: ${commit}`, ` CHANT_RELEASE_LABEL: ${GATE_LABEL}`, ...cutEnvToken(o)]),
|
|
587
603
|
" steps:",
|
|
@@ -597,6 +613,7 @@ function renderGithubDispatch(o) {
|
|
|
597
613
|
" publish:",
|
|
598
614
|
` needs: [gate, cut${built.map((b) => `, ${b}`).join("")}]`,
|
|
599
615
|
" runs-on: ubuntu-latest",
|
|
616
|
+
...jobPermissions(o.extra, { contents: "write", "id-token": "write" }, "publish"),
|
|
600
617
|
...defaults,
|
|
601
618
|
...o.extra.githubEnv([` CHANT_RELEASE_LABEL: ${GATE_LABEL}`, ...o.forgeToken]),
|
|
602
619
|
" steps:",
|
|
@@ -612,7 +629,7 @@ function renderGithubDispatch(o) {
|
|
|
612
629
|
` - run: ${o.chant} release publish "$CHANT_RELEASE_LABEL" ${o.flags}`,
|
|
613
630
|
];
|
|
614
631
|
if (o.after.length > 0) {
|
|
615
|
-
lines.push(" after-release:", " needs: [gate, publish]", " runs-on: ubuntu-latest", ...defaults, " env:", ` CHANT_RELEASE_LABEL: ${GATE_LABEL}`, " steps:", ...githubSetup(commit, o.fullSetup), ...installLines, ...o.after.map((l) => ` - run: ${l}`));
|
|
632
|
+
lines.push(" after-release:", " needs: [gate, publish]", " runs-on: ubuntu-latest", ...jobPermissions(o.extra, { contents: "read" }, "after"), ...defaults, " env:", ` CHANT_RELEASE_LABEL: ${GATE_LABEL}`, " steps:", ...githubSetup(commit, o.fullSetup), ...installLines, ...o.after.map((l) => ` - run: ${l}`));
|
|
616
633
|
}
|
|
617
634
|
return tagComments(`${lines.join("\n")}\n`);
|
|
618
635
|
}
|
|
@@ -740,7 +757,7 @@ export async function runReleaseWorkflow(ctx) {
|
|
|
740
757
|
const { gitTop } = await import("./tree.js");
|
|
741
758
|
const { securityGroupsAt } = await import("./security.js");
|
|
742
759
|
const { shellArg } = await import("./member-pipeline.js");
|
|
743
|
-
const usage = "chant release workflow [--forge github|gitlab|forgejo] [--install <command>] [--build <command>] [--chant <command>] [--output <file>]";
|
|
760
|
+
const usage = "chant release workflow [--forge github|gitlab|forgejo] [--install <command>] [--build <command>] [--chant <command>] [--output <file>] [--force]";
|
|
744
761
|
const { args } = ctx;
|
|
745
762
|
// #5149: a project with only a chant.config.ts, and no chant.workspace.json, renders its release workflow too.
|
|
746
763
|
const found = findWorkspaceRoot(process.cwd());
|
|
@@ -838,7 +855,7 @@ export async function runReleaseWorkflow(ctx) {
|
|
|
838
855
|
tags,
|
|
839
856
|
...(release?.workflow ? { pipeline: release.workflow } : {}),
|
|
840
857
|
...((release?.images?.length ?? 0) > 0 ? { images: true, imageArchives: resolveReleaseImages(release.images).map((i) => i.archive), imagePlatforms: releaseImagePlatforms(release.images) } : {}),
|
|
841
|
-
...((release?.artifacts?.length ?? 0) > 0 ? { artifacts: true, ...((await import("../lifecycle/release-artifacts.js")).usesGoreleaser(release.artifacts) ? { goreleaser: true } : {}) } : {}),
|
|
858
|
+
...((release?.artifacts?.length ?? 0) > 0 ? { artifacts: true, ...((await import("../lifecycle/release-artifacts.js")).usesGoreleaser(release.artifacts) ? { goreleaser: true } : {}), ...((await import("../lifecycle/release-artifacts.js")).usesNfpm(release.artifacts) ? { nfpm: true } : {}) } : {}),
|
|
842
859
|
...(release?.lane ? { lane: release.lane } : {}),
|
|
843
860
|
green: await (async () => {
|
|
844
861
|
const { resolveGreenSource } = await import("../lifecycle/release-green.js");
|
|
@@ -881,6 +898,12 @@ export async function runReleaseWorkflow(ctx) {
|
|
|
881
898
|
parts.push("--chant", args.ciChant);
|
|
882
899
|
if (args.output && !(isRenderPath(target) && asCommitted === defaultTarget))
|
|
883
900
|
parts.push("--output", relative(root, asCommitted).split(sep).join("/"));
|
|
901
|
+
// A file a person wrote, such as the npm publish workflow release.workflow.file names, is replaced only with --force.
|
|
902
|
+
if (args.force !== true && existsSync(target) && !readFileSync(target, "utf-8").includes(GENERATED_MARKER)) {
|
|
903
|
+
const shownTarget = relative(process.cwd(), target).split(sep).join("/") || target;
|
|
904
|
+
console.error(formatError({ message: `${shownTarget} exists and chant did not write it [release-workflow-exists]`, hint: "Run again with --force to replace it." }));
|
|
905
|
+
return 1;
|
|
906
|
+
}
|
|
884
907
|
mkdirSync(dirname(target), { recursive: true });
|
|
885
908
|
writeFileSync(target, releaseWorkflowHeader(parts.map(shellArg).join(" ")) + text);
|
|
886
909
|
const shown = relative(process.cwd(), target).split(sep).join("/") || target;
|
|
@@ -152,11 +152,11 @@ export interface TrainCutRun extends TrainCutQuery {
|
|
|
152
152
|
remote?: string;
|
|
153
153
|
actor?: string;
|
|
154
154
|
cutter?: MemberCutter;
|
|
155
|
-
/** Runs the `release.train.check` lines. Default: `sh -c` each one. */
|
|
155
|
+
/** Runs the `release.train.check` lines. Default: `sh -c` each one, its stdout sent to stderr. */
|
|
156
156
|
runCheck?: (line: string, o: {
|
|
157
157
|
cwd: string;
|
|
158
158
|
env: NodeJS.ProcessEnv;
|
|
159
|
-
}) => number
|
|
159
|
+
}) => number | Promise<number>;
|
|
160
160
|
/** A line of progress. */
|
|
161
161
|
say?: (line: string) => void;
|
|
162
162
|
now?: () => Date;
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
* cut's dry run, and cuts, records, tags and pushes nothing.
|
|
39
39
|
*/
|
|
40
40
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
41
|
+
import { runToStderr } from "./train-shell.js";
|
|
41
42
|
import { randomUUID } from "node:crypto";
|
|
42
43
|
import { existsSync, mkdtempSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
|
43
44
|
import { tmpdir } from "node:os";
|
|
@@ -341,7 +342,8 @@ export const spawnMemberCut = async (m, commit, o) => {
|
|
|
341
342
|
throw new TrainCutError("train-cut-failed", `the cut of ${m.member} printed no JSON`);
|
|
342
343
|
}
|
|
343
344
|
};
|
|
344
|
-
|
|
345
|
+
// A check's stdout goes to stderr: under --json, stdout is the cut's JSON document alone.
|
|
346
|
+
const defaultCheck = (line, o) => runToStderr(line, o);
|
|
345
347
|
/** Plan, and with `yes` cut, record, tag and push, a release train (#5154). */
|
|
346
348
|
export async function cutTrain(q) {
|
|
347
349
|
const root = locateWorkspace(q.cwd).rootOnDisk;
|
|
@@ -358,11 +360,31 @@ export async function cutTrain(q) {
|
|
|
358
360
|
const env = { ...process.env, CHANT_RELEASE_COMMIT: plan.commit, CHANT_TRAIN_ENV: plan.env, CHANT_TRAIN_PLAN: file };
|
|
359
361
|
for (const line of config.check ?? []) {
|
|
360
362
|
say(`check: ${line}`);
|
|
361
|
-
const code = (q.runCheck ?? defaultCheck)(line, { cwd: root, env });
|
|
363
|
+
const code = await (q.runCheck ?? defaultCheck)(line, { cwd: root, env });
|
|
362
364
|
if (code !== 0)
|
|
363
365
|
throw new TrainCutError("train-check-failed", `release.train.check failed (exit ${code}): ${line}`, "Nothing was cut. Fix what the check reports and run the train again.");
|
|
364
366
|
}
|
|
365
367
|
}
|
|
368
|
+
// #5230: a member's package npm has never had can't be published by trusted publishing. Refuse before the first member is cut.
|
|
369
|
+
{
|
|
370
|
+
const read = q.registry ?? npmVersions();
|
|
371
|
+
const { loadChantConfig } = await import("../config.js");
|
|
372
|
+
const { checkPackagesPublished } = await import("../lifecycle/publish-npm.js");
|
|
373
|
+
const { PublishTargetError } = await import("../lifecycle/release-publish.js");
|
|
374
|
+
for (const m of plan.members) {
|
|
375
|
+
if (m.resumed)
|
|
376
|
+
continue;
|
|
377
|
+
const dir = resolve(root, m.dir);
|
|
378
|
+
try {
|
|
379
|
+
checkPackagesPublished((await loadChantConfig(dir)).config.release?.publish ?? [], dir, (name, registry) => read(name, registry) !== null);
|
|
380
|
+
}
|
|
381
|
+
catch (err) {
|
|
382
|
+
if (err instanceof PublishTargetError)
|
|
383
|
+
throw new TrainCutError(err.code, `nothing was cut: ${m.member}: ${err.message}`, err.fix);
|
|
384
|
+
throw err;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
366
388
|
const cutter = q.cutter ?? spawnMemberCut;
|
|
367
389
|
const tags = {};
|
|
368
390
|
for (const m of plan.members) {
|
|
@@ -436,7 +458,7 @@ export async function runTrainCut(ctx, words) {
|
|
|
436
458
|
env,
|
|
437
459
|
...(args.at ? { at: args.at } : {}),
|
|
438
460
|
levels: parseTrainLevels(args.levels),
|
|
439
|
-
yes: args.yes === true,
|
|
461
|
+
yes: args.yes === true && args.dryRun !== true,
|
|
440
462
|
noPush: args.noPush === true,
|
|
441
463
|
...(args.actor ? { actor: args.actor } : {}),
|
|
442
464
|
say: (line) => (json ? undefined : console.error(line)),
|
|
@@ -456,7 +478,7 @@ export async function runTrainCut(ctx, words) {
|
|
|
456
478
|
throw err;
|
|
457
479
|
}
|
|
458
480
|
if (json) {
|
|
459
|
-
console.log(JSON.stringify({ dryRun: args.yes !== true, ...outcome }, null, 2));
|
|
481
|
+
console.log(JSON.stringify({ dryRun: args.yes !== true || args.dryRun === true, ...outcome }, null, 2));
|
|
460
482
|
return 0;
|
|
461
483
|
}
|
|
462
484
|
const short = outcome.commit.slice(0, 12);
|
|
@@ -471,7 +493,7 @@ export async function runTrainCut(ctx, words) {
|
|
|
471
493
|
console.log(`Release train for ${env} from ${short}${outcome.first ? " (the first: every member at one label)" : ""}:`);
|
|
472
494
|
for (const m of outcome.members)
|
|
473
495
|
console.log(` ${m.member.padEnd(24)} ${m.label.padEnd(12)} ${m.why}${m.bump ? `; ${m.bump} from ${m.bumpFrom}` : ""}${m.floor ? `; floor ${m.floor}` : ""}`);
|
|
474
|
-
if (args.yes !== true) {
|
|
496
|
+
if (args.yes !== true || args.dryRun === true) {
|
|
475
497
|
console.error("Dry run: nothing was cut, recorded, tagged or pushed. Run again with --yes to cut the train.");
|
|
476
498
|
return 0;
|
|
477
499
|
}
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
* - the workspace packages it depends on, directly or not, that this run
|
|
15
15
|
* does not publish are built once each, dependencies first, so a package
|
|
16
16
|
* that builds against another's output finds it. The members this run
|
|
17
|
-
* publishes build when npm packs them, in the train's layer order.
|
|
17
|
+
* publishes build when npm packs them, in the train's layer order. A
|
|
18
|
+
* member cut here whose package an earlier run of the publish already
|
|
19
|
+
* revealed is not packed again, so it builds here like any other
|
|
20
|
+
* dependency (#5222): a resumed publish finds what it left built. The
|
|
18
21
|
* command is `release.train.buildDependencies`, else the package's
|
|
19
22
|
* `prepack` script, else its `build` script.
|
|
20
23
|
*
|
|
@@ -29,8 +32,8 @@ export interface TrainPrepareQuery {
|
|
|
29
32
|
env: string;
|
|
30
33
|
/** The train by id or digest; the newest for `env` when absent. */
|
|
31
34
|
train?: string;
|
|
32
|
-
/** Runs one build command in a package directory and returns its exit code. Default: `sh -c
|
|
33
|
-
run?: (command: string, cwd: string) => number
|
|
35
|
+
/** Runs one build command in a package directory and returns its exit code. Default: `sh -c`, its stdout sent to stderr. */
|
|
36
|
+
run?: (command: string, cwd: string) => number | Promise<number>;
|
|
34
37
|
say?: (line: string) => void;
|
|
35
38
|
}
|
|
36
39
|
export interface TrainPrepareOutcome {
|