@intentius/chant 0.124.100 → 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/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/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 +42 -1
- package/dist/cli/handlers/release.js +656 -31
- 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 +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/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 +294 -9
- package/dist/config.js +100 -5
- package/dist/floor-table.data.js +15 -1
- 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/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 +8 -1
- package/dist/release-floors.js +9 -2
- package/dist/tool-pins.d.ts +38 -0
- package/dist/tool-pins.js +54 -0
- 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 +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 +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 +1 -1
|
@@ -18,18 +18,27 @@
|
|
|
18
18
|
* publish job runs `chant release stamp <label>` before its build, and
|
|
19
19
|
* `chant release publish` accepts a tree whose only changes are those files
|
|
20
20
|
* as the commit's own stamped with the release's label
|
|
21
|
-
* ({@link stampedChanges}).
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* ({@link stampedChanges}). By default only `version` changes. With
|
|
22
|
+
* `ranges` (#5155) each workspace dependency's range follows the label the
|
|
23
|
+
* release or a train gives that package: `exact` and `caret` for the
|
|
24
|
+
* packages the release stamps, `train` also for the packages of the other
|
|
25
|
+
* members a release train pins, which `chant workspace train prepare`
|
|
26
|
+
* (#5154) stamps for every member a train cut from one commit. A package
|
|
27
|
+
* path may leave the member as long as it stays inside the repository
|
|
28
|
+
* (#5154), so `release/core` can stamp `../../packages/core`. `files` (#5156) names
|
|
29
|
+
* other manifests the label goes into, by format, field or pattern, edited
|
|
30
|
+
* in place (./release-version-formats.ts).
|
|
25
31
|
*
|
|
26
32
|
* This module reaches only Node's built-ins and git.
|
|
27
33
|
*/
|
|
28
34
|
import { execFileSync } from "node:child_process";
|
|
29
35
|
import { existsSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
|
30
36
|
import { isAbsolute, posix, relative, resolve } from "node:path";
|
|
37
|
+
import { ManifestStampError, resolveVersionFile, stampVersionFile, versionFilePath } from "./release-version-formats.js";
|
|
38
|
+
export { MANIFEST_FORMATS } from "./release-version-formats.js";
|
|
31
39
|
/** The first chant with `release.version` and `chant release stamp` (#4840). Products feature-detect on it. */
|
|
32
40
|
export const RELEASE_VERSION_FLOOR = "0.124.79";
|
|
41
|
+
const RANGE_FIELDS = ["dependencies", "peerDependencies", "optionalDependencies"];
|
|
33
42
|
export class ReleaseVersionError extends Error {
|
|
34
43
|
constructor(code, message, fix) {
|
|
35
44
|
super(message);
|
|
@@ -43,36 +52,85 @@ const SEMVER = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[
|
|
|
43
52
|
/** Refuse a label `package.json` can't carry as its version. */
|
|
44
53
|
export function checkVersionLabel(label) {
|
|
45
54
|
if (label === null) {
|
|
46
|
-
throw new ReleaseVersionError("release-version-no-label", "release.version stamps the release's label
|
|
55
|
+
throw new ReleaseVersionError("release-version-no-label", "release.version stamps the release's label as the version, and this release has no label", "Cut it with a label: chant release cut <version>.");
|
|
47
56
|
}
|
|
48
57
|
if (!SEMVER.test(label)) {
|
|
49
|
-
throw new ReleaseVersionError("release-version-label-invalid", `release.version stamps the label
|
|
58
|
+
throw new ReleaseVersionError("release-version-label-invalid", `release.version stamps the label as the version, and "${label}" is not a version npm takes`, `Label the release MAJOR.MINOR.PATCH, such as ${SEMVER.test(label.replace(/^v/, "")) ? label.replace(/^v/, "") : "1.4.0"}${/^v\d/.test(label) ? ", with no v" : ""}.`);
|
|
50
59
|
}
|
|
51
60
|
}
|
|
52
61
|
const norm = (p) => posix.normalize(p.split("\\").join("/")).replace(/\/$/, "") || ".";
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Whether `p` leaves the repository (#5154). A path may climb out of the
|
|
64
|
+
* member with `..`, so a member under `release/<member>` can stamp
|
|
65
|
+
* `../../packages/core`, as long as it stays inside the repository that
|
|
66
|
+
* holds the member. Without `where`, only an absolute path is refused.
|
|
67
|
+
*/
|
|
68
|
+
function outside(p, where) {
|
|
69
|
+
if (isAbsolute(p))
|
|
70
|
+
return true;
|
|
71
|
+
if (!where)
|
|
72
|
+
return false;
|
|
73
|
+
const rel = relative(where.top, resolve(where.cwd, norm(p))).split("\\").join("/");
|
|
74
|
+
return rel === ".." || rel.startsWith("../") || isAbsolute(rel);
|
|
75
|
+
}
|
|
76
|
+
/** The repository root that holds `cwd`, or `cwd` itself outside git. */
|
|
77
|
+
function repositoryTop(cwd) {
|
|
78
|
+
try {
|
|
79
|
+
return realpathSync(execFileSync("git", ["rev-parse", "--show-toplevel"], { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim());
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return cwd;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Check the declaration: at least one package or file, every path inside the
|
|
87
|
+
* repository (`where`: the member's directory and the repository root; a path
|
|
88
|
+
* may leave the member, #5154), each file's format known.
|
|
89
|
+
*/
|
|
90
|
+
export function checkReleaseVersion(config, where) {
|
|
91
|
+
if (config.ranges !== undefined && !["keep", "exact", "caret", "train"].includes(config.ranges)) {
|
|
92
|
+
throw new ReleaseVersionError("release-version-invalid", `release.version.ranges is "${String(config.ranges)}", not keep, exact, caret or train`);
|
|
93
|
+
}
|
|
94
|
+
const files = config.files ?? [];
|
|
95
|
+
if ((config.packages ?? []).length === 0 && files.length === 0)
|
|
96
|
+
throw new ReleaseVersionError("release-version-invalid", "release.version names no package directory and no file");
|
|
97
|
+
for (const p of [...(config.packages ?? []), ...(typeof config.lockfile === "string" ? [config.lockfile] : []), ...files.map(versionFilePath)]) {
|
|
98
|
+
if (outside(p, where))
|
|
99
|
+
throw new ReleaseVersionError("release-version-invalid", `release.version: ${p} is not a path inside the repository`, "Name the path relative to the member's chant.config.ts; it may leave the member with .., as long as it stays inside the repository.");
|
|
100
|
+
}
|
|
101
|
+
const seen = new Set();
|
|
102
|
+
for (const f of files) {
|
|
103
|
+
const path = norm(versionFilePath(f));
|
|
104
|
+
if (seen.has(path))
|
|
105
|
+
throw new ReleaseVersionError("release-version-invalid", `release.version.files names ${path} twice`, "Stamp a file with one entry: a pattern with several capture groups reaches several places.");
|
|
106
|
+
seen.add(path);
|
|
107
|
+
asVersionError(() => resolveVersionFile(f));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/** Run `fn`, turning a format's refusal into a {@link ReleaseVersionError}. */
|
|
111
|
+
function asVersionError(fn) {
|
|
112
|
+
try {
|
|
113
|
+
return fn();
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
if (err instanceof ManifestStampError)
|
|
117
|
+
throw new ReleaseVersionError(err.code, err.message, err.fix);
|
|
118
|
+
throw err;
|
|
61
119
|
}
|
|
62
120
|
}
|
|
63
121
|
/** The lockfile the declaration names, relative to the member, or null. */
|
|
64
122
|
function lockfileOf(cwd, config) {
|
|
65
|
-
if (config.lockfile === false)
|
|
123
|
+
if (config.lockfile === false || (config.packages ?? []).length === 0)
|
|
66
124
|
return null;
|
|
67
125
|
if (typeof config.lockfile === "string")
|
|
68
126
|
return norm(config.lockfile);
|
|
69
127
|
return existsSync(resolve(cwd, "package-lock.json")) ? "package-lock.json" : null;
|
|
70
128
|
}
|
|
71
|
-
/** The files the release stamps, relative to the member: each package's `package.json`, then the lockfile
|
|
129
|
+
/** The files the release stamps, relative to the member: each package's `package.json`, then the lockfile, then `files`. */
|
|
72
130
|
export function releaseVersionFiles(cwd, config) {
|
|
73
|
-
const files = config.packages.map((p) => (norm(p) === "." ? "package.json" : `${norm(p)}/package.json`));
|
|
131
|
+
const files = (config.packages ?? []).map((p) => (norm(p) === "." ? "package.json" : `${norm(p)}/package.json`));
|
|
74
132
|
const lock = lockfileOf(cwd, config);
|
|
75
|
-
return lock ? [...files
|
|
133
|
+
return [...files, ...(lock ? [lock] : []), ...(config.files ?? []).map((f) => norm(versionFilePath(f)))];
|
|
76
134
|
}
|
|
77
135
|
/** The indent a JSON file was written with, so the stamped file differs from it in the version alone. */
|
|
78
136
|
function indentOf(text) {
|
|
@@ -84,18 +142,44 @@ function rewrite(text, edit) {
|
|
|
84
142
|
const out = JSON.stringify(doc, null, indentOf(text));
|
|
85
143
|
return text.endsWith("\n") ? `${out}\n` : out;
|
|
86
144
|
}
|
|
145
|
+
/** The range a dependency takes under `mode` at `label`. */
|
|
146
|
+
function rangeAt(mode, label) {
|
|
147
|
+
return mode === "exact" ? label : `^${label}`;
|
|
148
|
+
}
|
|
149
|
+
/** The workspace dependencies' ranges in one `dependencies`-bearing object, rewritten in place. A range of `*` is left. */
|
|
150
|
+
function rewriteRanges(holder, mode, table, self) {
|
|
151
|
+
for (const field of RANGE_FIELDS) {
|
|
152
|
+
const deps = holder[field];
|
|
153
|
+
if (!deps || typeof deps !== "object")
|
|
154
|
+
continue;
|
|
155
|
+
const map = deps;
|
|
156
|
+
for (const name of Object.keys(map)) {
|
|
157
|
+
if (name === self || !table.has(name) || map[name] === "*")
|
|
158
|
+
continue;
|
|
159
|
+
const label = table.get(name);
|
|
160
|
+
if (label === null || label === undefined) {
|
|
161
|
+
throw new ReleaseVersionError("release-ranges-unpinned", `${name} is a package of a member the train pins with no label, so its range in ${field} has no version to take`, "Cut that member with a label, record the train again, and stamp from it.");
|
|
162
|
+
}
|
|
163
|
+
map[name] = rangeAt(mode, label);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
87
167
|
/**
|
|
88
168
|
* One file's text stamped with `label`: a `package.json`'s `version`, or a
|
|
89
169
|
* lockfile's entries for `packageDirs` (relative to the lockfile's
|
|
90
170
|
* directory), with the root entry's `version` beside it for `"."`. A
|
|
91
|
-
* lockfile entry that is not there is not added.
|
|
171
|
+
* lockfile entry that is not there is not added. With `ranges` the
|
|
172
|
+
* workspace dependencies' ranges follow (#5155).
|
|
92
173
|
*/
|
|
93
|
-
export function stampText(text, label, kind, packageDirs = []) {
|
|
174
|
+
export function stampText(text, label, kind, packageDirs = [], ranges) {
|
|
175
|
+
const active = ranges && ranges.mode !== "keep" ? ranges : undefined;
|
|
94
176
|
if (kind === "package") {
|
|
95
177
|
return rewrite(text, (doc) => {
|
|
96
178
|
if (typeof doc.version !== "string")
|
|
97
179
|
throw new ReleaseVersionError("release-version-no-package", "package.json has no version to stamp");
|
|
98
180
|
doc.version = label;
|
|
181
|
+
if (active)
|
|
182
|
+
rewriteRanges(doc, active.mode, active.table, typeof doc.name === "string" ? doc.name : undefined);
|
|
99
183
|
});
|
|
100
184
|
}
|
|
101
185
|
return rewrite(text, (doc) => {
|
|
@@ -105,17 +189,51 @@ export function stampText(text, label, kind, packageDirs = []) {
|
|
|
105
189
|
const entry = packages[key];
|
|
106
190
|
if (entry && typeof entry === "object" && typeof entry.version === "string")
|
|
107
191
|
entry.version = label;
|
|
192
|
+
if (entry && typeof entry === "object" && active)
|
|
193
|
+
rewriteRanges(entry, active.mode, active.table, typeof entry.name === "string" ? entry.name : undefined);
|
|
108
194
|
if (key === "" && typeof doc.version === "string")
|
|
109
195
|
doc.version = label;
|
|
110
196
|
}
|
|
111
197
|
});
|
|
112
198
|
}
|
|
113
|
-
/**
|
|
114
|
-
function
|
|
199
|
+
/** The names of the packages `config` stamps, read from their package.json. A file that is missing or has no name is skipped; the stamp refuses it. */
|
|
200
|
+
export function ownNames(cwd, config) {
|
|
201
|
+
const names = [];
|
|
202
|
+
for (const p of config.packages ?? []) {
|
|
203
|
+
try {
|
|
204
|
+
const name = JSON.parse(readFileSync(resolve(cwd, norm(p) === "." ? "package.json" : `${norm(p)}/package.json`), "utf-8")).name;
|
|
205
|
+
if (typeof name === "string")
|
|
206
|
+
names.push(name);
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
// Refused with its own code when the stamp reads the file.
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return names;
|
|
213
|
+
}
|
|
214
|
+
/** Each stamped file's text, given its committed text. `train` is the labels a train gives other members' packages, for `ranges: "train"`. */
|
|
215
|
+
function stamper(cwd, config, label, train) {
|
|
115
216
|
const lock = lockfileOf(cwd, config);
|
|
116
217
|
const lockDir = lock ? posix.dirname(lock) : ".";
|
|
117
|
-
const dirs = config.packages.map((p) => norm(posix.relative(lockDir, norm(p))) || ".");
|
|
118
|
-
|
|
218
|
+
const dirs = (config.packages ?? []).map((p) => norm(posix.relative(lockDir, norm(p))) || ".");
|
|
219
|
+
const others = new Map((config.files ?? []).map((f) => [norm(versionFilePath(f)), f]));
|
|
220
|
+
const mode = config.ranges ?? "keep";
|
|
221
|
+
let plan;
|
|
222
|
+
if (mode !== "keep") {
|
|
223
|
+
const table = new Map();
|
|
224
|
+
if (mode === "train")
|
|
225
|
+
for (const [name, l] of Object.entries(train ?? {}))
|
|
226
|
+
table.set(name, l);
|
|
227
|
+
for (const name of ownNames(cwd, config))
|
|
228
|
+
table.set(name, label);
|
|
229
|
+
plan = { mode, table };
|
|
230
|
+
}
|
|
231
|
+
return (file, text) => {
|
|
232
|
+
const other = others.get(file);
|
|
233
|
+
if (other !== undefined)
|
|
234
|
+
return asVersionError(() => stampVersionFile(other, text, label));
|
|
235
|
+
return file === lock ? stampText(text, label, "lockfile", dirs, plan) : stampText(text, label, "package", [], plan);
|
|
236
|
+
};
|
|
119
237
|
}
|
|
120
238
|
/**
|
|
121
239
|
* Stamp the label into each file {@link releaseVersionFiles} names, and
|
|
@@ -123,13 +241,16 @@ function stamper(cwd, config, label) {
|
|
|
123
241
|
* package directory with no `package.json`, before anything is written.
|
|
124
242
|
*/
|
|
125
243
|
export function stampReleaseVersion(i) {
|
|
126
|
-
checkReleaseVersion(i.config);
|
|
244
|
+
checkReleaseVersion(i.config, { cwd: realpathSync(i.cwd), top: repositoryTop(i.cwd) });
|
|
127
245
|
checkVersionLabel(i.label);
|
|
128
|
-
const stamp = stamper(i.cwd, i.config, i.label);
|
|
246
|
+
const stamp = stamper(i.cwd, i.config, i.label, i.train);
|
|
129
247
|
const files = releaseVersionFiles(i.cwd, i.config);
|
|
248
|
+
const others = new Set((i.config.files ?? []).map((f) => norm(versionFilePath(f))));
|
|
130
249
|
const before = new Map();
|
|
131
250
|
for (const f of files) {
|
|
132
251
|
const abs = resolve(i.cwd, f);
|
|
252
|
+
if (!existsSync(abs) && others.has(f))
|
|
253
|
+
throw new ReleaseVersionError("release-version-no-file", `release.version.files names ${f}, which does not exist`, "Name the file by its path relative to the member's chant.config.ts.");
|
|
133
254
|
if (!existsSync(abs))
|
|
134
255
|
throw new ReleaseVersionError("release-version-no-package", `release.version names ${f}, which does not exist`, "Name the directory that holds the package.json, as the npm target does.");
|
|
135
256
|
before.set(f, readFileSync(abs, "utf-8"));
|
|
@@ -140,8 +261,10 @@ export function stampReleaseVersion(i) {
|
|
|
140
261
|
after.set(f, stamp(f, text));
|
|
141
262
|
}
|
|
142
263
|
catch (err) {
|
|
264
|
+
if (err instanceof ReleaseVersionError && others.has(f))
|
|
265
|
+
throw err;
|
|
143
266
|
if (err instanceof ReleaseVersionError)
|
|
144
|
-
throw new ReleaseVersionError(err.code, `${f}: ${err.message}
|
|
267
|
+
throw new ReleaseVersionError(err.code, `${f}: ${err.message}`, err.fix);
|
|
145
268
|
throw new ReleaseVersionError("release-version-invalid", `${f} is not JSON: ${err.message}`);
|
|
146
269
|
}
|
|
147
270
|
}
|
|
@@ -178,7 +301,9 @@ export function stampedChanges(i) {
|
|
|
178
301
|
const out = new Set();
|
|
179
302
|
if (i.label === null || !SEMVER.test(i.label))
|
|
180
303
|
return out;
|
|
181
|
-
|
|
304
|
+
// Under `ranges: "train"` a tree is also the commit's when it was stamped from a train (#5155).
|
|
305
|
+
const label = i.label;
|
|
306
|
+
const stamps = [stamper(i.cwd, i.config, label), ...(i.config.ranges === "train" ? (i.trains ?? []).map((t) => stamper(i.cwd, i.config, label, t)) : [])];
|
|
182
307
|
const files = new Set(releaseVersionFiles(i.cwd, i.config));
|
|
183
308
|
// git prints the top as its real path (macOS's /private/var for /var).
|
|
184
309
|
const cwd = realpathSync(i.cwd);
|
|
@@ -194,15 +319,18 @@ export function stampedChanges(i) {
|
|
|
194
319
|
const committed = gitShow(i.cwd, i.commit, rel);
|
|
195
320
|
if (committed === null)
|
|
196
321
|
continue;
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
322
|
+
const actual = readFileSync(resolve(i.cwd, rel), "utf-8");
|
|
323
|
+
for (const stamp of stamps) {
|
|
324
|
+
try {
|
|
325
|
+
if (stamp(rel, committed) === actual) {
|
|
326
|
+
out.add(path);
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
catch {
|
|
331
|
+
// This stamp can't be made from the commit's file; try the next.
|
|
332
|
+
}
|
|
203
333
|
}
|
|
204
|
-
if (readFileSync(resolve(i.cwd, rel), "utf-8") === expected)
|
|
205
|
-
out.add(path);
|
|
206
334
|
}
|
|
207
335
|
return out;
|
|
208
336
|
}
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
* - the actor: `--actor`, else the principal the signers file at base lists
|
|
18
18
|
* for the signing key, else the CI's actor, else git's `user.email`, else
|
|
19
19
|
* `$USER`.
|
|
20
|
-
* - the tag: `release
|
|
20
|
+
* - the tag: what `release.tag` renders (./release-tag.ts), by default
|
|
21
|
+
* `release/<label>`, or `release/<member>/<label>` in a workspace
|
|
21
22
|
* member, an annotated tag on the commit that is created locally and never
|
|
22
23
|
* pushed by chant.
|
|
23
24
|
*/
|
|
@@ -77,7 +78,7 @@ export declare function resolveCutActor(req: {
|
|
|
77
78
|
actor: string;
|
|
78
79
|
source: ActorSource;
|
|
79
80
|
} | undefined;
|
|
80
|
-
/** The tag a labelled release gets: `release/<label>`, or `release/<member>/<label>` for a workspace member. */
|
|
81
|
+
/** The tag a labelled release gets when `release.tag` is unset: `release/<label>`, or `release/<member>/<label>` for a workspace member. See ./release-tag.ts. */
|
|
81
82
|
export declare function releaseTagName(member: string | null, label: string): string;
|
|
82
83
|
/**
|
|
83
84
|
* Whether `tag` can name `commit`: `absent` (the cut creates it), `present`
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
* - the actor: `--actor`, else the principal the signers file at base lists
|
|
18
18
|
* for the signing key, else the CI's actor, else git's `user.email`, else
|
|
19
19
|
* `$USER`.
|
|
20
|
-
* - the tag: `release
|
|
20
|
+
* - the tag: what `release.tag` renders (./release-tag.ts), by default
|
|
21
|
+
* `release/<label>`, or `release/<member>/<label>` in a workspace
|
|
21
22
|
* member, an annotated tag on the commit that is created locally and never
|
|
22
23
|
* pushed by chant.
|
|
23
24
|
*/
|
|
@@ -169,7 +170,7 @@ export function resolveCutActor(req) {
|
|
|
169
170
|
return { actor: env.USER, source: "user" };
|
|
170
171
|
return undefined;
|
|
171
172
|
}
|
|
172
|
-
/** The tag a labelled release gets: `release/<label>`, or `release/<member>/<label>` for a workspace member. */
|
|
173
|
+
/** The tag a labelled release gets when `release.tag` is unset: `release/<label>`, or `release/<member>/<label>` for a workspace member. See ./release-tag.ts. */
|
|
173
174
|
export function releaseTagName(member, label) {
|
|
174
175
|
return member ? `release/${member}/${label}` : `release/${label}`;
|
|
175
176
|
}
|
|
@@ -69,7 +69,7 @@ export async function generateOpsPipeline(ops, lexicon, options, cwd) {
|
|
|
69
69
|
if (!plugin?.generateOpPipeline) {
|
|
70
70
|
return {
|
|
71
71
|
success: false,
|
|
72
|
-
error: `Lexicon "${lexicon}" does not support Op generate mode (no generateOpPipeline). GitLab, GitHub, and
|
|
72
|
+
error: `Lexicon "${lexicon}" does not support Op generate mode (no generateOpPipeline). GitLab, GitHub, Forgejo and Prow are supported today.`,
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
75
|
const discovered = await discoverOps({ cwd });
|
package/dist/pr-forge-base.js
CHANGED
|
@@ -22,8 +22,10 @@ export function pullRequestBaseFromEnv(kind, env = process.env, fetchImpl = (url
|
|
|
22
22
|
}
|
|
23
23
|
const token = env.CHANT_FORGE_TOKEN ?? env.GITHUB_TOKEN ?? env.GH_TOKEN;
|
|
24
24
|
const api = env.GITHUB_API_URL ?? (kind === "github" ? "https://api.github.com" : undefined);
|
|
25
|
-
|
|
25
|
+
// #5170: a Prow job names its GitHub repository in Prow's own variables, as `prowJobOf` in ./pr-forge.ts reads them.
|
|
26
|
+
const repo = env.GITHUB_REPOSITORY || (kind === "github" && env.PROW_JOB_ID && env.REPO_OWNER && env.REPO_NAME ? `${env.REPO_OWNER}/${env.REPO_NAME}` : undefined);
|
|
27
|
+
if (!repo || !token || !api)
|
|
26
28
|
return undefined;
|
|
27
29
|
const headers = kind === "github" ? { authorization: `Bearer ${token}`, accept: "application/vnd.github+json", "user-agent": "chant" } : { authorization: `token ${token}`, accept: "application/json" };
|
|
28
|
-
return (pr) => read(`${api.replace(/\/+$/, "")}/repos/${
|
|
30
|
+
return (pr) => read(`${api.replace(/\/+$/, "")}/repos/${repo}/pulls/${pr}`, headers, (b) => (b.base && typeof b.base === "object" ? b.base.ref : undefined));
|
|
29
31
|
}
|
package/dist/pr-forge.d.ts
CHANGED
|
@@ -626,11 +626,25 @@ export declare class ForgeEnvironmentError extends Error {
|
|
|
626
626
|
*/
|
|
627
627
|
export declare function forgeFromEnv(kind: ForgeKind, env?: Record<string, string | undefined>, fetchImpl?: ForgeFetch): PrForge;
|
|
628
628
|
type Env = Record<string, string | undefined>;
|
|
629
|
+
/**
|
|
630
|
+
* What a Prow job's pod says about its GitHub repository (#5170), or
|
|
631
|
+
* undefined outside a Prow job. Prow's pod utilities set `PROW_JOB_ID` in
|
|
632
|
+
* every job, `REPO_OWNER` and `REPO_NAME` in a presubmit and a postsubmit
|
|
633
|
+
* (and a periodic with `extra_refs`), `PULL_NUMBER` and `PULL_PULL_SHA` in a
|
|
634
|
+
* presubmit, and `PULL_BASE_SHA` beside them. Prow is the CI system here, and
|
|
635
|
+
* GitHub is still the forge whose API chant reads.
|
|
636
|
+
*/
|
|
637
|
+
export declare function prowJobOf(env?: Env): {
|
|
638
|
+
repo?: string;
|
|
639
|
+
pr?: number;
|
|
640
|
+
sha?: string;
|
|
641
|
+
} | undefined;
|
|
629
642
|
/**
|
|
630
643
|
* The forge a CI job runs on, from its environment, or undefined outside a
|
|
631
|
-
* GitHub Actions, GitLab CI
|
|
644
|
+
* GitHub Actions, GitLab CI, Forgejo Actions or Prow job. Forgejo is told apart by
|
|
632
645
|
* `FORGEJO_ACTIONS` or `GITEA_ACTIONS`, or by a GitHub-style job whose
|
|
633
|
-
* `GITHUB_API_URL` ends in `/api/v1`, which GitHub never serves.
|
|
646
|
+
* `GITHUB_API_URL` ends in `/api/v1`, which GitHub never serves. A Prow job
|
|
647
|
+
* that names its repository ({@link prowJobOf}) is on GitHub (#5170).
|
|
634
648
|
*/
|
|
635
649
|
export declare function detectForge(env?: Env): ForgeKind | undefined;
|
|
636
650
|
/** Where a CI job posts: the forge, the repository, the token, and the pull request and commit when there are ones. */
|
|
@@ -687,6 +701,10 @@ export declare const FORGE_TOKEN_ORDER: Record<ForgeKind, readonly string[]>;
|
|
|
687
701
|
* `GITHUB_REF`, its head from the payload, else `GITHUB_SHA`.
|
|
688
702
|
* - Forgejo Actions: the same, with `FORGEJO_*` read before `GITHUB_*`,
|
|
689
703
|
* and the REST base `<server>/api/v1` when no API URL is set.
|
|
704
|
+
* - Prow, for the GitHub forge (#5170): the same `GITHUB_*` names when the
|
|
705
|
+
* job sets them, else `REPO_OWNER`/`REPO_NAME`, `PULL_NUMBER`, and
|
|
706
|
+
* `PULL_PULL_SHA` or `PULL_BASE_SHA` ({@link prowJobOf}). The token comes
|
|
707
|
+
* from the job's own variables, such as a Secret mounted as `GITHUB_TOKEN`.
|
|
690
708
|
* - GitLab CI: `CI_API_V4_URL` (or `CI_SERVER_URL/api/v4`), the merge
|
|
691
709
|
* request's project before the pipeline's (a fork's merge request runs in
|
|
692
710
|
* the fork), `CI_MERGE_REQUEST_IID`, `CI_COMMIT_SHA`, `CI_PIPELINE_URL`.
|
package/dist/pr-forge.js
CHANGED
|
@@ -1329,8 +1329,11 @@ export function forgeFromEnv(kind, env = process.env, fetchImpl) {
|
|
|
1329
1329
|
}
|
|
1330
1330
|
const token = env.CHANT_FORGE_TOKEN ?? env.GITHUB_TOKEN ?? env.GH_TOKEN;
|
|
1331
1331
|
const host = hostOf(env.GITHUB_SERVER_URL);
|
|
1332
|
+
// #5170: a Prow job names its GitHub repository in Prow's own variables.
|
|
1333
|
+
const prow = kind === "github" ? prowJobOf(env) : undefined;
|
|
1334
|
+
const repo = env.GITHUB_REPOSITORY || prow?.repo;
|
|
1332
1335
|
const missing = [
|
|
1333
|
-
...(
|
|
1336
|
+
...(repo ? [] : [prow ? PROW_REPO_MISSING : "GITHUB_REPOSITORY"]),
|
|
1334
1337
|
...(token ? [] : ["GITHUB_TOKEN or CHANT_FORGE_TOKEN"]),
|
|
1335
1338
|
...(kind === "forgejo" && !host ? ["GITHUB_SERVER_URL"] : []),
|
|
1336
1339
|
...(kind === "forgejo" && !env.GITHUB_API_URL ? ["GITHUB_API_URL"] : []),
|
|
@@ -1338,11 +1341,11 @@ export function forgeFromEnv(kind, env = process.env, fetchImpl) {
|
|
|
1338
1341
|
if (missing.length > 0)
|
|
1339
1342
|
throw new ForgeEnvironmentError(kind, missing);
|
|
1340
1343
|
const runUrl = env.GITHUB_SERVER_URL && env.GITHUB_RUN_ID
|
|
1341
|
-
? `${env.GITHUB_SERVER_URL.replace(/\/+$/, "")}/${
|
|
1344
|
+
? `${env.GITHUB_SERVER_URL.replace(/\/+$/, "")}/${repo}/actions/runs/${env.GITHUB_RUN_ID}`
|
|
1342
1345
|
: undefined;
|
|
1343
1346
|
const opts = {
|
|
1344
1347
|
apiBase: env.GITHUB_API_URL ?? "https://api.github.com",
|
|
1345
|
-
repo:
|
|
1348
|
+
repo: repo,
|
|
1346
1349
|
token: token,
|
|
1347
1350
|
...(runUrl ? { runUrl } : {}),
|
|
1348
1351
|
...f,
|
|
@@ -1350,11 +1353,34 @@ export function forgeFromEnv(kind, env = process.env, fetchImpl) {
|
|
|
1350
1353
|
return kind === "forgejo" ? forgejoForge({ ...opts, host: host }) : githubForge({ ...opts, host: host ?? "github.com" });
|
|
1351
1354
|
}
|
|
1352
1355
|
const truthy = (v) => v === "true" || v === "1";
|
|
1356
|
+
const PROW_REPO_MISSING = "GITHUB_REPOSITORY, or REPO_OWNER and REPO_NAME from Prow";
|
|
1357
|
+
/**
|
|
1358
|
+
* What a Prow job's pod says about its GitHub repository (#5170), or
|
|
1359
|
+
* undefined outside a Prow job. Prow's pod utilities set `PROW_JOB_ID` in
|
|
1360
|
+
* every job, `REPO_OWNER` and `REPO_NAME` in a presubmit and a postsubmit
|
|
1361
|
+
* (and a periodic with `extra_refs`), `PULL_NUMBER` and `PULL_PULL_SHA` in a
|
|
1362
|
+
* presubmit, and `PULL_BASE_SHA` beside them. Prow is the CI system here, and
|
|
1363
|
+
* GitHub is still the forge whose API chant reads.
|
|
1364
|
+
*/
|
|
1365
|
+
export function prowJobOf(env = process.env) {
|
|
1366
|
+
if (!env.PROW_JOB_ID?.trim())
|
|
1367
|
+
return undefined;
|
|
1368
|
+
const owner = env.REPO_OWNER?.trim();
|
|
1369
|
+
const name = env.REPO_NAME?.trim();
|
|
1370
|
+
const pr = num(env.PULL_NUMBER?.trim());
|
|
1371
|
+
const sha = env.PULL_PULL_SHA?.trim() || env.PULL_BASE_SHA?.trim();
|
|
1372
|
+
return {
|
|
1373
|
+
...(owner && name ? { repo: `${owner}/${name}` } : {}),
|
|
1374
|
+
...(pr !== undefined && pr > 0 ? { pr } : {}),
|
|
1375
|
+
...(sha ? { sha } : {}),
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1353
1378
|
/**
|
|
1354
1379
|
* The forge a CI job runs on, from its environment, or undefined outside a
|
|
1355
|
-
* GitHub Actions, GitLab CI
|
|
1380
|
+
* GitHub Actions, GitLab CI, Forgejo Actions or Prow job. Forgejo is told apart by
|
|
1356
1381
|
* `FORGEJO_ACTIONS` or `GITEA_ACTIONS`, or by a GitHub-style job whose
|
|
1357
|
-
* `GITHUB_API_URL` ends in `/api/v1`, which GitHub never serves.
|
|
1382
|
+
* `GITHUB_API_URL` ends in `/api/v1`, which GitHub never serves. A Prow job
|
|
1383
|
+
* that names its repository ({@link prowJobOf}) is on GitHub (#5170).
|
|
1358
1384
|
*/
|
|
1359
1385
|
export function detectForge(env = process.env) {
|
|
1360
1386
|
if (truthy(env.GITLAB_CI))
|
|
@@ -1363,6 +1389,8 @@ export function detectForge(env = process.env) {
|
|
|
1363
1389
|
return "forgejo";
|
|
1364
1390
|
if (truthy(env.GITHUB_ACTIONS))
|
|
1365
1391
|
return /\/api\/v1\/?$/.test(env.GITHUB_API_URL ?? "") ? "forgejo" : "github";
|
|
1392
|
+
if (prowJobOf(env)?.repo)
|
|
1393
|
+
return "github";
|
|
1366
1394
|
return undefined;
|
|
1367
1395
|
}
|
|
1368
1396
|
/**
|
|
@@ -1410,6 +1438,10 @@ function prFromEvent(payload, ref) {
|
|
|
1410
1438
|
* `GITHUB_REF`, its head from the payload, else `GITHUB_SHA`.
|
|
1411
1439
|
* - Forgejo Actions: the same, with `FORGEJO_*` read before `GITHUB_*`,
|
|
1412
1440
|
* and the REST base `<server>/api/v1` when no API URL is set.
|
|
1441
|
+
* - Prow, for the GitHub forge (#5170): the same `GITHUB_*` names when the
|
|
1442
|
+
* job sets them, else `REPO_OWNER`/`REPO_NAME`, `PULL_NUMBER`, and
|
|
1443
|
+
* `PULL_PULL_SHA` or `PULL_BASE_SHA` ({@link prowJobOf}). The token comes
|
|
1444
|
+
* from the job's own variables, such as a Secret mounted as `GITHUB_TOKEN`.
|
|
1413
1445
|
* - GitLab CI: `CI_API_V4_URL` (or `CI_SERVER_URL/api/v4`), the merge
|
|
1414
1446
|
* request's project before the pipeline's (a fork's merge request runs in
|
|
1415
1447
|
* the fork), `CI_MERGE_REQUEST_IID`, `CI_COMMIT_SHA`, `CI_PIPELINE_URL`.
|
|
@@ -1458,7 +1490,9 @@ export function forgeTargetFromEnv(env = process.env, opts = {}) {
|
|
|
1458
1490
|
}
|
|
1459
1491
|
const fj = kind === "forgejo";
|
|
1460
1492
|
const read = (name) => (fj ? pick(`FORGEJO_${name}`, `GITHUB_${name}`) : pick(`GITHUB_${name}`));
|
|
1461
|
-
|
|
1493
|
+
// #5170: in a Prow job, Prow's variables name what GitHub Actions' would; a GITHUB_* one set by the job still wins.
|
|
1494
|
+
const prow = fj ? undefined : prowJobOf(env);
|
|
1495
|
+
const repo = read("REPOSITORY") ?? prow?.repo;
|
|
1462
1496
|
const server = read("SERVER_URL")?.replace(/\/+$/, "");
|
|
1463
1497
|
const apiBase = read("API_URL")?.replace(/\/+$/, "") ?? (fj ? (server ? `${server}/api/v1` : undefined) : "https://api.github.com");
|
|
1464
1498
|
let event;
|
|
@@ -1472,18 +1506,20 @@ export function forgeTargetFromEnv(env = process.env, opts = {}) {
|
|
|
1472
1506
|
event = undefined;
|
|
1473
1507
|
}
|
|
1474
1508
|
}
|
|
1475
|
-
const
|
|
1509
|
+
const fromEvent = prFromEvent(event, read("REF"));
|
|
1510
|
+
const pr = fromEvent.pr ?? prow?.pr;
|
|
1511
|
+
const head = fromEvent.sha;
|
|
1476
1512
|
if (!repo)
|
|
1477
|
-
missing.push(fj ? "FORGEJO_REPOSITORY or GITHUB_REPOSITORY" : "GITHUB_REPOSITORY");
|
|
1513
|
+
missing.push(fj ? "FORGEJO_REPOSITORY or GITHUB_REPOSITORY" : prow ? PROW_REPO_MISSING : "GITHUB_REPOSITORY");
|
|
1478
1514
|
if (!apiBase)
|
|
1479
1515
|
missing.push("GITHUB_SERVER_URL or GITHUB_API_URL");
|
|
1480
1516
|
if (opts.requirePr && !pr)
|
|
1481
|
-
missing.push(
|
|
1517
|
+
missing.push(`a pull request (a pull_request event, ${prow ? "refs/pull/<n>/ in GITHUB_REF, or PULL_NUMBER from a Prow presubmit" : "or refs/pull/<n>/ in GITHUB_REF"})`);
|
|
1482
1518
|
if (!token)
|
|
1483
1519
|
missing.push(tokenMissing);
|
|
1484
1520
|
if (missing.length > 0)
|
|
1485
1521
|
throw new ForgeEnvironmentError(kind, missing);
|
|
1486
|
-
const sha = head ?? read("SHA");
|
|
1522
|
+
const sha = head ?? read("SHA") ?? prow?.sha;
|
|
1487
1523
|
const runId = read("RUN_ID");
|
|
1488
1524
|
const runUrl = server && runId ? `${server}/${repo}/actions/runs/${runId}` : undefined;
|
|
1489
1525
|
return {
|
package/dist/release-floors.d.ts
CHANGED
|
@@ -18,8 +18,15 @@
|
|
|
18
18
|
* version into every floor that names this constant as a literal, and moves
|
|
19
19
|
* this constant to the next patch (#4501). The check fails while a floor
|
|
20
20
|
* still names this constant after its version shipped.
|
|
21
|
+
*
|
|
22
|
+
* A new floor is declared next to the code it gates, in that feature's own
|
|
23
|
+
* file, as `export const <NAME>_FLOOR = NEXT_RELEASE;` with NEXT_RELEASE
|
|
24
|
+
* imported from here (#5196): scripts/floor-table.ts collects every floor
|
|
25
|
+
* under packages/core/src, so parallel features add floors to different
|
|
26
|
+
* files rather than to the end of this one. The floors below were declared
|
|
27
|
+
* here before that and keep the subpath they shipped under.
|
|
21
28
|
*/
|
|
22
|
-
export declare const NEXT_RELEASE = "0.124.
|
|
29
|
+
export declare const NEXT_RELEASE = "0.124.101";
|
|
23
30
|
/** The first chant with `chant dev local` and `chant dev bundle-check`, `@intentius/chant/local-chant` and `@intentius/chant/bundle-check` (`chantRuntimeTarget`, `chantExternalPlugin`, `checkBundle`): a product built against a chant checkout, and its bundle checked, without its own scripts (#4787). */
|
|
24
31
|
export declare const LOCAL_CHANT_FLOOR = "0.124.86";
|
|
25
32
|
/** The first chant with `chant workspace ref-gate` (pre-receive, pre-push, check, status, attach, install) and `refs` in `.chant/trust.json`, the checks a ref update needs evidence for (#4867). */
|
package/dist/release-floors.js
CHANGED
|
@@ -18,8 +18,15 @@
|
|
|
18
18
|
* version into every floor that names this constant as a literal, and moves
|
|
19
19
|
* this constant to the next patch (#4501). The check fails while a floor
|
|
20
20
|
* still names this constant after its version shipped.
|
|
21
|
+
*
|
|
22
|
+
* A new floor is declared next to the code it gates, in that feature's own
|
|
23
|
+
* file, as `export const <NAME>_FLOOR = NEXT_RELEASE;` with NEXT_RELEASE
|
|
24
|
+
* imported from here (#5196): scripts/floor-table.ts collects every floor
|
|
25
|
+
* under packages/core/src, so parallel features add floors to different
|
|
26
|
+
* files rather than to the end of this one. The floors below were declared
|
|
27
|
+
* here before that and keep the subpath they shipped under.
|
|
21
28
|
*/
|
|
22
|
-
export const NEXT_RELEASE = "0.124.
|
|
29
|
+
export const NEXT_RELEASE = "0.124.101";
|
|
23
30
|
/** The first chant with `chant dev local` and `chant dev bundle-check`, `@intentius/chant/local-chant` and `@intentius/chant/bundle-check` (`chantRuntimeTarget`, `chantExternalPlugin`, `checkBundle`): a product built against a chant checkout, and its bundle checked, without its own scripts (#4787). */
|
|
24
31
|
export const LOCAL_CHANT_FLOOR = "0.124.86";
|
|
25
32
|
/** The first chant with `chant workspace ref-gate` (pre-receive, pre-push, check, status, attach, install) and `refs` in `.chant/trust.json`, the checks a ref update needs evidence for (#4867). */
|
|
@@ -193,4 +200,4 @@ export const TERRAFORM_COMMAND_TRACE_FLOOR = "0.124.91";
|
|
|
193
200
|
/** The first chant whose product pipeline limits comment commands to logins and teams on GitHub and Forgejo (INTENTIUS/terragucci#1461): `commentAllow: { allow, tokenSecret? }` in `productPipelineJobs`, where `allow` maps `plan`, `apply`, `lock`, `unlock`, `agent` and `default` to logins and `team:<org>/<team>` entries. The map is written as `CHANT_COMMENT_ALLOW` into the comment job, the product plan's re-plan decision and the agent's jobs (a spec's `agent.commentAllow`), so it is read from the workflow on the default branch. `answerProductComment` takes `allow` and replies to a commenter the list leaves out, `ForgeReads.teamMember` reads a team on GitHub and Forgejo, `CHANT_COMMENT_ALLOW_TOKEN` (`tokenSecret`) carries a token that can read teams, and a team the forge cannot answer for fails closed with a message. */
|
|
194
201
|
export const COMMENT_ALLOW_FLOOR = "0.124.98";
|
|
195
202
|
/** The first chant with `chant release changed`, the members to release at a commit with their dependency closure, and `release.legacyTags` in `chant.config.ts` (#5134). */
|
|
196
|
-
export const RELEASE_CHANGED_FLOOR =
|
|
203
|
+
export const RELEASE_CHANGED_FLOOR = "0.124.100";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The command-line tools the workflows chant generates download, each pinned
|
|
3
|
+
* by the SHA-256 of its release file for every platform a job runs on, as
|
|
4
|
+
* {@link ./image-pins.ts} pins images by digest and ../action-pins.ts pins
|
|
5
|
+
* actions by commit. A generated step downloads the file, checks it against
|
|
6
|
+
* the digest and refuses to run anything else, so a moved release asset
|
|
7
|
+
* fails the job instead of running. Each row names the release it was read
|
|
8
|
+
* from, so an update is one change here.
|
|
9
|
+
*
|
|
10
|
+
* Refresh a row from the release's checksums file:
|
|
11
|
+
*
|
|
12
|
+
* curl -sL https://github.com/sigstore/cosign/releases/download/v3.1.4/cosign_checksums.txt | grep -E 'cosign-linux-(amd64|arm64)$'
|
|
13
|
+
* gh release download v2.19.0 -R goreleaser/goreleaser -p checksums.txt -O - | grep -E 'goreleaser_Linux_(x86_64|arm64)\.tar\.gz$'
|
|
14
|
+
*/
|
|
15
|
+
export interface ToolPin {
|
|
16
|
+
/** The tool's name: the binary the step leaves in its directory. */
|
|
17
|
+
readonly name: string;
|
|
18
|
+
/** The release the row was read from, such as `v3.1.4`. */
|
|
19
|
+
readonly version: string;
|
|
20
|
+
/** Set when each platform's file is a `.tar.gz` that holds the binary, rather than the binary itself. */
|
|
21
|
+
readonly archive?: boolean;
|
|
22
|
+
/** Each platform's download URL and the SHA-256 of the file, as hex. */
|
|
23
|
+
readonly platforms: Readonly<Record<string, {
|
|
24
|
+
readonly url: string;
|
|
25
|
+
readonly sha256: string;
|
|
26
|
+
}>>;
|
|
27
|
+
}
|
|
28
|
+
export declare const TOOL_PINS: {
|
|
29
|
+
readonly cosign: ToolPin;
|
|
30
|
+
readonly goreleaser: ToolPin;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Shell that downloads `pin` for `platform` into `dir`, checks its SHA-256
|
|
34
|
+
* and leaves the executable `<dir>/<name>`: made executable, or unpacked
|
|
35
|
+
* from the archive. It fails, and so fails the step, when the file is not
|
|
36
|
+
* the pinned one. Throws for a platform the row has no file for.
|
|
37
|
+
*/
|
|
38
|
+
export declare function toolInstallLine(pin: ToolPin, platform: string, dir: string): string;
|