@intentius/chant 0.124.100 → 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/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-evidence-claims.d.ts +12 -0
- package/dist/ci-evidence-claims.js +12 -0
- package/dist/ci-system.d.ts +66 -0
- package/dist/ci-system.js +61 -0
- 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 +374 -0
- package/dist/cli/handlers/release.d.ts +43 -2
- package/dist/cli/handlers/release.js +667 -39
- package/dist/cli/handlers/run-generate.js +11 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +44 -101
- package/dist/cli/parse-args.js +48 -0
- package/dist/cli/registry.d.ts +16 -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 +50 -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 +19 -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 +15 -0
- 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/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-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 +369 -10
- package/dist/config.js +127 -7
- package/dist/deep-observation.js +9 -3
- package/dist/floor-table.data.js +21 -1
- package/dist/forge-remote.d.ts +13 -0
- package/dist/forge-remote.js +15 -0
- package/dist/lexicon.d.ts +45 -4
- 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.d.ts +62 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.js +275 -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 +13 -0
- package/dist/lifecycle/publish-declaration.d.ts +322 -4
- package/dist/lifecycle/publish-declaration.js +340 -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-helm.d.ts +83 -0
- package/dist/lifecycle/publish-helm.js +452 -0
- 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-maven.d.ts +79 -0
- package/dist/lifecycle/publish-maven.js +364 -0
- package/dist/lifecycle/publish-mcp-registry.d.ts +66 -0
- package/dist/lifecycle/publish-mcp-registry.js +305 -0
- package/dist/lifecycle/publish-npm.d.ts +27 -1
- package/dist/lifecycle/publish-npm.js +216 -3
- package/dist/lifecycle/publish-nuget.d.ts +93 -0
- package/dist/lifecycle/publish-nuget.js +377 -0
- package/dist/lifecycle/publish-oci.d.ts +91 -2
- package/dist/lifecycle/publish-oci.js +247 -8
- 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 +138 -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-rubygems.d.ts +84 -0
- package/dist/lifecycle/publish-rubygems.js +366 -0
- package/dist/lifecycle/publish-signing.d.ts +147 -0
- package/dist/lifecycle/publish-signing.js +257 -0
- package/dist/lifecycle/publish-targets.d.ts +37 -1
- package/dist/lifecycle/publish-targets.js +102 -0
- package/dist/lifecycle/publish-tauri.js +43 -0
- package/dist/lifecycle/publish-train-names.d.ts +57 -0
- package/dist/lifecycle/publish-train-names.js +123 -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 +290 -0
- package/dist/lifecycle/release-artifacts.js +808 -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 +64 -4
- package/dist/lifecycle/release-cut.js +147 -34
- package/dist/lifecycle/release-doctor.d.ts +113 -0
- package/dist/lifecycle/release-doctor.js +1198 -0
- package/dist/lifecycle/release-green.d.ts +86 -0
- package/dist/lifecycle/release-green.js +286 -0
- 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 +275 -0
- package/dist/lifecycle/release-init.js +984 -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 +251 -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 +247 -35
- 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 +322 -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/op/generate-pipeline.js +1 -1
- 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/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 +8 -1
- package/dist/release-floors.js +9 -2
- package/dist/sensitive-key.d.ts +12 -0
- package/dist/sensitive-key.js +52 -0
- package/dist/tool-pins.d.ts +40 -0
- package/dist/tool-pins.js +66 -0
- package/dist/ts-loader.d.ts +8 -0
- package/dist/ts-loader.js +19 -0
- package/dist/wave-runtime.mjs +345 -342
- 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/lexicon-outputs.d.ts +1 -1
- package/dist/workspace/lexicon-outputs.js +1 -1
- package/dist/workspace/member-pipeline.d.ts +2 -1
- package/dist/workspace/member-pipeline.js +5 -2
- package/dist/workspace/reason-codes.d.ts +2 -0
- package/dist/workspace/reason-codes.js +3 -1
- package/dist/workspace/release-changed.d.ts +75 -4
- package/dist/workspace/release-changed.js +205 -34
- package/dist/workspace/release-changed.schema.json +20 -2
- 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 +50 -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/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 +36 -0
- package/dist/workspace/release-train-workflow.js +121 -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 +183 -59
- package/dist/workspace/release-workflow.js +570 -201
- 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 +504 -0
- package/dist/workspace/train-prepare.d.ts +64 -0
- package/dist/workspace/train-prepare.js +313 -0
- package/dist/workspace/train-publish.d.ts +177 -0
- package/dist/workspace/train-publish.js +574 -0
- package/dist/workspace/train-range-labels.d.ts +33 -0
- package/dist/workspace/train-range-labels.js +109 -0
- 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/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 +1 -1
|
@@ -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,36 @@
|
|
|
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
|
+
/**
|
|
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;
|
|
35
|
+
/** GitHub and Forgejo: the train workflow (#5154). */
|
|
36
|
+
export declare function renderTrainWorkflow(o: TrainWorkflowInput): string;
|
|
@@ -0,0 +1,121 @@
|
|
|
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. 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.
|
|
20
|
+
* - publish: in a checkout of the commit, `chant workspace train prepare`
|
|
21
|
+
* (stamp each member, build the packages they need), the build, and
|
|
22
|
+
* `chant workspace train publish <env> <id> --yes`, which stages, runs the
|
|
23
|
+
* members' `release.verify`, and reveals layer by layer.
|
|
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
|
+
*
|
|
30
|
+
* The publish job also runs on a pushed `release-train/<env>/*` tag, so a
|
|
31
|
+
* train cut from a workstation with `chant workspace train cut <env> --yes`
|
|
32
|
+
* publishes from the same file. With the tag trigger (the default) that is
|
|
33
|
+
* the whole workflow. A tag the job's own token pushed starts nothing, so a
|
|
34
|
+
* dispatched run publishes in its own publish job.
|
|
35
|
+
*/
|
|
36
|
+
import { tagComments } from "../action-pins.js";
|
|
37
|
+
import { gateScript, githubSetup, jobPermissions, LEDGER_FETCH_FIRST } from "./release-workflow.js";
|
|
38
|
+
/** The tag a train's cut pushes, as a GitHub tag filter: `*` stops at `/`, so a member's own tag starts nothing. */
|
|
39
|
+
export function trainTagFilter(env) {
|
|
40
|
+
return `release-train/${env}/*`;
|
|
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)`;
|
|
64
|
+
/** GitHub and Forgejo: the train workflow (#5154). */
|
|
65
|
+
export function renderTrainWorkflow(o) {
|
|
66
|
+
const defaults = o.root ? [" defaults:", " run:", ` working-directory: ${o.root}`] : [];
|
|
67
|
+
const run = (l) => ` - run: ${l}`;
|
|
68
|
+
const block = (lines) => [" run: |", ...lines.map((l) => ` ${l}`)];
|
|
69
|
+
const installLines = o.install ? [run(o.install)] : [];
|
|
70
|
+
const ciFetch = run("git fetch origin 'refs/tags/ci/*:refs/tags/ci/*'");
|
|
71
|
+
const ledgerFetch = run("git fetch origin chant/lifecycle:chant/lifecycle");
|
|
72
|
+
const dispatch = o.trigger === "dispatch";
|
|
73
|
+
const env = o.env;
|
|
74
|
+
const lines = [
|
|
75
|
+
"name: chant release train",
|
|
76
|
+
"on:",
|
|
77
|
+
...(dispatch
|
|
78
|
+
? [
|
|
79
|
+
" workflow_dispatch:",
|
|
80
|
+
" inputs:",
|
|
81
|
+
" levels:",
|
|
82
|
+
" 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",
|
|
83
|
+
" required: false",
|
|
84
|
+
" default: auto",
|
|
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",
|
|
91
|
+
]
|
|
92
|
+
: []),
|
|
93
|
+
" push:",
|
|
94
|
+
` tags: [${JSON.stringify(trainTagFilter(env))}]`,
|
|
95
|
+
"permissions:",
|
|
96
|
+
" contents: read",
|
|
97
|
+
"concurrency:",
|
|
98
|
+
" group: chant-release",
|
|
99
|
+
" cancel-in-progress: false",
|
|
100
|
+
"jobs:",
|
|
101
|
+
];
|
|
102
|
+
if (dispatch) {
|
|
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([
|
|
104
|
+
'git config user.name "chant release"',
|
|
105
|
+
'git config user.email "chant-release@localhost"',
|
|
106
|
+
`${o.chant} workspace train cut ${env} --at "$CHANT_RELEASE_COMMIT" --levels "\${CHANT_RELEASE_LEVELS:-auto}" --yes --json > "$RUNNER_TEMP/chant-train.json"`,
|
|
107
|
+
`train="$(${trainIdScript("$RUNNER_TEMP/chant-train.json")})" || exit 1`,
|
|
108
|
+
'echo "train=$train" >> "$GITHUB_OUTPUT"',
|
|
109
|
+
]));
|
|
110
|
+
}
|
|
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 }}`;
|
|
115
|
+
const trainFromRef = `echo "CHANT_RELEASE_TRAIN=\${CHANT_RELEASE_TRAIN:-\${GITHUB_REF_NAME#release-train/${env}/}}" >> "$GITHUB_ENV"`;
|
|
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}`));
|
|
117
|
+
if (o.after.length > 0) {
|
|
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));
|
|
119
|
+
}
|
|
120
|
+
return tagComments(`${lines.join("\n")}\n`);
|
|
121
|
+
}
|
|
@@ -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) {
|