@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.
- package/bin/chant +3 -3
- package/dist/action-pins.d.ts +2 -0
- package/dist/action-pins.js +3 -0
- package/dist/ci-detect.d.ts +13 -0
- package/dist/ci-detect.js +12 -0
- package/dist/ci-system.d.ts +66 -0
- package/dist/ci-system.js +61 -0
- package/dist/cli/commands/carve-emit.js +2 -2
- package/dist/cli/commands/check-lexicon-plugin.d.ts +2 -2
- package/dist/cli/commands/check-lexicon-plugin.js +3 -3
- package/dist/cli/commands/check-lexicon.js +4 -4
- package/dist/cli/commands/init-lexicon/templates/project.d.ts +1 -1
- package/dist/cli/commands/init-lexicon/templates/project.js +4 -4
- package/dist/cli/commands/init.d.ts +13 -0
- package/dist/cli/commands/init.js +30 -2
- package/dist/cli/handlers/build.js +27 -0
- package/dist/cli/handlers/release-doctor.d.ts +12 -0
- package/dist/cli/handlers/release-doctor.js +118 -0
- package/dist/cli/handlers/release-init.d.ts +10 -0
- package/dist/cli/handlers/release-init.js +342 -0
- package/dist/cli/handlers/release.d.ts +50 -1
- package/dist/cli/handlers/release.js +688 -30
- package/dist/cli/handlers/run-generate.js +11 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +45 -97
- package/dist/cli/parse-args.js +55 -0
- package/dist/cli/registry.d.ts +18 -0
- package/dist/cli/release-commands/artifacts.d.ts +3 -0
- package/dist/cli/release-commands/artifacts.js +14 -0
- package/dist/cli/release-commands/candidates.d.ts +3 -0
- package/dist/cli/release-commands/candidates.js +16 -0
- package/dist/cli/release-commands/changed.d.ts +3 -0
- package/dist/cli/release-commands/changed.js +14 -0
- package/dist/cli/release-commands/compose.d.ts +3 -0
- package/dist/cli/release-commands/compose.js +16 -0
- package/dist/cli/release-commands/cut.d.ts +3 -0
- package/dist/cli/release-commands/cut.js +49 -0
- package/dist/cli/release-commands/doctor.d.ts +3 -0
- package/dist/cli/release-commands/doctor.js +14 -0
- package/dist/cli/release-commands/export.d.ts +3 -0
- package/dist/cli/release-commands/export.js +12 -0
- package/dist/cli/release-commands/images.d.ts +3 -0
- package/dist/cli/release-commands/images.js +13 -0
- package/dist/cli/release-commands/index.d.ts +8 -0
- package/dist/cli/release-commands/index.js +52 -0
- package/dist/cli/release-commands/init.d.ts +3 -0
- package/dist/cli/release-commands/init.js +16 -0
- package/dist/cli/release-commands/list.d.ts +3 -0
- package/dist/cli/release-commands/list.js +10 -0
- package/dist/cli/release-commands/next.d.ts +3 -0
- package/dist/cli/release-commands/next.js +13 -0
- package/dist/cli/release-commands/publish.d.ts +3 -0
- package/dist/cli/release-commands/publish.js +22 -0
- package/dist/cli/release-commands/stamp.d.ts +3 -0
- package/dist/cli/release-commands/stamp.js +15 -0
- package/dist/cli/release-commands/status.d.ts +3 -0
- package/dist/cli/release-commands/status.js +17 -0
- package/dist/cli/release-commands/tag.d.ts +3 -0
- package/dist/cli/release-commands/tag.js +12 -0
- package/dist/cli/release-commands/types.d.ts +20 -0
- package/dist/cli/release-commands/types.js +1 -0
- package/dist/cli/release-commands/verify.d.ts +3 -0
- package/dist/cli/release-commands/verify.js +15 -0
- package/dist/cli/release-commands/workflow.d.ts +3 -0
- package/dist/cli/release-commands/workflow.js +13 -0
- package/dist/codegen/pinned-upgrade.js +1 -1
- package/dist/components/capability-plugin.d.ts +1 -1
- package/dist/components/capability-plugin.js +1 -1
- package/dist/components/cli-support.d.ts +1 -1
- package/dist/components/cli-support.js +1 -1
- package/dist/config-environments.d.ts +8 -1
- package/dist/config-environments.js +2 -0
- package/dist/config.d.ts +299 -6
- package/dist/config.js +102 -5
- package/dist/dead-guards.d.ts +5 -1
- package/dist/dead-guards.js +34 -23
- package/dist/discovery/sandbox/driver.js +1 -1
- package/dist/discovery/specifier-resolve.js +1 -1
- package/dist/floor-table.d.ts +3 -1
- package/dist/floor-table.data.js +23 -3
- package/dist/floor-table.js +4 -3
- package/dist/forge-remote.d.ts +13 -0
- package/dist/forge-remote.js +15 -0
- package/dist/lexicon.d.ts +41 -2
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +62 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.js +270 -3
- package/dist/lifecycle/publish-attachments.d.ts +2 -1
- package/dist/lifecycle/publish-attachments.js +19 -2
- package/dist/lifecycle/publish-cargo.d.ts +99 -0
- package/dist/lifecycle/publish-cargo.js +412 -0
- package/dist/lifecycle/publish-credentials.d.ts +1 -1
- package/dist/lifecycle/publish-credentials.js +8 -0
- package/dist/lifecycle/publish-declaration.d.ts +199 -4
- package/dist/lifecycle/publish-declaration.js +200 -9
- package/dist/lifecycle/publish-forge.d.ts +45 -2
- package/dist/lifecycle/publish-forge.js +434 -34
- package/dist/lifecycle/publish-git-ssh.d.ts +15 -0
- package/dist/lifecycle/publish-git-ssh.js +30 -4
- package/dist/lifecycle/publish-github.d.ts +40 -2
- package/dist/lifecycle/publish-github.js +100 -3
- package/dist/lifecycle/publish-homebrew.d.ts +7 -9
- package/dist/lifecycle/publish-homebrew.js +34 -197
- package/dist/lifecycle/publish-index.d.ts +141 -0
- package/dist/lifecycle/publish-index.js +719 -0
- package/dist/lifecycle/publish-marketplace.js +77 -0
- package/dist/lifecycle/publish-mcp-registry.d.ts +66 -0
- package/dist/lifecycle/publish-mcp-registry.js +306 -0
- package/dist/lifecycle/publish-npm.js +165 -2
- package/dist/lifecycle/publish-oci.d.ts +34 -1
- package/dist/lifecycle/publish-oci.js +246 -7
- package/dist/lifecycle/publish-pypi.d.ts +136 -0
- package/dist/lifecycle/publish-pypi.js +657 -0
- package/dist/lifecycle/publish-record.d.ts +6 -3
- package/dist/lifecycle/publish-record.js +6 -3
- package/dist/lifecycle/publish-signing.d.ts +147 -0
- package/dist/lifecycle/publish-signing.js +257 -0
- package/dist/lifecycle/publish-targets.d.ts +27 -1
- package/dist/lifecycle/publish-targets.js +80 -0
- package/dist/lifecycle/publish-tauri.js +43 -0
- package/dist/lifecycle/publish-train-names.d.ts +54 -0
- package/dist/lifecycle/publish-train-names.js +118 -0
- package/dist/lifecycle/publish-verify.d.ts +121 -0
- package/dist/lifecycle/publish-verify.js +130 -0
- package/dist/lifecycle/query.js +8 -0
- package/dist/lifecycle/release-artifacts.d.ts +212 -0
- package/dist/lifecycle/release-artifacts.js +571 -0
- package/dist/lifecycle/release-changelog.d.ts +13 -1
- package/dist/lifecycle/release-changelog.js +35 -2
- package/dist/lifecycle/release-cut.d.ts +58 -3
- package/dist/lifecycle/release-cut.js +132 -34
- package/dist/lifecycle/release-doctor.d.ts +113 -0
- package/dist/lifecycle/release-doctor.js +996 -0
- package/dist/lifecycle/release-green.d.ts +86 -0
- package/dist/lifecycle/release-green.js +286 -0
- package/dist/lifecycle/release-init.d.ts +255 -0
- package/dist/lifecycle/release-init.js +859 -0
- package/dist/lifecycle/release-intents.d.ts +73 -0
- package/dist/lifecycle/release-intents.js +128 -0
- package/dist/lifecycle/release-next.d.ts +111 -0
- package/dist/lifecycle/release-next.js +252 -0
- package/dist/lifecycle/release-prerelease.d.ts +19 -0
- package/dist/lifecycle/release-prerelease.js +30 -0
- package/dist/lifecycle/release-publish.d.ts +256 -10
- package/dist/lifecycle/release-publish.js +246 -34
- package/dist/lifecycle/release-status-change.d.ts +226 -0
- package/dist/lifecycle/release-status-change.js +478 -0
- package/dist/lifecycle/release-status.d.ts +11 -0
- package/dist/lifecycle/release-status.js +1 -1
- package/dist/lifecycle/release-store.d.ts +73 -2
- package/dist/lifecycle/release-store.js +32 -1
- package/dist/lifecycle/release-tag.d.ts +142 -0
- package/dist/lifecycle/release-tag.js +323 -0
- package/dist/lifecycle/release-verify.d.ts +73 -1
- package/dist/lifecycle/release-verify.js +117 -2
- package/dist/lifecycle/release-version-formats.d.ts +73 -0
- package/dist/lifecycle/release-version-formats.js +570 -0
- package/dist/lifecycle/release-version.d.ts +58 -10
- package/dist/lifecycle/release-version.js +164 -36
- package/dist/lifecycle/release-workstation.d.ts +3 -2
- package/dist/lifecycle/release-workstation.js +3 -2
- package/dist/module-source.d.ts +2 -2
- package/dist/module-source.js +8 -8
- package/dist/op/generate-pipeline.js +1 -1
- package/dist/pr-forge-base.js +4 -2
- package/dist/pr-forge.d.ts +20 -2
- package/dist/pr-forge.js +46 -10
- package/dist/release-floors.d.ts +10 -1
- package/dist/release-floors.js +10 -1
- package/dist/tool-pins.d.ts +38 -0
- package/dist/tool-pins.js +54 -0
- package/dist/ts-loader.d.ts +1 -1
- package/dist/ts-loader.js +6 -6
- package/dist/wave-runtime.mjs +337 -334
- package/dist/workspace/ci-forge.d.ts +17 -0
- package/dist/workspace/ci-forge.js +17 -0
- package/dist/workspace/ci-init.js +1 -1
- package/dist/workspace/composites.schema.json +1 -0
- package/dist/workspace/declaration.d.ts +8 -0
- package/dist/workspace/declaration.js +12 -0
- package/dist/workspace/declaration.schema.json +8 -0
- package/dist/workspace/environments.d.ts +2 -0
- package/dist/workspace/environments.js +1 -1
- package/dist/workspace/identity-gate-rule.d.ts +61 -5
- package/dist/workspace/identity-gate-rule.js +81 -12
- package/dist/workspace/member-pipeline.d.ts +2 -1
- package/dist/workspace/member-pipeline.js +5 -2
- package/dist/workspace/reason-codes.d.ts +6 -0
- package/dist/workspace/reason-codes.js +8 -1
- package/dist/workspace/release-changed.d.ts +179 -0
- package/dist/workspace/release-changed.js +625 -0
- package/dist/workspace/release-changed.schema.json +206 -0
- package/dist/workspace/release-steps/artifacts.d.ts +7 -0
- package/dist/workspace/release-steps/artifacts.js +45 -0
- package/dist/workspace/release-steps/builds.d.ts +12 -0
- package/dist/workspace/release-steps/builds.js +38 -0
- package/dist/workspace/release-steps/doctor.d.ts +8 -0
- package/dist/workspace/release-steps/doctor.js +14 -0
- package/dist/workspace/release-steps/goreleaser.d.ts +16 -0
- package/dist/workspace/release-steps/goreleaser.js +36 -0
- package/dist/workspace/release-steps/green.d.ts +3 -0
- package/dist/workspace/release-steps/green.js +6 -0
- package/dist/workspace/release-steps/images.d.ts +22 -0
- package/dist/workspace/release-steps/images.js +59 -0
- package/dist/workspace/release-steps/index.d.ts +9 -0
- package/dist/workspace/release-steps/index.js +46 -0
- package/dist/workspace/release-steps/pypi.d.ts +15 -0
- package/dist/workspace/release-steps/pypi.js +21 -0
- package/dist/workspace/release-steps/qemu.d.ts +21 -0
- package/dist/workspace/release-steps/qemu.js +35 -0
- package/dist/workspace/release-steps/signing.d.ts +18 -0
- package/dist/workspace/release-steps/signing.js +30 -0
- package/dist/workspace/release-steps/stamp.d.ts +3 -0
- package/dist/workspace/release-steps/stamp.js +4 -0
- package/dist/workspace/release-steps/targets.d.ts +31 -0
- package/dist/workspace/release-steps/targets.js +40 -0
- package/dist/workspace/release-steps/types.d.ts +104 -0
- package/dist/workspace/release-steps/types.js +2 -0
- package/dist/workspace/release-steps/verify.d.ts +3 -0
- package/dist/workspace/release-steps/verify.js +4 -0
- package/dist/workspace/release-toolchains.d.ts +59 -0
- package/dist/workspace/release-toolchains.js +133 -0
- package/dist/workspace/release-train-workflow.d.ts +29 -0
- package/dist/workspace/release-train-workflow.js +85 -0
- package/dist/workspace/release-train.d.ts +3 -1
- package/dist/workspace/release-train.js +20 -3
- package/dist/workspace/release-workflow.d.ts +160 -61
- package/dist/workspace/release-workflow.js +539 -193
- package/dist/workspace/releases.schema.json +70 -1
- package/dist/workspace/search-contract.d.ts +1 -1
- package/dist/workspace/security.js +9 -2
- package/dist/workspace/train-cut.d.ts +182 -0
- package/dist/workspace/train-cut.js +482 -0
- package/dist/workspace/train-prepare.d.ts +61 -0
- package/dist/workspace/train-prepare.js +267 -0
- package/dist/workspace/train-publish.d.ts +177 -0
- package/dist/workspace/train-publish.js +575 -0
- package/dist/workspace/train-range-labels.d.ts +33 -0
- package/dist/workspace/train-range-labels.js +109 -0
- package/dist/workspace/trust/seal.d.ts +13 -3
- package/dist/workspace/trust/seal.js +14 -4
- package/dist/workspace/work-cli.d.ts +3 -2
- package/dist/workspace/work-cli.js +3 -2
- package/dist/workspace/workspace-ledger.d.ts +14 -1
- package/dist/workspace/workspace-ledger.js +33 -7
- package/package.json +26 -26
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { OpSetupStep } from "../../lexicon.js";
|
|
2
|
+
import type { ReleasePipelineConfig, ReleaseWorkflowForge } from "../release-workflow.js";
|
|
3
|
+
import { type ReleaseWorkflowFeature } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* The step that installs cosign for Sigstore signing (#5164): the binary
|
|
6
|
+
* {@link TOOL_PINS} pins for the runner's platform, downloaded to the job's
|
|
7
|
+
* temp directory and checked against its SHA-256, and `CHANT_COSIGN` set to
|
|
8
|
+
* it. A config whose `setup` already sets `CHANT_COSIGN` gets nothing.
|
|
9
|
+
*/
|
|
10
|
+
export declare function cosignSetup(forge: ReleaseWorkflowForge, p: ReleasePipelineConfig): OpSetupStep[];
|
|
11
|
+
/**
|
|
12
|
+
* cosign after the config's setup, so a config that installs its own is left
|
|
13
|
+
* alone. It goes in the jobs that run chant release (the cut, whose doctor
|
|
14
|
+
* checks it, and the publish, which signs), never in a per-platform build
|
|
15
|
+
* job. On GitLab the doctor in a dispatched cut gets the publish job's
|
|
16
|
+
* `SIGSTORE_ID_TOKEN`, so it can check that signing will work.
|
|
17
|
+
*/
|
|
18
|
+
export declare const signingFeature: ReleaseWorkflowFeature;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Sigstore signing (#5164): cosign in the jobs that run chant release, and the OIDC token the doctor checks. */
|
|
2
|
+
import { TOOL_PINS, toolInstallLine } from "../../tool-pins.js";
|
|
3
|
+
import { RELEASE_RUNNER_PLATFORM } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* The step that installs cosign for Sigstore signing (#5164): the binary
|
|
6
|
+
* {@link TOOL_PINS} pins for the runner's platform, downloaded to the job's
|
|
7
|
+
* temp directory and checked against its SHA-256, and `CHANT_COSIGN` set to
|
|
8
|
+
* it. A config whose `setup` already sets `CHANT_COSIGN` gets nothing.
|
|
9
|
+
*/
|
|
10
|
+
export function cosignSetup(forge, p) {
|
|
11
|
+
if ((p.setup ?? []).some((s) => !("uses" in s) && s.run.includes("CHANT_COSIGN")) || p.env?.CHANT_COSIGN !== undefined)
|
|
12
|
+
return [];
|
|
13
|
+
if (forge === "gitlab")
|
|
14
|
+
return [{ run: `${toolInstallLine(TOOL_PINS.cosign, RELEASE_RUNNER_PLATFORM, "/tmp")} && export CHANT_COSIGN=/tmp/cosign` }];
|
|
15
|
+
return [{ name: `Install cosign ${TOOL_PINS.cosign.version}`, run: `${toolInstallLine(TOOL_PINS.cosign, RELEASE_RUNNER_PLATFORM, "$RUNNER_TEMP")} && echo "CHANT_COSIGN=$RUNNER_TEMP/cosign" >> "$GITHUB_ENV"` }];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* cosign after the config's setup, so a config that installs its own is left
|
|
19
|
+
* alone. It goes in the jobs that run chant release (the cut, whose doctor
|
|
20
|
+
* checks it, and the publish, which signs), never in a per-platform build
|
|
21
|
+
* job. On GitLab the doctor in a dispatched cut gets the publish job's
|
|
22
|
+
* `SIGSTORE_ID_TOKEN`, so it can check that signing will work.
|
|
23
|
+
*/
|
|
24
|
+
export const signingFeature = {
|
|
25
|
+
name: "signing",
|
|
26
|
+
setup: (c) => (c.signing ? { order: 40, steps: cosignSetup(c.forge, c.pipeline) } : null),
|
|
27
|
+
steps: (c) => c.signing && c.doctor && c.shape === "dispatch" && c.job === "cut" && c.forge === "gitlab"
|
|
28
|
+
? [{ slot: "jobKeys", order: 20, items: [{ lines: [" id_tokens:", " SIGSTORE_ID_TOKEN:", " aud: sigstore"] }] }]
|
|
29
|
+
: [],
|
|
30
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** What the `release.publish` targets need of the jobs on GitHub (#4786). */
|
|
2
|
+
import type { ReleasePipelineConfig, ReleaseWorkflowForge, ReleaseWorkflowTarget } from "../release-workflow.js";
|
|
3
|
+
import type { ReleaseWorkflowFeature } from "./types.js";
|
|
4
|
+
/** npm trusted publishing needs this npm or later (#4786). */
|
|
5
|
+
export declare const NPM_TRUSTED_PUBLISHING_MIN = "11.5.1";
|
|
6
|
+
/** The npm a publish job installs when the runner's Node bundles one older than {@link NPM_TRUSTED_PUBLISHING_MIN}. */
|
|
7
|
+
export declare const NPM_TRUSTED_PUBLISHING_VERSION = "11.19.0";
|
|
8
|
+
/**
|
|
9
|
+
* The shell line that installs {@link NPM_TRUSTED_PUBLISHING_VERSION} when the
|
|
10
|
+
* runner's npm is older than {@link NPM_TRUSTED_PUBLISHING_MIN}, and prints the
|
|
11
|
+
* npm in use.
|
|
12
|
+
*/
|
|
13
|
+
export declare const NPM_TRUSTED_PUBLISHING_SETUP = "have=\"$(npm --version)\"; if [ \"$(printf '%s\\n' \"11.5.1\" \"$have\" | sort -V | head -n1)\" != \"11.5.1\" ]; then npm install -g npm@11.19.0; fi; npm --version";
|
|
14
|
+
/**
|
|
15
|
+
* What a GitHub release workflow needs for its targets, worked out from them
|
|
16
|
+
* (#4786), so no product wires it by hand:
|
|
17
|
+
*
|
|
18
|
+
* - an `oci` target on `ghcr.io` that names no credentials pushes with the
|
|
19
|
+
* job's token: `packages: write`, and `OCI_USERNAME` and `OCI_PASSWORD`
|
|
20
|
+
* from `github.actor` and `github.token`;
|
|
21
|
+
* - an `npm` target on npmjs publishes with trusted publishing, which needs
|
|
22
|
+
* npm {@link NPM_TRUSTED_PUBLISHING_MIN}: the jobs upgrade npm when the
|
|
23
|
+
* runner's is older.
|
|
24
|
+
*
|
|
25
|
+
* `release.workflow` wins: a scope, variable or the same setup line it names
|
|
26
|
+
* is not added again. Other forges, and configs without such targets, get
|
|
27
|
+
* nothing.
|
|
28
|
+
*/
|
|
29
|
+
export declare function targetExtras(forge: ReleaseWorkflowForge, targets: ReadonlyArray<ReleaseWorkflowTarget>, p: ReleasePipelineConfig): Pick<ReleasePipelineConfig, "permissions" | "env" | "setup">;
|
|
30
|
+
/** The targets' setup after the config's own, so a config that set it by hand renders the same file without it. Their permissions and variables the frame merges. */
|
|
31
|
+
export declare const targetsFeature: ReleaseWorkflowFeature;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** npm trusted publishing needs this npm or later (#4786). */
|
|
2
|
+
export const NPM_TRUSTED_PUBLISHING_MIN = "11.5.1";
|
|
3
|
+
/** The npm a publish job installs when the runner's Node bundles one older than {@link NPM_TRUSTED_PUBLISHING_MIN}. */
|
|
4
|
+
export const NPM_TRUSTED_PUBLISHING_VERSION = "11.19.0";
|
|
5
|
+
/**
|
|
6
|
+
* The shell line that installs {@link NPM_TRUSTED_PUBLISHING_VERSION} when the
|
|
7
|
+
* runner's npm is older than {@link NPM_TRUSTED_PUBLISHING_MIN}, and prints the
|
|
8
|
+
* npm in use.
|
|
9
|
+
*/
|
|
10
|
+
export const NPM_TRUSTED_PUBLISHING_SETUP = `have="$(npm --version)"; if [ "$(printf '%s\\n' "${NPM_TRUSTED_PUBLISHING_MIN}" "$have" | sort -V | head -n1)" != "${NPM_TRUSTED_PUBLISHING_MIN}" ]; then npm install -g npm@${NPM_TRUSTED_PUBLISHING_VERSION}; fi; npm --version`;
|
|
11
|
+
/**
|
|
12
|
+
* What a GitHub release workflow needs for its targets, worked out from them
|
|
13
|
+
* (#4786), so no product wires it by hand:
|
|
14
|
+
*
|
|
15
|
+
* - an `oci` target on `ghcr.io` that names no credentials pushes with the
|
|
16
|
+
* job's token: `packages: write`, and `OCI_USERNAME` and `OCI_PASSWORD`
|
|
17
|
+
* from `github.actor` and `github.token`;
|
|
18
|
+
* - an `npm` target on npmjs publishes with trusted publishing, which needs
|
|
19
|
+
* npm {@link NPM_TRUSTED_PUBLISHING_MIN}: the jobs upgrade npm when the
|
|
20
|
+
* runner's is older.
|
|
21
|
+
*
|
|
22
|
+
* `release.workflow` wins: a scope, variable or the same setup line it names
|
|
23
|
+
* is not added again. Other forges, and configs without such targets, get
|
|
24
|
+
* nothing.
|
|
25
|
+
*/
|
|
26
|
+
export function targetExtras(forge, targets, p) {
|
|
27
|
+
if (forge !== "github")
|
|
28
|
+
return {};
|
|
29
|
+
const ghcr = targets.some((t) => t.type === "oci" && /^ghcr\.io\//.test(t.repository ?? "") && !t.usernameEnv && !t.passwordEnv);
|
|
30
|
+
const npm = targets.some((t) => t.type === "npm" && (t.registry === undefined || /^https:\/\/registry\.npmjs\.org\/?$/.test(t.registry)));
|
|
31
|
+
const permissions = ghcr && p.permissions?.packages === undefined ? { packages: "write" } : undefined;
|
|
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 }}"])) : {};
|
|
33
|
+
const setup = npm && !(p.setup ?? []).some((s) => !("uses" in s) && s.run === NPM_TRUSTED_PUBLISHING_SETUP) ? [{ run: NPM_TRUSTED_PUBLISHING_SETUP }] : [];
|
|
34
|
+
return { ...(permissions ? { permissions } : {}), ...(Object.keys(env).length > 0 ? { env } : {}), ...(setup.length > 0 ? { setup } : {}) };
|
|
35
|
+
}
|
|
36
|
+
/** The targets' setup after the config's own, so a config that set it by hand renders the same file without it. Their permissions and variables the frame merges. */
|
|
37
|
+
export const targetsFeature = {
|
|
38
|
+
name: "targets",
|
|
39
|
+
setup: (c) => ({ order: 30, steps: targetExtras(c.forge, c.input.publish ?? [], c.pipeline).setup ?? [] }),
|
|
40
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a release feature adds to the jobs `chant release workflow` writes
|
|
3
|
+
* (#5196). The cut and publish jobs are a fixed frame (checkout, install, the
|
|
4
|
+
* cut, the publish) with named slots between its lines; each feature, in a
|
|
5
|
+
* file of its own in this directory, says which steps it puts in which slot
|
|
6
|
+
* of which job, and ./index.ts lists the features. A new feature adds a file
|
|
7
|
+
* and a line to that list rather than editing the frame.
|
|
8
|
+
*/
|
|
9
|
+
import type { OpSetupStep } from "../../lexicon.js";
|
|
10
|
+
import type { MemberTags } from "../../lifecycle/release-tag.js";
|
|
11
|
+
import type { ReleaseGreenSource } from "../../lifecycle/release-green.js";
|
|
12
|
+
import type { ReleasePipelineConfig, ReleaseWorkflowForge, ReleaseWorkflowInput } from "../release-workflow.js";
|
|
13
|
+
import type { ReleaseBuildConfig } from "../release-toolchains.js";
|
|
14
|
+
/** The platform the jobs `chant release workflow` writes run on: GitHub's and Forgejo's `ubuntu-latest`, and a GitLab runner's default (#4876). */
|
|
15
|
+
export declare const RELEASE_RUNNER_PLATFORM = "linux/amd64";
|
|
16
|
+
/**
|
|
17
|
+
* The three files the generator writes: `tag`, the publish job on a
|
|
18
|
+
* `release/**` tag; `templated`, the same on the tags a `release.tag`
|
|
19
|
+
* template makes (#5150); `dispatch`, the release started by hand (#4656).
|
|
20
|
+
*/
|
|
21
|
+
export type ReleaseWorkflowShape = "tag" | "templated" | "dispatch";
|
|
22
|
+
/** The settings every feature reads, resolved once per render. */
|
|
23
|
+
export interface ReleaseWorkflowContext {
|
|
24
|
+
forge: ReleaseWorkflowForge;
|
|
25
|
+
shape: ReleaseWorkflowShape;
|
|
26
|
+
input: ReleaseWorkflowInput;
|
|
27
|
+
/** `release.workflow`, or an empty one. */
|
|
28
|
+
pipeline: ReleasePipelineConfig;
|
|
29
|
+
/** What runs chant. */
|
|
30
|
+
chant: string;
|
|
31
|
+
/** The workspace root from the repository root, or null at the top. */
|
|
32
|
+
root: string | null;
|
|
33
|
+
/** Under `verified-releases`. */
|
|
34
|
+
verify: boolean;
|
|
35
|
+
/** `release.images` is declared (#4657). */
|
|
36
|
+
images: boolean;
|
|
37
|
+
/** The image archives the cut hands the publish job, from the repository root (dispatch only; empty otherwise). */
|
|
38
|
+
archives: string[];
|
|
39
|
+
/** `release.artifacts` is declared (#5151). */
|
|
40
|
+
artifacts: boolean;
|
|
41
|
+
/** `release.version` is declared (#4840). */
|
|
42
|
+
version: boolean;
|
|
43
|
+
/** `chant release doctor` runs (#5161): on by default in a dispatched release, opt-in on a tag. */
|
|
44
|
+
doctor: boolean;
|
|
45
|
+
/** The publish signs with Sigstore (#5164). */
|
|
46
|
+
signing: boolean;
|
|
47
|
+
/** The green gate the cut checks (#5149). */
|
|
48
|
+
green: ReleaseGreenSource;
|
|
49
|
+
/** `release.workflow.builds` (#5152). */
|
|
50
|
+
builds: ReleaseBuildConfig[];
|
|
51
|
+
/** `release.tag` (#5150), when the shape is `templated`. */
|
|
52
|
+
tags?: MemberTags;
|
|
53
|
+
}
|
|
54
|
+
/** The two jobs features add steps to. A tag-triggered file has only `publish`. */
|
|
55
|
+
export type ReleaseStepJob = "cut" | "publish";
|
|
56
|
+
/**
|
|
57
|
+
* The slots of the cut and publish jobs, in the order they run:
|
|
58
|
+
*
|
|
59
|
+
* - `afterCheckout`: GitLab dispatch publish only, before the `cd` into the root.
|
|
60
|
+
* - `prepare`: after the install, the config's setup steps and (on a
|
|
61
|
+
* templated tag) the label, before the ledger fetch in a cut.
|
|
62
|
+
* - `beforeCut`: a cut, after the fetches, right before `chant release cut`.
|
|
63
|
+
* - `afterCut`: a cut, after the tag is pushed.
|
|
64
|
+
* - `beforeBuild`: a publish, right before its build. On a tag the fetches of
|
|
65
|
+
* the ci tags and `chant/lifecycle` come before this slot when it holds
|
|
66
|
+
* anything, since those steps read the release, and after the build when
|
|
67
|
+
* it is empty.
|
|
68
|
+
* - `afterBuild`: a publish, after its build.
|
|
69
|
+
* - `beforePublish`: a publish, right before `chant release publish`.
|
|
70
|
+
* - `artifactPaths`: GitLab dispatch cut only, lines under its `artifacts: paths:`.
|
|
71
|
+
* - `jobKeys`: GitLab dispatch cut only, lines added to the job's keys.
|
|
72
|
+
* - `idTokens`: GitLab publish job only, entries under its `id_tokens:`
|
|
73
|
+
* beside `SIGSTORE_ID_TOKEN`, as lines indented four spaces for the name
|
|
74
|
+
* and six for `aud`.
|
|
75
|
+
*/
|
|
76
|
+
export type ReleaseStepSlot = "afterCheckout" | "prepare" | "beforeCut" | "afterCut" | "beforeBuild" | "afterBuild" | "beforePublish" | "artifactPaths" | "jobKeys" | "idTokens";
|
|
77
|
+
/** A step: a shell line, which the job writes as its forge writes one (`- run: ...`, a script entry), or `lines` placed as they are. */
|
|
78
|
+
export type ReleaseStepItem = string | {
|
|
79
|
+
lines: string[];
|
|
80
|
+
};
|
|
81
|
+
/** Where a feature's steps go, and their order within the slot (lowest first). */
|
|
82
|
+
export interface ReleaseStepPlacement {
|
|
83
|
+
slot: ReleaseStepSlot;
|
|
84
|
+
order: number;
|
|
85
|
+
items: ReleaseStepItem[];
|
|
86
|
+
}
|
|
87
|
+
/** One job of one file, as a feature sees it. */
|
|
88
|
+
export interface ReleaseStepContext extends ReleaseWorkflowContext {
|
|
89
|
+
job: ReleaseStepJob;
|
|
90
|
+
/** The release's label as a shell word in this job. */
|
|
91
|
+
label: string;
|
|
92
|
+
}
|
|
93
|
+
/** A feature of the release workflow. */
|
|
94
|
+
export interface ReleaseWorkflowFeature {
|
|
95
|
+
/** The feature's name, for a reader. */
|
|
96
|
+
name: string;
|
|
97
|
+
/** Setup steps of the cut and publish jobs, merged with `release.workflow.setup` (order 20), lowest first. */
|
|
98
|
+
setup?: (c: ReleaseWorkflowContext) => {
|
|
99
|
+
order: number;
|
|
100
|
+
steps: OpSetupStep[];
|
|
101
|
+
} | null;
|
|
102
|
+
/** The feature's steps in one job. */
|
|
103
|
+
steps?: (c: ReleaseStepContext) => ReleaseStepPlacement[];
|
|
104
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export declare const RELEASE_TOOLCHAINS: readonly ["node", "go", "python", "rust", "java"];
|
|
2
|
+
export type ReleaseToolchainName = (typeof RELEASE_TOOLCHAINS)[number];
|
|
3
|
+
/** One entry of `release.workflow.toolchains`: a name, or a name with the version to install. */
|
|
4
|
+
export type ReleaseToolchainDecl = ReleaseToolchainName | {
|
|
5
|
+
name: ReleaseToolchainName;
|
|
6
|
+
version: string;
|
|
7
|
+
};
|
|
8
|
+
/** The files at a project's root that say which toolchain it builds with, and which version. */
|
|
9
|
+
export declare const TOOLCHAIN_MARKERS: readonly ["package.json", "go.mod", "pyproject.toml", "setup.py", "requirements.txt", ".python-version", "Cargo.toml", "pom.xml", "build.gradle", "build.gradle.kts", ".java-version", ".sdkmanrc", ".tool-versions"];
|
|
10
|
+
/** The toolchains the files at a project's root name, in {@link RELEASE_TOOLCHAINS} order. */
|
|
11
|
+
export declare function detectToolchains(files: ReadonlySet<string>): ReleaseToolchainName[];
|
|
12
|
+
/** A setup step: the pinned action and its inputs. */
|
|
13
|
+
export interface ToolchainStep {
|
|
14
|
+
name: ReleaseToolchainName;
|
|
15
|
+
uses: string;
|
|
16
|
+
with: Array<[string, string | number | boolean]>;
|
|
17
|
+
}
|
|
18
|
+
/** The Node every job that runs chant gets, as the workflow always set it up. */
|
|
19
|
+
export declare const NODE_DEFAULT_VERSION = 24;
|
|
20
|
+
/**
|
|
21
|
+
* The setup step for one toolchain. A declared version wins; otherwise the
|
|
22
|
+
* version file the project keeps (`go.mod`, `.python-version`,
|
|
23
|
+
* `.java-version`), and otherwise the toolchain's current stable line. Paths
|
|
24
|
+
* are from the repository root, where the setup actions read them.
|
|
25
|
+
*/
|
|
26
|
+
export declare function toolchainStep(decl: ReleaseToolchainDecl, files: ReadonlySet<string>, root: string | null): ToolchainStep;
|
|
27
|
+
/**
|
|
28
|
+
* The toolchains a job sets up: those declared, or those the project's files
|
|
29
|
+
* name. `false` is none, the runner bringing its own. `withNode` adds Node
|
|
30
|
+
* first for a job that runs chant, at the declared version when there is one.
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveToolchains(decl: readonly ReleaseToolchainDecl[] | false | undefined, files: ReadonlySet<string>, root: string | null, withNode: boolean): ToolchainStep[];
|
|
33
|
+
/** A step's lines in a GitHub or Forgejo job. Node renders as it always has: its inputs unquoted. */
|
|
34
|
+
export declare function toolchainLines(steps: readonly ToolchainStep[]): string[];
|
|
35
|
+
/**
|
|
36
|
+
* `release.workflow.builds` (#5152): a job per platform that builds on its
|
|
37
|
+
* own runner before the cut and hands its outputs to the cut.
|
|
38
|
+
*/
|
|
39
|
+
export interface ReleaseBuildConfig {
|
|
40
|
+
/** The job's name, `build-<name>`: lowercase letters, digits and dashes. */
|
|
41
|
+
name: string;
|
|
42
|
+
/** The runner: GitHub's and Forgejo's `runs-on` label (or labels), GitLab's runner `tags`. */
|
|
43
|
+
runner: string | string[];
|
|
44
|
+
/** The command that builds, run with bash from the project root with `CHANT_RELEASE_LABEL` set. */
|
|
45
|
+
build: string;
|
|
46
|
+
/** The files it hands to the cut, from the project root. Shell globs such as `dist/*` are allowed. */
|
|
47
|
+
outputs: string[];
|
|
48
|
+
/** What installs before the build. Default the workflow's install; `false` for none. */
|
|
49
|
+
install?: string | false;
|
|
50
|
+
/** The toolchains this job sets up, in place of the workflow's. */
|
|
51
|
+
toolchains?: ReleaseToolchainDecl[] | false;
|
|
52
|
+
/** Variables for this job only. The cut and publish jobs' `env` is not given to it. */
|
|
53
|
+
env?: Record<string, string>;
|
|
54
|
+
}
|
|
55
|
+
/** The workflow artifact a build job hands its outputs on in, and the tar archive inside it. */
|
|
56
|
+
export declare const releaseBuildArtifact: (name: string) => string;
|
|
57
|
+
export declare const releaseBuildArchive: (name: string) => string;
|
|
58
|
+
/** Each build checked: a unique job name, a runner, a build, and outputs that stay inside the project. */
|
|
59
|
+
export declare function checkBuilds(builds: readonly ReleaseBuildConfig[]): void;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The toolchains a generated release workflow sets up (#5152), and the
|
|
3
|
+
* per-platform build jobs that run before the cut.
|
|
4
|
+
*
|
|
5
|
+
* A job that runs chant always has Node, since chant runs on it. Beside it
|
|
6
|
+
* the jobs set up what the project builds with: declared in
|
|
7
|
+
* `release.workflow.toolchains`, or found from the files at the project's
|
|
8
|
+
* root (`go.mod`, `pyproject.toml`, `Cargo.toml`, `pom.xml`, ...). Each
|
|
9
|
+
* setup action is pinned by commit in ../action-pins.ts, and none caches:
|
|
10
|
+
* a release build starts from the commit and the toolchain, not from a cache
|
|
11
|
+
* an earlier run could have written.
|
|
12
|
+
*/
|
|
13
|
+
import { ACTION_PINS, usesRef } from "../action-pins.js";
|
|
14
|
+
export const RELEASE_TOOLCHAINS = ["node", "go", "python", "rust", "java"];
|
|
15
|
+
/** The files at a project's root that say which toolchain it builds with, and which version. */
|
|
16
|
+
export const TOOLCHAIN_MARKERS = [
|
|
17
|
+
"package.json",
|
|
18
|
+
"go.mod",
|
|
19
|
+
"pyproject.toml",
|
|
20
|
+
"setup.py",
|
|
21
|
+
"requirements.txt",
|
|
22
|
+
".python-version",
|
|
23
|
+
"Cargo.toml",
|
|
24
|
+
"pom.xml",
|
|
25
|
+
"build.gradle",
|
|
26
|
+
"build.gradle.kts",
|
|
27
|
+
".java-version",
|
|
28
|
+
".sdkmanrc",
|
|
29
|
+
".tool-versions",
|
|
30
|
+
];
|
|
31
|
+
const FOUND_BY = {
|
|
32
|
+
node: ["package.json"],
|
|
33
|
+
go: ["go.mod"],
|
|
34
|
+
python: ["pyproject.toml", "setup.py", "requirements.txt"],
|
|
35
|
+
rust: ["Cargo.toml"],
|
|
36
|
+
java: ["pom.xml", "build.gradle", "build.gradle.kts"],
|
|
37
|
+
};
|
|
38
|
+
/** The toolchains the files at a project's root name, in {@link RELEASE_TOOLCHAINS} order. */
|
|
39
|
+
export function detectToolchains(files) {
|
|
40
|
+
return RELEASE_TOOLCHAINS.filter((t) => FOUND_BY[t].some((f) => files.has(f)));
|
|
41
|
+
}
|
|
42
|
+
/** The Node every job that runs chant gets, as the workflow always set it up. */
|
|
43
|
+
export const NODE_DEFAULT_VERSION = 24;
|
|
44
|
+
/**
|
|
45
|
+
* The setup step for one toolchain. A declared version wins; otherwise the
|
|
46
|
+
* version file the project keeps (`go.mod`, `.python-version`,
|
|
47
|
+
* `.java-version`), and otherwise the toolchain's current stable line. Paths
|
|
48
|
+
* are from the repository root, where the setup actions read them.
|
|
49
|
+
*/
|
|
50
|
+
export function toolchainStep(decl, files, root) {
|
|
51
|
+
const name = typeof decl === "string" ? decl : decl.name;
|
|
52
|
+
const version = typeof decl === "string" ? undefined : decl.version;
|
|
53
|
+
const at = (f) => (root ? `${root}/${f}` : f);
|
|
54
|
+
switch (name) {
|
|
55
|
+
case "node":
|
|
56
|
+
return { name, uses: usesRef(ACTION_PINS.setupNode4), with: [["node-version", version ?? NODE_DEFAULT_VERSION], ["registry-url", "https://registry.npmjs.org"]] };
|
|
57
|
+
case "go":
|
|
58
|
+
return {
|
|
59
|
+
name,
|
|
60
|
+
uses: usesRef(ACTION_PINS.setupGo7),
|
|
61
|
+
with: [version ? ["go-version", version] : files.has("go.mod") ? ["go-version-file", at("go.mod")] : ["go-version", "stable"], ["cache", false]],
|
|
62
|
+
};
|
|
63
|
+
case "python":
|
|
64
|
+
return { name, uses: usesRef(ACTION_PINS.setupPython7), with: [version ? ["python-version", version] : files.has(".python-version") ? ["python-version-file", at(".python-version")] : ["python-version", "3.x"]] };
|
|
65
|
+
case "rust":
|
|
66
|
+
// The action reads rust-toolchain.toml when there is one, and installs stable when not.
|
|
67
|
+
return { name, uses: usesRef(ACTION_PINS.setupRustToolchain2), with: [...(version ? [["toolchain", version]] : []), ["cache", false], ["rustflags", ""]] };
|
|
68
|
+
case "java": {
|
|
69
|
+
const file = [".java-version", ".sdkmanrc", ".tool-versions"].find((f) => files.has(f));
|
|
70
|
+
return { name, uses: usesRef(ACTION_PINS.setupJava6), with: [["distribution", "temurin"], version ? ["java-version", version] : file ? ["java-version-file", at(file)] : ["java-version", "21"]] };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The toolchains a job sets up: those declared, or those the project's files
|
|
76
|
+
* name. `false` is none, the runner bringing its own. `withNode` adds Node
|
|
77
|
+
* first for a job that runs chant, at the declared version when there is one.
|
|
78
|
+
*/
|
|
79
|
+
export function resolveToolchains(decl, files, root, withNode) {
|
|
80
|
+
if (decl === false)
|
|
81
|
+
return [];
|
|
82
|
+
const list = decl ? [...decl] : detectToolchains(files);
|
|
83
|
+
const named = (d) => (typeof d === "string" ? d : d.name);
|
|
84
|
+
const seen = new Set();
|
|
85
|
+
for (const d of list) {
|
|
86
|
+
const n = named(d);
|
|
87
|
+
if (!RELEASE_TOOLCHAINS.includes(n))
|
|
88
|
+
throw new Error(`release.workflow.toolchains: ${JSON.stringify(n)} is not one of ${RELEASE_TOOLCHAINS.join(", ")}`);
|
|
89
|
+
if (seen.has(n))
|
|
90
|
+
throw new Error(`release.workflow.toolchains: ${n} is named twice`);
|
|
91
|
+
seen.add(n);
|
|
92
|
+
}
|
|
93
|
+
if (withNode && !seen.has("node"))
|
|
94
|
+
list.unshift("node");
|
|
95
|
+
// Node first, so the chant the job runs is there before anything else.
|
|
96
|
+
list.sort((a, b) => (named(a) === "node" ? -1 : named(b) === "node" ? 1 : 0));
|
|
97
|
+
return list.map((d) => toolchainStep(d, files, root));
|
|
98
|
+
}
|
|
99
|
+
/** A step's lines in a GitHub or Forgejo job. Node renders as it always has: its inputs unquoted. */
|
|
100
|
+
export function toolchainLines(steps) {
|
|
101
|
+
return steps.flatMap((s) => [
|
|
102
|
+
` - uses: ${s.uses}`,
|
|
103
|
+
...(s.with.length > 0 ? [" with:", ...s.with.map(([k, v]) => ` ${k}: ${s.name === "node" ? String(v) : JSON.stringify(v)}`)] : []),
|
|
104
|
+
]);
|
|
105
|
+
}
|
|
106
|
+
/** The workflow artifact a build job hands its outputs on in, and the tar archive inside it. */
|
|
107
|
+
export const releaseBuildArtifact = (name) => `chant-release-build-${name}`;
|
|
108
|
+
export const releaseBuildArchive = (name) => `${releaseBuildArtifact(name)}.tar`;
|
|
109
|
+
const OUTPUT = /^[A-Za-z0-9_@+.*?\[\]-][A-Za-z0-9_@+.*?\[\]/-]*$/;
|
|
110
|
+
/** Each build checked: a unique job name, a runner, a build, and outputs that stay inside the project. */
|
|
111
|
+
export function checkBuilds(builds) {
|
|
112
|
+
const where = "release.workflow.builds";
|
|
113
|
+
const names = new Set();
|
|
114
|
+
for (const b of builds) {
|
|
115
|
+
if (!/^[a-z0-9][a-z0-9-]*$/.test(b.name))
|
|
116
|
+
throw new Error(`${where}: ${JSON.stringify(b.name)} is not a job name of lowercase letters, digits and dashes`);
|
|
117
|
+
if (names.has(b.name))
|
|
118
|
+
throw new Error(`${where}: ${b.name} is named twice`);
|
|
119
|
+
names.add(b.name);
|
|
120
|
+
const runners = Array.isArray(b.runner) ? b.runner : [b.runner];
|
|
121
|
+
if (runners.length === 0 || runners.some((r) => typeof r !== "string" || r.trim() === "" || /[\r\n]/.test(r)))
|
|
122
|
+
throw new Error(`${where}.${b.name}: runner is blank`);
|
|
123
|
+
if (typeof b.build !== "string" || b.build.trim() === "")
|
|
124
|
+
throw new Error(`${where}.${b.name}: build is blank`);
|
|
125
|
+
if (!Array.isArray(b.outputs) || b.outputs.length === 0)
|
|
126
|
+
throw new Error(`${where}.${b.name}: outputs names no file`);
|
|
127
|
+
for (const o of b.outputs) {
|
|
128
|
+
if (!OUTPUT.test(o) || o.split("/").includes("..") || o.startsWith("-")) {
|
|
129
|
+
throw new Error(`${where}.${b.name}: output ${JSON.stringify(o)} is not a path inside the project (letters, digits, ._@+-/ and the globs * ? [ ], with no .. and no leading / or -)`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ReleaseGreenSource } from "../lifecycle/release-green.js";
|
|
2
|
+
import { type JobExtras, type ReleaseWorkflowForge } from "./release-workflow.js";
|
|
3
|
+
export interface TrainWorkflowInput {
|
|
4
|
+
forge: Exclude<ReleaseWorkflowForge, "gitlab">;
|
|
5
|
+
env: string;
|
|
6
|
+
trigger: "dispatch" | "tag";
|
|
7
|
+
chant: string;
|
|
8
|
+
install: string | null;
|
|
9
|
+
build: string | null;
|
|
10
|
+
root: string | null;
|
|
11
|
+
/** `chant workspace train publish`'s flags: `--require-provenance` under `supply-chain`, and `--yes`. */
|
|
12
|
+
flags: string;
|
|
13
|
+
after: string[];
|
|
14
|
+
/** The toolchain steps of the gate (Node, for chant) and of the jobs that build (#5152). */
|
|
15
|
+
chantSetup: string[];
|
|
16
|
+
fullSetup: string[];
|
|
17
|
+
extra: JobExtras;
|
|
18
|
+
/** The publish job's `GITHUB_TOKEN` line for a GitHub forge target, or nothing. */
|
|
19
|
+
forgeToken: string[];
|
|
20
|
+
/** The cut job's `GITHUB_TOKEN` line under `forge-checks` (#5149), or nothing. */
|
|
21
|
+
cutToken?: string[];
|
|
22
|
+
green: ReleaseGreenSource;
|
|
23
|
+
gate: "last-green" | "head";
|
|
24
|
+
lane?: string;
|
|
25
|
+
}
|
|
26
|
+
/** The tag a train's cut pushes, as a GitHub tag filter: `*` stops at `/`, so a member's own tag starts nothing. */
|
|
27
|
+
export declare function trainTagFilter(env: string): string;
|
|
28
|
+
/** GitHub and Forgejo: the train workflow (#5154). */
|
|
29
|
+
export declare function renderTrainWorkflow(o: TrainWorkflowInput): string;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The release workflow of a train (#5154): `chant release workflow` at a
|
|
3
|
+
* workspace root whose `chant.config.ts` declares `release.train` and
|
|
4
|
+
* `release.workflow`. The root's members release separately, each at its
|
|
5
|
+
* own label, and one run releases every member that changed.
|
|
6
|
+
*
|
|
7
|
+
* With `trigger: "dispatch"` a person starts it with the levels (default
|
|
8
|
+
* `auto`, the levels the commits and intent files give), and three jobs
|
|
9
|
+
* follow:
|
|
10
|
+
*
|
|
11
|
+
* - gate: the commit to release, as a dispatched release picks it (`chant ci
|
|
12
|
+
* last-green`, or the dispatched commit under `gate: "head"`).
|
|
13
|
+
* - cut: `chant workspace train cut <env> --at <commit> --levels <levels>
|
|
14
|
+
* --yes`, which picks the members, labels each past every version it
|
|
15
|
+
* already has, cuts them, records the train and pushes the member tags
|
|
16
|
+
* and `release-train/<env>/<id>` in one push. A commit with nothing to
|
|
17
|
+
* release ends the run here.
|
|
18
|
+
* - publish: in a checkout of the commit, `chant workspace train prepare`
|
|
19
|
+
* (stamp each member, build the packages they need), the build, and
|
|
20
|
+
* `chant workspace train publish <env> <id> --yes`, which stages, runs the
|
|
21
|
+
* members' `release.verify`, and reveals layer by layer.
|
|
22
|
+
*
|
|
23
|
+
* The publish job also runs on a pushed `release-train/<env>/*` tag, so a
|
|
24
|
+
* train cut from a workstation with `chant workspace train cut <env> --yes`
|
|
25
|
+
* publishes from the same file. With the tag trigger (the default) that is
|
|
26
|
+
* the whole workflow. A tag the job's own token pushed starts nothing, so a
|
|
27
|
+
* dispatched run publishes in its own publish job.
|
|
28
|
+
*/
|
|
29
|
+
import { tagComments } from "../action-pins.js";
|
|
30
|
+
import { field, gateScript, githubSetup, LEDGER_FETCH_FIRST } from "./release-workflow.js";
|
|
31
|
+
/** The tag a train's cut pushes, as a GitHub tag filter: `*` stops at `/`, so a member's own tag starts nothing. */
|
|
32
|
+
export function trainTagFilter(env) {
|
|
33
|
+
return `release-train/${env}/*`;
|
|
34
|
+
}
|
|
35
|
+
/** GitHub and Forgejo: the train workflow (#5154). */
|
|
36
|
+
export function renderTrainWorkflow(o) {
|
|
37
|
+
const defaults = o.root ? [" defaults:", " run:", ` working-directory: ${o.root}`] : [];
|
|
38
|
+
const run = (l) => ` - run: ${l}`;
|
|
39
|
+
const block = (lines) => [" run: |", ...lines.map((l) => ` ${l}`)];
|
|
40
|
+
const installLines = o.install ? [run(o.install)] : [];
|
|
41
|
+
const ciFetch = run("git fetch origin 'refs/tags/ci/*:refs/tags/ci/*'");
|
|
42
|
+
const ledgerFetch = run("git fetch origin chant/lifecycle:chant/lifecycle");
|
|
43
|
+
const dispatch = o.trigger === "dispatch";
|
|
44
|
+
const env = o.env;
|
|
45
|
+
const lines = [
|
|
46
|
+
"name: chant release train",
|
|
47
|
+
"on:",
|
|
48
|
+
...(dispatch
|
|
49
|
+
? [
|
|
50
|
+
" workflow_dispatch:",
|
|
51
|
+
" inputs:",
|
|
52
|
+
" levels:",
|
|
53
|
+
" description: auto for the levels the commits and intent files give, a level for every member (major, minor or patch), or <member>=<level>, separated by spaces",
|
|
54
|
+
" required: false",
|
|
55
|
+
" default: auto",
|
|
56
|
+
" type: string",
|
|
57
|
+
]
|
|
58
|
+
: []),
|
|
59
|
+
" push:",
|
|
60
|
+
` tags: [${JSON.stringify(trainTagFilter(env))}]`,
|
|
61
|
+
"permissions:",
|
|
62
|
+
" contents: write",
|
|
63
|
+
" id-token: write",
|
|
64
|
+
...o.extra.permissions,
|
|
65
|
+
"concurrency:",
|
|
66
|
+
" group: chant-release",
|
|
67
|
+
" cancel-in-progress: false",
|
|
68
|
+
"jobs:",
|
|
69
|
+
];
|
|
70
|
+
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([
|
|
72
|
+
'git config user.name "chant release"',
|
|
73
|
+
'git config user.email "chant-release@localhost"',
|
|
74
|
+
`${o.chant} workspace train cut ${env} --at "$CHANT_RELEASE_COMMIT" --levels "\${CHANT_RELEASE_LEVELS:-auto}" --yes --json > "$RUNNER_TEMP/chant-train.json"`,
|
|
75
|
+
`echo "train=$(${field("d.train?.id")} "$RUNNER_TEMP/chant-train.json")" >> "$GITHUB_OUTPUT"`,
|
|
76
|
+
]));
|
|
77
|
+
}
|
|
78
|
+
const publishIf = dispatch ? " if: ${{ always() && (github.event_name == 'push' || (needs.cut.result == 'success' && needs.cut.outputs.train != '')) }}" : null;
|
|
79
|
+
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 ? [" CHANT_RELEASE_TRAIN: ${{ needs.cut.outputs.train }}"] : []), ...o.forgeToken]), " steps:", ...githubSetup(dispatch ? "${{ needs.gate.outputs.commit || github.sha }}" : 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
|
+
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:", " CHANT_RELEASE_TRAIN: ${{ needs.cut.outputs.train }}"] : []), " steps:", ...githubSetup(dispatch ? "${{ needs.gate.outputs.commit || github.sha }}" : undefined, o.fullSetup), run(trainFromRef), ...installLines, ...o.after.map(run));
|
|
83
|
+
}
|
|
84
|
+
return tagComments(`${lines.join("\n")}\n`);
|
|
85
|
+
}
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
* train names one of them per member: by default the newest cut release, or
|
|
8
8
|
* the one `--pin <member>=<label|digest>` picks. It refuses unless every
|
|
9
9
|
* `chant` member of the declaration has a release, so a train never leaves a
|
|
10
|
-
* member out. It is written to `_members/_workspace/<env>/trains.jsonl
|
|
10
|
+
* member out. It is written to `_members/_workspace/<env>/trains.jsonl`, or
|
|
11
|
+
* for a nested workspace inside its outer member's ledger
|
|
12
|
+
* (`_members/<outer>/_members/_workspace/<env>/trains.jsonl`).
|
|
11
13
|
*
|
|
12
14
|
* A train's digest (#4037) is over the member release digests and nothing
|
|
13
15
|
* else, so the same picks always give the same train digest, whatever the
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
* train names one of them per member: by default the newest cut release, or
|
|
8
8
|
* the one `--pin <member>=<label|digest>` picks. It refuses unless every
|
|
9
9
|
* `chant` member of the declaration has a release, so a train never leaves a
|
|
10
|
-
* member out. It is written to `_members/_workspace/<env>/trains.jsonl
|
|
10
|
+
* member out. It is written to `_members/_workspace/<env>/trains.jsonl`, or
|
|
11
|
+
* for a nested workspace inside its outer member's ledger
|
|
12
|
+
* (`_members/<outer>/_members/_workspace/<env>/trains.jsonl`).
|
|
11
13
|
*
|
|
12
14
|
* A train's digest (#4037) is over the member release digests and nothing
|
|
13
15
|
* else, so the same picks always give the same train digest, whatever the
|
|
@@ -96,6 +98,9 @@ export async function readMemberReleases(cwd, opts = {}) {
|
|
|
96
98
|
const located = locateWorkspace(cwd);
|
|
97
99
|
const declaration = readDeclaration(located.tree, "", { rootChant: true });
|
|
98
100
|
const out = [];
|
|
101
|
+
// #5136: in a nested workspace each member's ledger sits inside the outer member's.
|
|
102
|
+
const { resolveMemberLedger } = await import("../lifecycle/member-ledger.js");
|
|
103
|
+
const outer = (await resolveMemberLedger(located.rootOnDisk)).members;
|
|
99
104
|
for (const m of declaration.members) {
|
|
100
105
|
if (m.kind === REPO_KIND && m.repo !== null) {
|
|
101
106
|
out.push(await (opts.readRepo ?? readRepoReleases)(m.name, m.repo, located.rootOnDisk));
|
|
@@ -103,7 +108,7 @@ export async function readMemberReleases(cwd, opts = {}) {
|
|
|
103
108
|
}
|
|
104
109
|
if (m.kind !== "chant")
|
|
105
110
|
continue;
|
|
106
|
-
const loc = { cwd: located.rootOnDisk, member: m.dir === "." ?
|
|
111
|
+
const loc = { cwd: located.rootOnDisk, member: m.dir === "." ? outer : [...outer, m.name] };
|
|
107
112
|
const { releases } = await readAllReleases(loc);
|
|
108
113
|
const { cuts } = await readCuts(loc);
|
|
109
114
|
const newest = (digest) => cuts.filter((c) => c.releaseDigest === digest).map((c) => c.timestamp).sort().at(-1) ?? "";
|
|
@@ -489,7 +494,7 @@ async function promoteAcrossRepos(query, train, now) {
|
|
|
489
494
|
}
|
|
490
495
|
return { kind: "ran", train, record, pending: null, approved: null, ledgerError };
|
|
491
496
|
}
|
|
492
|
-
const USAGE = "chant workspace train <env> [--pin <member>=<label|digest>]... [--dry-run] [--json] | chant workspace train list <env> [--json] | chant workspace train promote <env> [<train id|digest>] [--gate <name>] [--continue] [--dry-run] [--json]";
|
|
497
|
+
const USAGE = "chant workspace train <env> [--pin <member>=<label|digest>]... [--dry-run] [--json] | chant workspace train list <env> [--json] | chant workspace train promote <env> [<train id|digest>] [--gate <name>] [--continue] [--dry-run] [--json] | chant workspace train cut <env> [--at <sha>] [--levels <levels>] [--yes] [--no-push] [--json] | chant workspace train prepare <env> [<train id|digest>] [--json] | chant workspace train publish <env> [<train id|digest>] [--yes] [--json]";
|
|
493
498
|
/** Each train with the runs that promoted it, oldest first. */
|
|
494
499
|
export function trainsWithPromotions(trains, runs) {
|
|
495
500
|
const latest = latestRuns(runs);
|
|
@@ -512,6 +517,18 @@ export async function runWorkspaceTrain(ctx) {
|
|
|
512
517
|
const rest = words[0] === "train" ? words.slice(1) : words;
|
|
513
518
|
if (rest[0] === "promote")
|
|
514
519
|
return runTrainPromote(ctx, rest.slice(1));
|
|
520
|
+
if (rest[0] === "cut") {
|
|
521
|
+
const { runTrainCut } = await import("./train-cut.js");
|
|
522
|
+
return runTrainCut(ctx, rest.slice(1));
|
|
523
|
+
}
|
|
524
|
+
if (rest[0] === "prepare") {
|
|
525
|
+
const { runTrainPrepare } = await import("./train-prepare.js");
|
|
526
|
+
return runTrainPrepare(ctx, rest.slice(1));
|
|
527
|
+
}
|
|
528
|
+
if (rest[0] === "publish") {
|
|
529
|
+
const { runTrainPublish } = await import("./train-publish.js");
|
|
530
|
+
return runTrainPublish(ctx, rest.slice(1));
|
|
531
|
+
}
|
|
515
532
|
const listing = rest[0] === "list";
|
|
516
533
|
const env = listing ? rest[1] : rest[0];
|
|
517
534
|
if (!env) {
|