@intentius/chant 0.124.102 → 0.124.104
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/audit/secrets.d.ts +6 -0
- package/dist/audit/secrets.js +9 -2
- package/dist/cli/commands/import-index.d.ts +15 -0
- package/dist/cli/commands/import-index.js +37 -3
- package/dist/cli/commands/onboard.js +8 -8
- package/dist/cli/handlers/lifecycle.js +6 -0
- package/dist/cli/handlers/release-config.d.ts +15 -0
- package/dist/cli/handlers/release-config.js +58 -0
- package/dist/cli/handlers/release-init.js +3 -1
- package/dist/cli/handlers/release.js +36 -3
- package/dist/cli/main.js +24 -3
- package/dist/cli/parse-args.js +12 -0
- package/dist/cli/registry.d.ts +4 -0
- package/dist/cli/release-commands/cut.js +3 -0
- package/dist/cloud-lister/kubernetes-components.js +1 -2
- package/dist/config-import.js +26 -4
- package/dist/config.d.ts +14 -0
- package/dist/config.js +4 -0
- package/dist/floor-table.data.js +13 -11
- package/dist/floor-table.js +3 -1
- package/dist/graph-refs.d.ts +9 -0
- package/dist/graph-refs.js +9 -7
- package/dist/lifecycle/cloud-index.d.ts +6 -0
- package/dist/lifecycle/cloud-index.js +32 -5
- package/dist/lifecycle/identity-match.d.ts +18 -2
- package/dist/lifecycle/identity-match.js +10 -5
- package/dist/lifecycle/index-drift.d.ts +13 -0
- package/dist/lifecycle/index-drift.js +21 -3
- package/dist/lifecycle/index-import.d.ts +15 -0
- package/dist/lifecycle/index-import.js +25 -2
- package/dist/lifecycle/index-join.d.ts +1 -1
- package/dist/lifecycle/index-join.js +1 -1
- package/dist/lifecycle/publish-declaration.d.ts +6 -0
- package/dist/lifecycle/publish-declaration.js +19 -3
- package/dist/lifecycle/publish-forge.d.ts +2 -0
- package/dist/lifecycle/publish-forge.js +3 -1
- package/dist/lifecycle/publish-helm.js +1 -2
- package/dist/lifecycle/publish-maven.js +1 -2
- package/dist/lifecycle/publish-npm.js +1 -1
- package/dist/lifecycle/publish-nuget.js +1 -2
- package/dist/lifecycle/publish-oci.d.ts +27 -0
- package/dist/lifecycle/publish-oci.js +63 -8
- package/dist/lifecycle/publish-rubygems.js +1 -2
- package/dist/lifecycle/release-artifacts.js +1 -2
- package/dist/lifecycle/release-changelog.d.ts +18 -5
- package/dist/lifecycle/release-changelog.js +22 -10
- package/dist/lifecycle/release-cut.d.ts +13 -1
- package/dist/lifecycle/release-cut.js +3 -0
- package/dist/lifecycle/release-images.d.ts +32 -2
- package/dist/lifecycle/release-images.js +70 -2
- package/dist/lifecycle/release-init-goreleaser-images.d.ts +21 -0
- package/dist/lifecycle/release-init-goreleaser-images.js +160 -0
- package/dist/lifecycle/release-init.d.ts +22 -0
- package/dist/lifecycle/release-init.js +96 -16
- package/dist/local-chant.d.ts +3 -0
- package/dist/local-chant.js +28 -2
- package/dist/release-floors.d.ts +10 -6
- package/dist/release-floors.js +10 -6
- package/dist/ts-loader.d.ts +12 -3
- package/dist/ts-loader.js +27 -11
- package/dist/wave-runtime.mjs +291 -290
- package/dist/workspace/catalog-edges.d.ts +22 -0
- package/dist/workspace/catalog-edges.js +23 -0
- package/dist/workspace/release-steps/goreleaser.d.ts +6 -3
- package/dist/workspace/release-steps/goreleaser.js +12 -6
- package/dist/workspace/release-toolchains.d.ts +6 -0
- package/dist/workspace/release-toolchains.js +8 -0
- package/dist/workspace/release-train-workflow.d.ts +39 -3
- package/dist/workspace/release-train-workflow.js +258 -9
- package/dist/workspace/release-train.js +5 -1
- package/dist/workspace/release-workflow.d.ts +37 -0
- package/dist/workspace/release-workflow.js +97 -16
- package/dist/workspace/train-artifacts.d.ts +107 -0
- package/dist/workspace/train-artifacts.js +238 -0
- package/dist/workspace/train-cut.d.ts +34 -1
- package/dist/workspace/train-cut.js +98 -14
- package/dist/workspace/train-publish.d.ts +9 -0
- package/dist/workspace/train-publish.js +27 -1
- package/package.json +2 -2
|
@@ -49,6 +49,13 @@ export const RELEASE_IMAGES_FLOOR = "0.124.71";
|
|
|
49
49
|
export const RELEASE_IMAGE_DOCKERFILE_FLOOR = "0.124.78";
|
|
50
50
|
/** The first chant whose Dockerfile entry in `release.images` takes `args`, build arguments beside the two chant passes (#4908). */
|
|
51
51
|
export const RELEASE_IMAGE_ARGS_FLOOR = "0.124.88";
|
|
52
|
+
/**
|
|
53
|
+
* The first chant whose Dockerfile entry takes `labels`, OCI labels on the
|
|
54
|
+
* image, and `{label}` and `{version}` in `args` and `labels` values, and
|
|
55
|
+
* whose image builds see `CHANT_RELEASE_VERSION`; and whose default archive
|
|
56
|
+
* moves out of a goreleaser entry's `dist` (#5269).
|
|
57
|
+
*/
|
|
58
|
+
export const RELEASE_IMAGE_LABELS_FLOOR = "0.124.104";
|
|
52
59
|
/** The platforms a Dockerfile entry builds by default. Building arm64 on amd64 needs QEMU's binfmt handlers. */
|
|
53
60
|
export const RELEASE_IMAGE_PLATFORMS = ["linux/amd64", "linux/arm64"];
|
|
54
61
|
/** The buildx builder a Dockerfile entry builds with, created with the `docker-container` driver when missing: the default driver cannot rewrite timestamps in an OCI archive. */
|
|
@@ -58,6 +65,14 @@ const PLATFORM = /^[a-z0-9]+\/[a-z0-9_]+(?:\/[a-z0-9]+)?$/;
|
|
|
58
65
|
const sh = (s) => (/^[A-Za-z0-9_./:=,@+%-]+$/.test(s) ? s : `'${s.replace(/'/g, "'\\''")}'`);
|
|
59
66
|
const isDockerfile = (i) => "dockerfile" in i && i.dockerfile !== undefined;
|
|
60
67
|
const archiveOf = (i) => i.archive ?? `dist/images/${i.name}.tar`;
|
|
68
|
+
/** The placeholders an `args` or `labels` value takes (#5269), each the variable the build command reads. */
|
|
69
|
+
const PLACEHOLDERS = { "{label}": '"$CHANT_RELEASE_LABEL"', "{version}": '"$CHANT_RELEASE_VERSION"' };
|
|
70
|
+
/** `s` as one shell word, its `{label}` and `{version}` read from the build's environment (#5269). */
|
|
71
|
+
const word = (s) => s
|
|
72
|
+
.split(/(\{label\}|\{version\})/)
|
|
73
|
+
.filter((p) => p.length > 0)
|
|
74
|
+
.map((p) => PLACEHOLDERS[p] ?? sh(p))
|
|
75
|
+
.join("");
|
|
61
76
|
/**
|
|
62
77
|
* The shell command a Dockerfile entry builds with (#4819), the one
|
|
63
78
|
* terragucci's and plywood's `scripts/release-image.sh` ran: `--no-cache`,
|
|
@@ -74,12 +89,52 @@ export function releaseImageBuildCommand(i, o = {}) {
|
|
|
74
89
|
[
|
|
75
90
|
`docker buildx build --builder ${b} --no-cache --platform ${sh((i.platforms ?? RELEASE_IMAGE_PLATFORMS).join(","))}`,
|
|
76
91
|
`--provenance=false --sbom=false --build-arg SOURCE_DATE_EPOCH="$SOURCE_DATE_EPOCH"${o.versionArg ? ' --build-arg CHANT_RELEASE_LABEL="$CHANT_RELEASE_LABEL"' : ""}${Object.entries(i.args ?? {})
|
|
77
|
-
.map(([k, v]) => ` --build-arg ${
|
|
92
|
+
.map(([k, v]) => ` --build-arg ${word(`${k}=${v}`)}`)
|
|
93
|
+
.join("")}${Object.entries(i.labels ?? {})
|
|
94
|
+
.map(([k, v]) => ` --label ${word(`${k}=${v}`)}`)
|
|
78
95
|
.join("")}`,
|
|
79
96
|
`--output ${sh(`type=oci,dest=${archive},rewrite-timestamp=true`)} -f ${sh(i.dockerfile)} ${sh(i.context ?? ".")} >&2`,
|
|
80
97
|
].join(" "),
|
|
81
98
|
].join(" && ");
|
|
82
99
|
}
|
|
100
|
+
/** The archive of a Dockerfile entry that names none and whose default would be inside a goreleaser entry's `dist` (#5269). */
|
|
101
|
+
export const imageArchiveBesideGoreleaser = (name) => `build/images/${name}.tar`;
|
|
102
|
+
/** `p` is `dir` or inside it, both relative to the member. */
|
|
103
|
+
const within = (p, dir) => {
|
|
104
|
+
const a = posix.normalize(p.replace(/\\/g, "/"));
|
|
105
|
+
const d = posix.normalize(dir.replace(/\\/g, "/")).replace(/\/$/, "");
|
|
106
|
+
return d === "." || a === d || a.startsWith(`${d}/`);
|
|
107
|
+
};
|
|
108
|
+
/** The `dist` directory of each goreleaser entry in `release.artifacts` (#5269). */
|
|
109
|
+
const goreleaserDists = (artifacts) => artifacts.flatMap((a) => {
|
|
110
|
+
const g = a?.goreleaser;
|
|
111
|
+
return g && typeof g === "object" ? [typeof g.dist === "string" ? g.dist : "dist"] : [];
|
|
112
|
+
});
|
|
113
|
+
/**
|
|
114
|
+
* A member's `release.images` with each archive placed (#5269). goreleaser
|
|
115
|
+
* empties its `dist` (`--clean`) when it builds, after the images, so an
|
|
116
|
+
* archive there would be gone before the cut records it: a Dockerfile entry
|
|
117
|
+
* that names no archive, whose default `dist/images/<name>.tar` is inside a
|
|
118
|
+
* goreleaser entry's `dist`, writes {@link imageArchiveBesideGoreleaser}
|
|
119
|
+
* instead. An archive named inside it is left for
|
|
120
|
+
* {@link checkImagesOutsideGoreleaser} to refuse.
|
|
121
|
+
*/
|
|
122
|
+
export function placeReleaseImages(images, artifacts = []) {
|
|
123
|
+
const dists = goreleaserDists(artifacts);
|
|
124
|
+
if (dists.length === 0)
|
|
125
|
+
return [...images];
|
|
126
|
+
return images.map((i) => (isDockerfile(i) && i.archive === undefined && dists.some((d) => within(archiveOf(i), d)) ? { ...i, archive: imageArchiveBesideGoreleaser(i.name) } : i));
|
|
127
|
+
}
|
|
128
|
+
/** Refuse an image archive inside a goreleaser entry's `dist` (#5269), which goreleaser empties after the images are built. */
|
|
129
|
+
export function checkImagesOutsideGoreleaser(images, artifacts = []) {
|
|
130
|
+
const dists = goreleaserDists(artifacts);
|
|
131
|
+
for (const i of images) {
|
|
132
|
+
const dist = dists.find((d) => within(archiveOf(i), d));
|
|
133
|
+
if (dist === undefined)
|
|
134
|
+
continue;
|
|
135
|
+
throw new ReleaseImageError("release-image-archive-in-dist", `release.images "${i.name}": the archive ${archiveOf(i)} is inside ${dist}, which goreleaser empties when it builds the release's files, after the images`, `Write it outside ${dist}, such as archive: "${imageArchiveBesideGoreleaser(i.name)}".`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
83
138
|
/** Each entry as a command and an archive: a Dockerfile entry's command is {@link releaseImageBuildCommand}, its archive the default when it names none. */
|
|
84
139
|
export function resolveReleaseImages(images, o = {}) {
|
|
85
140
|
return images.map((i) => (isDockerfile(i) ? { name: i.name, build: releaseImageBuildCommand(i, o), archive: archiveOf(i) } : i));
|
|
@@ -102,6 +157,7 @@ export class ReleaseImageError extends Error {
|
|
|
102
157
|
}
|
|
103
158
|
const NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/;
|
|
104
159
|
const BUILD_ARG = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
160
|
+
const LABEL_KEY = /^[A-Za-z0-9][A-Za-z0-9._\/-]*$/;
|
|
105
161
|
/** The build arguments chant passes itself, which an entry's `args` cannot set. */
|
|
106
162
|
const CHANT_BUILD_ARGS = ["SOURCE_DATE_EPOCH", "CHANT_RELEASE_LABEL"];
|
|
107
163
|
const outside = (p) => isAbsolute(p) || p.split(/[\\/]/).includes("..");
|
|
@@ -121,6 +177,12 @@ export function checkReleaseImages(images) {
|
|
|
121
177
|
if (p !== undefined && outside(p))
|
|
122
178
|
throw new ReleaseImageError("release-image-archive-outside", `release.images "${i.name}": ${what} ${p} is not a path inside the member`);
|
|
123
179
|
}
|
|
180
|
+
for (const [k, v] of Object.entries((isDockerfile(i) && i.labels) || {})) {
|
|
181
|
+
if (!LABEL_KEY.test(k))
|
|
182
|
+
throw new ReleaseImageError("release-image-invalid", `release.images "${i.name}": labels names ${JSON.stringify(k)}, which is not a label key such as org.opencontainers.image.version`);
|
|
183
|
+
if (typeof v !== "string" || /[\r\n]/.test(v))
|
|
184
|
+
throw new ReleaseImageError("release-image-invalid", `release.images "${i.name}": labels.${k} is not a one-line string`);
|
|
185
|
+
}
|
|
124
186
|
for (const [k, v] of Object.entries((isDockerfile(i) && i.args) || {})) {
|
|
125
187
|
if (!BUILD_ARG.test(k))
|
|
126
188
|
throw new ReleaseImageError("release-image-invalid", `release.images "${i.name}": args names ${JSON.stringify(k)}, which is not a build argument name`);
|
|
@@ -138,7 +200,8 @@ const defaultRun = (command, o) => spawnSync(command, { cwd: o.cwd, env: o.env,
|
|
|
138
200
|
/**
|
|
139
201
|
* Build each image and return it as the release's image artifact. The
|
|
140
202
|
* command runs with `SOURCE_DATE_EPOCH` and, for a cut with a label,
|
|
141
|
-
* `CHANT_RELEASE_LABEL
|
|
203
|
+
* `CHANT_RELEASE_LABEL` and `CHANT_RELEASE_VERSION` (the label from its
|
|
204
|
+
* first digit, when it has one); an archive it did not write, or a command that
|
|
142
205
|
* fails, stops the cut.
|
|
143
206
|
*/
|
|
144
207
|
export function buildReleaseImages(i) {
|
|
@@ -148,8 +211,13 @@ export function buildReleaseImages(i) {
|
|
|
148
211
|
const envFor = () => {
|
|
149
212
|
const env = { ...(i.env ?? process.env), SOURCE_DATE_EPOCH: String(i.sourceDateEpoch) };
|
|
150
213
|
delete env.CHANT_RELEASE_LABEL;
|
|
214
|
+
delete env.CHANT_RELEASE_VERSION;
|
|
151
215
|
if (i.label !== null)
|
|
152
216
|
env.CHANT_RELEASE_LABEL = i.label;
|
|
217
|
+
// #5269: the label from its first digit, for an entry's {version}.
|
|
218
|
+
const at = i.label?.search(/\d/) ?? -1;
|
|
219
|
+
if (i.label !== null && at >= 0)
|
|
220
|
+
env.CHANT_RELEASE_VERSION = i.label.slice(at);
|
|
153
221
|
return env;
|
|
154
222
|
};
|
|
155
223
|
// #4819: each prepare command once, before any build, with no digests file, as the image's contents are built in the cut and the publish job alike.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** The image a goreleaser config builds, as `release init` declares it. */
|
|
2
|
+
export interface GoreleaserImage {
|
|
3
|
+
/** The `release.images` entry's name: the repository's last segment. */
|
|
4
|
+
name: string;
|
|
5
|
+
repository: string;
|
|
6
|
+
dockerfile: string;
|
|
7
|
+
platforms: string[];
|
|
8
|
+
args: Record<string, string>;
|
|
9
|
+
labels: Record<string, string>;
|
|
10
|
+
/** The oci target's tags. */
|
|
11
|
+
tags: string[];
|
|
12
|
+
/** The oci target's `platformTags`, such as `{version}-{arch}`. */
|
|
13
|
+
platformTags: string[];
|
|
14
|
+
archive: string;
|
|
15
|
+
/** The goreleaser keys the plan replaces, to remove from the config. */
|
|
16
|
+
keys: string[];
|
|
17
|
+
/** What was not carried, each in words. */
|
|
18
|
+
unread: string[];
|
|
19
|
+
}
|
|
20
|
+
/** The image a goreleaser config builds, or null when it builds none with `dockers` or `dockers_v2`. */
|
|
21
|
+
export declare function goreleaserImage(text: string): GoreleaserImage | null;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `chant release init` for a goreleaser config that builds container images
|
|
3
|
+
* (#5269): its `dockers` (with `docker_manifests`) or `dockers_v2` read as
|
|
4
|
+
* one `release.images` Dockerfile entry and an `oci` target with the same
|
|
5
|
+
* repository, tags, per-platform tags, build arguments and labels, so a
|
|
6
|
+
* project that adopts the plan keeps publishing its image. What does not
|
|
7
|
+
* translate is named, never dropped without a word.
|
|
8
|
+
*
|
|
9
|
+
* goreleaser's templates map to chant's placeholders: `{{ .Version }}` is
|
|
10
|
+
* `{version}`. Any other template is not carried.
|
|
11
|
+
*/
|
|
12
|
+
import { parseYAML } from "../yaml.js";
|
|
13
|
+
import { imageArchiveBesideGoreleaser } from "./release-images.js";
|
|
14
|
+
const VERSION = /\{\{\s*\.Version\s*\}\}/g;
|
|
15
|
+
/** A goreleaser template as a chant value, or null when it holds a template chant has no placeholder for. */
|
|
16
|
+
function template(t) {
|
|
17
|
+
const v = t.replace(VERSION, "{version}");
|
|
18
|
+
return /\{\{/.test(v) ? null : v;
|
|
19
|
+
}
|
|
20
|
+
/** `repo:tag` split at the tag's colon (a registry port's colon comes before the last slash). */
|
|
21
|
+
function splitRef(ref) {
|
|
22
|
+
const at = ref.lastIndexOf(":");
|
|
23
|
+
if (at <= ref.lastIndexOf("/"))
|
|
24
|
+
return null;
|
|
25
|
+
return { repository: ref.slice(0, at), tag: ref.slice(at + 1) };
|
|
26
|
+
}
|
|
27
|
+
const strings = (v) => (Array.isArray(v) ? v.filter((x) => typeof x === "string") : typeof v === "string" ? [v] : []);
|
|
28
|
+
/** `--build-arg=K=V`, `--label=K=V` and `--platform=...` flags into args and labels; the rest is not carried. */
|
|
29
|
+
function readFlags(flags, into) {
|
|
30
|
+
for (const f of flags) {
|
|
31
|
+
const m = /^--(build-arg|label)[= ]([^=\s]+)=(.*)$/.exec(f.trim());
|
|
32
|
+
if (m) {
|
|
33
|
+
const value = template(m[3]);
|
|
34
|
+
if (value === null)
|
|
35
|
+
into.unread.push(`the ${m[1]} ${m[2]}=${m[3]}, whose template chant has no placeholder for`);
|
|
36
|
+
else
|
|
37
|
+
(m[1] === "label" ? into.labels : into.args)[m[2]] = value;
|
|
38
|
+
}
|
|
39
|
+
else if (!/^--platform[= ]/.test(f.trim()))
|
|
40
|
+
into.unread.push(`the build flag ${f}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** The image a goreleaser config builds, or null when it builds none with `dockers` or `dockers_v2`. */
|
|
44
|
+
export function goreleaserImage(text) {
|
|
45
|
+
let doc;
|
|
46
|
+
try {
|
|
47
|
+
doc = parseYAML(text);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
if (!doc || typeof doc !== "object")
|
|
53
|
+
return null;
|
|
54
|
+
const unread = [];
|
|
55
|
+
const args = {};
|
|
56
|
+
const labels = {};
|
|
57
|
+
const flags = { args, labels, unread };
|
|
58
|
+
const platforms = [];
|
|
59
|
+
const tags = [];
|
|
60
|
+
const platformTags = new Set();
|
|
61
|
+
const repositories = new Set();
|
|
62
|
+
const dockerfiles = new Set();
|
|
63
|
+
const keys = [];
|
|
64
|
+
const addTag = (raw) => {
|
|
65
|
+
const t = template(raw);
|
|
66
|
+
if (t === null)
|
|
67
|
+
unread.push(`the tag ${raw}, whose template chant has no placeholder for`);
|
|
68
|
+
else if (!tags.includes(t))
|
|
69
|
+
tags.push(t);
|
|
70
|
+
};
|
|
71
|
+
const v2 = Array.isArray(doc.dockers_v2) ? doc.dockers_v2 : [];
|
|
72
|
+
const v1 = Array.isArray(doc.dockers) ? doc.dockers : [];
|
|
73
|
+
if (v2.length > 0) {
|
|
74
|
+
keys.push("dockers_v2");
|
|
75
|
+
for (const d of v2) {
|
|
76
|
+
for (const r of strings(d.images))
|
|
77
|
+
repositories.add(r);
|
|
78
|
+
dockerfiles.add(typeof d.dockerfile === "string" ? d.dockerfile : "Dockerfile");
|
|
79
|
+
for (const p of strings(d.platforms))
|
|
80
|
+
if (!platforms.includes(p))
|
|
81
|
+
platforms.push(p);
|
|
82
|
+
for (const t of strings(d.tags))
|
|
83
|
+
addTag(t);
|
|
84
|
+
for (const [k, v] of Object.entries(d.build_args ?? {})) {
|
|
85
|
+
const value = typeof v === "string" ? template(v) : null;
|
|
86
|
+
if (value === null)
|
|
87
|
+
unread.push(`the build argument ${k}, whose value chant can't carry`);
|
|
88
|
+
else
|
|
89
|
+
args[k] = value;
|
|
90
|
+
}
|
|
91
|
+
for (const [k, v] of Object.entries(d.labels ?? {})) {
|
|
92
|
+
const value = typeof v === "string" ? template(v) : null;
|
|
93
|
+
if (value === null)
|
|
94
|
+
unread.push(`the label ${k}, whose value chant can't carry`);
|
|
95
|
+
else
|
|
96
|
+
labels[k] = value;
|
|
97
|
+
}
|
|
98
|
+
readFlags(strings(d.flags), flags);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (v1.length > 0) {
|
|
102
|
+
keys.push("dockers");
|
|
103
|
+
// The images each entry pushes: per platform, or the whole image when there are no manifests.
|
|
104
|
+
const manifests = Array.isArray(doc.docker_manifests) ? doc.docker_manifests : [];
|
|
105
|
+
if (manifests.length > 0)
|
|
106
|
+
keys.push("docker_manifests");
|
|
107
|
+
for (const d of v1) {
|
|
108
|
+
const goos = typeof d.goos === "string" ? d.goos : "linux";
|
|
109
|
+
const goarch = typeof d.goarch === "string" ? d.goarch : "amd64";
|
|
110
|
+
const variant = goarch === "arm" && d.goarm !== undefined ? `v${String(d.goarm)}` : "";
|
|
111
|
+
const platform = `${goos}/${goarch}${variant ? `/${variant}` : ""}`;
|
|
112
|
+
if (!platforms.includes(platform))
|
|
113
|
+
platforms.push(platform);
|
|
114
|
+
dockerfiles.add(typeof d.dockerfile === "string" ? d.dockerfile : "Dockerfile");
|
|
115
|
+
readFlags(strings(d.build_flag_templates), flags);
|
|
116
|
+
for (const ref of strings(d.image_templates)) {
|
|
117
|
+
const r = splitRef(ref);
|
|
118
|
+
if (!r) {
|
|
119
|
+
unread.push(`the image ${ref}, which names no tag`);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
repositories.add(r.repository);
|
|
123
|
+
const t = template(r.tag);
|
|
124
|
+
const arch = `${goarch}${variant}`;
|
|
125
|
+
if (manifests.length === 0)
|
|
126
|
+
addTag(r.tag);
|
|
127
|
+
else if (t !== null && t.includes(arch))
|
|
128
|
+
platformTags.add(t.split(arch).join("{arch}"));
|
|
129
|
+
else
|
|
130
|
+
unread.push(`the per-platform tag ${r.tag}, which does not name its platform's architecture`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
for (const m of manifests) {
|
|
134
|
+
const name = typeof m.name_template === "string" ? splitRef(m.name_template) : null;
|
|
135
|
+
if (!name)
|
|
136
|
+
continue;
|
|
137
|
+
repositories.add(name.repository);
|
|
138
|
+
addTag(name.tag);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (keys.length === 0)
|
|
142
|
+
return null;
|
|
143
|
+
if (Object.keys(doc).includes("kos"))
|
|
144
|
+
unread.push("the kos images, which chant does not build");
|
|
145
|
+
const [repository, ...others] = [...repositories];
|
|
146
|
+
if (!repository)
|
|
147
|
+
return null;
|
|
148
|
+
if (others.length > 0)
|
|
149
|
+
unread.push(`the images pushed to ${others.join(", ")}, as one oci target pushes to one repository`);
|
|
150
|
+
const [dockerfile, ...moreFiles] = [...dockerfiles];
|
|
151
|
+
if (moreFiles.length > 0)
|
|
152
|
+
unread.push(`the images built from ${moreFiles.join(", ")}, as one entry builds one Dockerfile`);
|
|
153
|
+
const name = (repository.split("/").pop() ?? "image").toLowerCase().replace(/[^a-z0-9._-]+/g, "-") || "image";
|
|
154
|
+
// A platform tag that names no version would move with every release; chant tags each release's own.
|
|
155
|
+
const ownTags = [...platformTags].filter((t) => t.includes("{version}") || t.includes("{label}"));
|
|
156
|
+
for (const t of platformTags)
|
|
157
|
+
if (!ownTags.includes(t))
|
|
158
|
+
unread.push(`the per-platform tag ${t}, which names no version`);
|
|
159
|
+
return { name, repository, dockerfile: dockerfile ?? "Dockerfile", platforms, args, labels, tags, platformTags: ownTags, archive: imageArchiveBesideGoreleaser(name), keys, unread };
|
|
160
|
+
}
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* the forge. Everything it can't set up from the repository, such as an npm
|
|
18
18
|
* trusted publisher, is a step printed for a person ({@link ReleaseInitPlan.registry}).
|
|
19
19
|
*/
|
|
20
|
+
import { type GoreleaserImage } from "./release-init-goreleaser-images.js";
|
|
20
21
|
import { type RegistryProjectFacts } from "./release-init-registries.js";
|
|
21
22
|
export type ReleaseInitCode = "release-init-release-exists" | "release-init-config-unreadable" | "release-init-workflow-exists" | "release-init-not-a-project" | "release-init-member-exists" | "release-init-tsx-missing";
|
|
22
23
|
/** A refusal of `chant release init`, with its code. */
|
|
@@ -103,6 +104,14 @@ export interface ProjectFacts {
|
|
|
103
104
|
snapshot: boolean;
|
|
104
105
|
/** The config builds images (`dockers:` or `kos:`). */
|
|
105
106
|
images: boolean;
|
|
107
|
+
/** Its `changelog.filters` (#5270): the types left out, or the patterns no commit type names. */
|
|
108
|
+
changelog?: {
|
|
109
|
+
exclude: string[];
|
|
110
|
+
} | {
|
|
111
|
+
unread: string[];
|
|
112
|
+
} | null;
|
|
113
|
+
/** The image its `dockers` or `dockers_v2` build (#5269), as release.images and an oci target declare it. */
|
|
114
|
+
image?: GoreleaserImage | null;
|
|
106
115
|
} | null;
|
|
107
116
|
/** Helm charts (#5233): each directory holding a `Chart.yaml`, from the project root, and the chart's name. A chart inside another's directory is its subchart and is not listed. */
|
|
108
117
|
charts?: Array<{
|
|
@@ -120,6 +129,8 @@ export interface ProjectFacts {
|
|
|
120
129
|
chantCi: boolean;
|
|
121
130
|
/** `.gitignore` ignores `dist/`. */
|
|
122
131
|
distIgnored: boolean;
|
|
132
|
+
/** `.gitignore` ignores `build/`, where an image beside goreleaser's dist is written (#5269). */
|
|
133
|
+
buildIgnored?: boolean;
|
|
123
134
|
/** A `pom.xml`, `*.csproj` files or a `*.gemspec` at the root (#5232). */
|
|
124
135
|
registries?: RegistryProjectFacts;
|
|
125
136
|
}
|
|
@@ -153,6 +164,17 @@ export declare function goreleaserFacts(text: string): {
|
|
|
153
164
|
snapshot: boolean;
|
|
154
165
|
images: boolean;
|
|
155
166
|
};
|
|
167
|
+
/**
|
|
168
|
+
* A goreleaser config's `changelog` (#5270), as generated notes: the commit
|
|
169
|
+
* types its `filters.exclude` leaves out, when each pattern names one type
|
|
170
|
+
* (`^docs:`, `^chore(\(.*\))?:`), or the patterns that name none. `null` when the
|
|
171
|
+
* config generates no changelog of its own filtering.
|
|
172
|
+
*/
|
|
173
|
+
export declare function goreleaserChangelog(text: string): {
|
|
174
|
+
exclude: string[];
|
|
175
|
+
} | {
|
|
176
|
+
unread: string[];
|
|
177
|
+
} | null;
|
|
156
178
|
/** The lines a goreleaser config needs so its snapshot build carries the release's label. */
|
|
157
179
|
export declare const GORELEASER_SNAPSHOT = "snapshot:\n version_template: \"{{ .Env.CHANT_RELEASE_LABEL }}\"\n";
|
|
158
180
|
/** A `Cargo.toml`'s name, workspace, stampable version and `publish = false`. */
|
|
@@ -22,6 +22,9 @@ import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
|
22
22
|
import { basename, join, posix, relative, sep } from "node:path";
|
|
23
23
|
import { GENERATED_MARKER } from "../discovery/files.js";
|
|
24
24
|
import { forgeOfRemote } from "../forge-remote.js";
|
|
25
|
+
import { parseYAML } from "../yaml.js";
|
|
26
|
+
import { goreleaserImage } from "./release-init-goreleaser-images.js";
|
|
27
|
+
import { imageArchiveBesideGoreleaser } from "./release-images.js";
|
|
25
28
|
import { detectRegistryProjects, planRegistryTargets } from "./release-init-registries.js";
|
|
26
29
|
/** A refusal of `chant release init`, with its code. */
|
|
27
30
|
export class ReleaseInitError extends Error {
|
|
@@ -236,6 +239,40 @@ export function goreleaserFacts(text) {
|
|
|
236
239
|
images: /^(dockers|dockers_v2|kos)\s*:/m.test(text),
|
|
237
240
|
};
|
|
238
241
|
}
|
|
242
|
+
/**
|
|
243
|
+
* A goreleaser config's `changelog` (#5270), as generated notes: the commit
|
|
244
|
+
* types its `filters.exclude` leaves out, when each pattern names one type
|
|
245
|
+
* (`^docs:`, `^chore(\(.*\))?:`), or the patterns that name none. `null` when the
|
|
246
|
+
* config generates no changelog of its own filtering.
|
|
247
|
+
*/
|
|
248
|
+
export function goreleaserChangelog(text) {
|
|
249
|
+
let doc;
|
|
250
|
+
try {
|
|
251
|
+
doc = parseYAML(text);
|
|
252
|
+
}
|
|
253
|
+
catch {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
const changelog = doc?.changelog;
|
|
257
|
+
if (!changelog || typeof changelog !== "object" || changelog.disable === true)
|
|
258
|
+
return null;
|
|
259
|
+
const patterns = Array.isArray(changelog.filters?.exclude) ? changelog.filters.exclude.filter((p) => typeof p === "string") : [];
|
|
260
|
+
const include = Array.isArray(changelog.filters?.include) ? changelog.filters.include.filter((p) => typeof p === "string") : [];
|
|
261
|
+
if (patterns.length === 0 && include.length === 0)
|
|
262
|
+
return null;
|
|
263
|
+
const types = [];
|
|
264
|
+
const unread = [...include];
|
|
265
|
+
for (const p of patterns) {
|
|
266
|
+
const m = /^\^(\w+)(?:\(\\\(\.\*\\\)\)\?)?:$/.exec(p.trim());
|
|
267
|
+
if (m) {
|
|
268
|
+
if (!types.includes(m[1]))
|
|
269
|
+
types.push(m[1]);
|
|
270
|
+
}
|
|
271
|
+
else
|
|
272
|
+
unread.push(p);
|
|
273
|
+
}
|
|
274
|
+
return unread.length > 0 ? { unread } : { exclude: types };
|
|
275
|
+
}
|
|
239
276
|
/** The lines a goreleaser config needs so its snapshot build carries the release's label. */
|
|
240
277
|
export const GORELEASER_SNAPSHOT = 'snapshot:\n version_template: "{{ .Env.CHANT_RELEASE_LABEL }}"\n';
|
|
241
278
|
/** Read the project at `root` (the directory `chant release init` runs in). */
|
|
@@ -318,7 +355,13 @@ export function detectProject(root) {
|
|
|
318
355
|
const pyproject = readText(join(root, "pyproject.toml"));
|
|
319
356
|
const python = pyproject === null ? (existsSync(join(root, "setup.py")) ? { name: null, pyproject: false, version: false } : null) : pyprojectFacts(pyproject);
|
|
320
357
|
const grFile = GORELEASER_FILES.find((f) => existsSync(join(root, f)));
|
|
321
|
-
const
|
|
358
|
+
const grText = grFile ? (readText(join(root, grFile)) ?? "") : "";
|
|
359
|
+
const grImage = grFile ? goreleaserImage(grText) : null;
|
|
360
|
+
// #5269: chant builds the Dockerfile from the repository, not from goreleaser's context with the binary it built.
|
|
361
|
+
if (grImage && (readText(join(root, grImage.dockerfile)) ?? "").match(/^\s*FROM\s/gim)?.length === 1) {
|
|
362
|
+
grImage.unread.push(`a binary goreleaser builds: chant builds ${grImage.dockerfile} from the repository, and its one stage copies what goreleaser would have put in its context; give it a build stage of its own`);
|
|
363
|
+
}
|
|
364
|
+
const goreleaser = grFile ? { file: grFile, ...goreleaserFacts(grText), ...(grImage ? { image: grImage } : {}), changelog: goreleaserChangelog(grText) } : null;
|
|
322
365
|
const nfpmFile = NFPM_FILES.find((f) => existsSync(join(root, f)));
|
|
323
366
|
const nfpmVersion = nfpmFile ? /^version:[ \t]*["']?[^\n]*\$\{?CHANT_RELEASE_(VERSION|LABEL)/m.test(readText(join(root, nfpmFile)) ?? "") : false;
|
|
324
367
|
const tagList = (git(top, ["tag", "--list"]) ?? "").split("\n").map((t) => t.trim()).filter(Boolean);
|
|
@@ -342,6 +385,7 @@ export function detectProject(root) {
|
|
|
342
385
|
tags: readTagHistory(tagList),
|
|
343
386
|
chantCi: ciGreen || tagList.some((t) => t.startsWith("ci/green/") || /^ci\/green-[^/]+\//.test(t)),
|
|
344
387
|
distIgnored: /^\/?dist\/?\s*$/m.test(gitignore) || /^\/?dist\/\*\s*$/m.test(gitignore),
|
|
388
|
+
buildIgnored: /^\/?build\/?\s*$/m.test(gitignore) || /^\/?build\/\*\s*$/m.test(gitignore),
|
|
345
389
|
registries: detectRegistryProjects(root),
|
|
346
390
|
};
|
|
347
391
|
}
|
|
@@ -534,11 +578,36 @@ export function planRelease(facts, opts) {
|
|
|
534
578
|
// Images.
|
|
535
579
|
const goreleaserImages = facts.goreleaser?.images ?? false;
|
|
536
580
|
const dockerfiles = goreleaserImages ? [] : facts.dockerfiles;
|
|
537
|
-
|
|
538
|
-
|
|
581
|
+
const grImage = facts.goreleaser?.image ?? null;
|
|
582
|
+
if (goreleaserImages && !grImage)
|
|
583
|
+
notes.push(`${facts.goreleaser.file} builds its images with kos, which chant does not build, so no image is declared in release.images and the release publishes none: declare a Dockerfile entry in release.images and an oci target to keep publishing it.`);
|
|
584
|
+
else if (goreleaserImages && facts.dockerfiles.length > 0)
|
|
585
|
+
notes.push(`${facts.goreleaser.file} builds the images, so release.images declares its image alone and no other Dockerfile.`);
|
|
539
586
|
const fallbackName = (facts.origin?.repo.split("/").pop() ?? facts.node?.root.name?.replace(/^@[^/]+\//, "") ?? facts.go?.module?.split("/").pop() ?? "app");
|
|
540
587
|
const images = [];
|
|
541
588
|
const usedNames = new Set();
|
|
589
|
+
// #5269: goreleaser's image, built by chant at the cut and pushed by an oci target with goreleaser's tags.
|
|
590
|
+
if (grImage) {
|
|
591
|
+
const g = grImage;
|
|
592
|
+
usedNames.add(g.name);
|
|
593
|
+
images.push({
|
|
594
|
+
name: g.name,
|
|
595
|
+
dockerfile: g.dockerfile,
|
|
596
|
+
...(g.platforms.length > 0 ? { platforms: g.platforms } : {}),
|
|
597
|
+
archive: g.archive,
|
|
598
|
+
...(Object.keys(g.args).length > 0 ? { args: g.args } : {}),
|
|
599
|
+
...(Object.keys(g.labels).length > 0 ? { labels: g.labels } : {}),
|
|
600
|
+
});
|
|
601
|
+
publish.push({ type: "oci", image: g.archive, repository: g.repository, ...(g.tags.length > 0 ? { tags: g.tags } : {}), ...(g.platformTags.length > 0 ? { platformTags: g.platformTags } : {}) });
|
|
602
|
+
if (g.repository.startsWith("ghcr.io/"))
|
|
603
|
+
registry.push(`${g.repository}: the workflow pushes with the run's token, as goreleaser did.`);
|
|
604
|
+
else
|
|
605
|
+
registry.push(`${g.repository}: set OCI_USERNAME and OCI_PASSWORD for the release workflow, as ${forge === "gitlab" ? "masked CI/CD variables" : "secrets in release.workflow.env"}, with push access to the registry.`);
|
|
606
|
+
reasons.push(`release.images: ${g.dockerfile} built once at the cut as a reproducible OCI archive of ${g.platforms.join(", ") || "the default platforms"}, as ${facts.goreleaser.file}'s ${g.keys.join(" and ")} built it, pushed to ${g.repository} by the oci target`);
|
|
607
|
+
notes.push(`Remove ${g.keys.join(" and ")} from ${facts.goreleaser.file}: chant builds and pushes the image now, and the cut's goreleaser would build it again.`);
|
|
608
|
+
if (g.unread.length > 0)
|
|
609
|
+
notes.push(`Not carried from ${facts.goreleaser.file}'s images: ${g.unread.join("; ")}.`);
|
|
610
|
+
}
|
|
542
611
|
for (const dockerfile of dockerfiles) {
|
|
543
612
|
let name = imageName(dockerfile, fallbackName);
|
|
544
613
|
while (usedNames.has(name))
|
|
@@ -548,7 +617,7 @@ export function planRelease(facts, opts) {
|
|
|
548
617
|
images.push(dir === "." ? { name, dockerfile } : { name, dockerfile, context: dir });
|
|
549
618
|
const repository = imageRepository(facts.origin, name, dockerfiles.length === 1);
|
|
550
619
|
if (repository) {
|
|
551
|
-
publish.push({ type: "oci", image: `dist/images/${name}.tar`, repository });
|
|
620
|
+
publish.push({ type: "oci", image: facts.goreleaser ? imageArchiveBesideGoreleaser(name) : `dist/images/${name}.tar`, repository });
|
|
552
621
|
if (repository.startsWith("ghcr.io/"))
|
|
553
622
|
registry.push(`${repository}: the workflow pushes with the run's token. The first push makes the package private; make it public in the package's settings if it should be.`);
|
|
554
623
|
else
|
|
@@ -559,7 +628,8 @@ export function planRelease(facts, opts) {
|
|
|
559
628
|
}
|
|
560
629
|
if (images.length > 0) {
|
|
561
630
|
release.images = images;
|
|
562
|
-
|
|
631
|
+
if (dockerfiles.length > 0)
|
|
632
|
+
reasons.push(`release.images: ${dockerfiles.join(", ")} built once at the cut as reproducible OCI archives${publish.some((p) => p.type === "oci") ? ", pushed by the oci target" : ""}`);
|
|
563
633
|
}
|
|
564
634
|
// goreleaser.
|
|
565
635
|
let goreleaserPatch = null;
|
|
@@ -573,8 +643,15 @@ export function planRelease(facts, opts) {
|
|
|
573
643
|
release.artifacts = [{ name: "goreleaser", goreleaser: {} }];
|
|
574
644
|
reasons.push(`release.artifacts: ${gr.file} builds the binaries and archives once at the cut with goreleaser release --snapshot, and the release records each file`);
|
|
575
645
|
if (facts.origin) {
|
|
576
|
-
|
|
577
|
-
|
|
646
|
+
// #5270: a changelog that filters commit types keeps its filters as notes from commits.
|
|
647
|
+
const cl = gr.changelog;
|
|
648
|
+
const exclude = cl && "exclude" in cl ? cl.exclude : null;
|
|
649
|
+
publish.push({ type: "forge", forge: facts.origin.kind, repo: facts.origin.repo, assets: ["artifact:goreleaser"], notes: exclude ? { generate: "commits", exclude } : { generate: "forge" } });
|
|
650
|
+
reasons.push(exclude
|
|
651
|
+
? `forge target: the goreleaser files as assets of the ${facts.origin.kind} release ${facts.origin.repo}, with notes from the commits since the previous release except ${exclude.join(", ")}, as ${gr.file}'s changelog filters left them out`
|
|
652
|
+
: `forge target: the goreleaser files as assets of the ${facts.origin.kind} release ${facts.origin.repo}, with generated notes`);
|
|
653
|
+
if (cl && "unread" in cl)
|
|
654
|
+
notes.push(`${gr.file}'s changelog filters ${cl.unread.map((p) => JSON.stringify(p)).join(", ")} name no commit type, so the forge release's notes are the forge's own: set notes to { generate: "commits", types: [...] } or { generate: "commits", exclude: [...] } to filter them.`);
|
|
578
655
|
}
|
|
579
656
|
else
|
|
580
657
|
notes.push(`No forge release is declared for ${gr.file}'s files: origin names no GitHub, GitLab or Forgejo repository.`);
|
|
@@ -684,6 +761,8 @@ export function planRelease(facts, opts) {
|
|
|
684
761
|
reasons.push(`release.workflow.file ${workflowFile}: it runs npm publish today, so the npm trusted publisher that names it keeps working; the release workflow replaces it rather than publishing from a second file`);
|
|
685
762
|
if (!facts.distIgnored && (images.length > 0 || facts.goreleaser || charts.length > 0 || facts.nfpm || publish.some((p) => ["pypi", "nuget", "rubygems"].includes(p.type ?? "")) || publish.some((p) => p.type === "marketplace")))
|
|
686
763
|
notes.push("dist/ is not in .gitignore: the publish refuses a tree with build outputs git does not ignore.");
|
|
764
|
+
if (facts.goreleaser && images.length > 0 && facts.buildIgnored !== true)
|
|
765
|
+
notes.push("build/ is not in .gitignore: the images are written to build/images/, outside goreleaser's dist, and the publish refuses a tree with build outputs git does not ignore.");
|
|
687
766
|
if (forge === "gitlab")
|
|
688
767
|
registry.push(`GitLab: include ${workflowFile} from .gitlab-ci.yml, and store a project access token with write_repository as the masked CI/CD variable CHANT_RELEASE_TOKEN; the cut and publish jobs push with it.`);
|
|
689
768
|
const h = facts.tags.prefix;
|
|
@@ -711,21 +790,19 @@ export function trainFit(facts) {
|
|
|
711
790
|
return { train: false, why: `the root package ${node.root.name} is published too, and a train releases the packages below the root` };
|
|
712
791
|
const ext = [node.root, ...node.workspaces].find((p) => p.vscode && !p.private && p.name);
|
|
713
792
|
if (ext)
|
|
714
|
-
return { train: false, why: `${ext.name} is a VS Code extension, and
|
|
793
|
+
return { train: false, why: `${ext.name} is a VS Code extension, and release init makes a train's members of npm packages only` };
|
|
715
794
|
if (facts.goreleaser)
|
|
716
|
-
return { train: false, why: `${facts.goreleaser.file} builds files
|
|
795
|
+
return { train: false, why: `${facts.goreleaser.file} builds files for the repository, and release init makes a train's members of npm packages only, with none to build them` };
|
|
717
796
|
if (facts.dockerfiles.length > 0)
|
|
718
|
-
return { train: false, why: `${facts.dockerfiles[0]}
|
|
797
|
+
return { train: false, why: `${facts.dockerfiles[0]} builds an image, and release init makes a train's members of npm packages only, with none to build it` };
|
|
719
798
|
if ((facts.charts?.length ?? 0) > 0)
|
|
720
|
-
return { train: false, why: `${facts.charts[0].dir}/Chart.yaml is a chart packed at the cut,
|
|
799
|
+
return { train: false, why: `${facts.charts[0].dir}/Chart.yaml is a chart packed at the cut, and release init makes a train's members of npm packages only, with none to pack it` };
|
|
721
800
|
if (facts.nfpm)
|
|
722
|
-
return { train: false, why: `${facts.nfpm.file} packages files at the cut,
|
|
801
|
+
return { train: false, why: `${facts.nfpm.file} packages files at the cut, and release init makes a train's members of npm packages only, with none to build them` };
|
|
723
802
|
if (facts.python?.pyproject && facts.python.name)
|
|
724
|
-
return { train: false, why: "pyproject.toml
|
|
803
|
+
return { train: false, why: "pyproject.toml's package publishes beside the npm packages, and release init makes a train's members of npm packages only" };
|
|
725
804
|
if (facts.rust && !facts.rust.unpublishable && (facts.rust.name || facts.rust.workspace))
|
|
726
805
|
return { train: false, why: "Cargo.toml's crates publish beside the npm packages, and a train releases npm packages" };
|
|
727
|
-
if (facts.workflowForge === "gitlab")
|
|
728
|
-
return { train: false, why: "the train workflow renders for GitHub and Forgejo, and this repository runs GitLab CI" };
|
|
729
806
|
return { train: true };
|
|
730
807
|
}
|
|
731
808
|
/** A workspace member name (lowercase letters, digits and dashes, at most 40) for a package. */
|
|
@@ -822,8 +899,11 @@ export function planTrain(facts, opts) {
|
|
|
822
899
|
for (const m of members) {
|
|
823
900
|
registry.push(adopted
|
|
824
901
|
? `npm ${m.package}: keep the trusted publisher on npmjs.com that names ${repo} and the workflow file ${workflowName}, or add one naming them if the package has none, and allow npm dist-tag on it, since the reveal moves latest. If ${m.package} is not on npm yet, publish its first version by hand from ${m.dir} (npm publish) so it has settings; the train labels the next past it.`
|
|
825
|
-
: `npm ${m.package}: on npmjs.com, add a trusted publisher for ${forge === "github" ? "GitHub Actions" : "this forge"} naming ${repo} and the workflow file ${workflowName}, and allow npm dist-tag, since the reveal moves latest. Every package names the same file. If ${m.package} is not on npm yet, publish its first version by hand from ${m.dir} (npm publish) so it has settings; the train labels the next past it.`);
|
|
902
|
+
: `npm ${m.package}: on npmjs.com, add a trusted publisher for ${forge === "gitlab" ? `GitLab CI/CD naming ${repo} and the top-level config .gitlab-ci.yml` : `${forge === "github" ? "GitHub Actions" : "this forge"} naming ${repo} and the workflow file ${workflowName}`}, and allow npm dist-tag, since the reveal moves latest. Every package names the same file. If ${m.package} is not on npm yet, publish its first version by hand from ${m.dir} (npm publish) so it has settings; the train labels the next past it.`);
|
|
826
903
|
}
|
|
904
|
+
// #5216: a GitLab job token cannot push the train's tags.
|
|
905
|
+
if (forge === "gitlab")
|
|
906
|
+
registry.push(`GitLab: include ${workflowFile} from .gitlab-ci.yml, and store a project access token with write_repository as the masked CI/CD variable CHANT_RELEASE_TOKEN; the cut and publish jobs push with it.`);
|
|
827
907
|
const workspaceName = memberNameOf({ name: facts.origin?.repo.split("/").pop() ?? node.root.name ?? null, dir: facts.path ?? "workspace" }) || "workspace";
|
|
828
908
|
return { release, members, workspaceName, reasons, notes, registry, workflowFile, env };
|
|
829
909
|
}
|
package/dist/local-chant.d.ts
CHANGED
|
@@ -50,6 +50,9 @@ export declare function packOrder(pkgs: Map<string, ChantPackage>, want: Iterabl
|
|
|
50
50
|
* hand (0.124.34 while 0.124.87 was out), which failed a product's floor and
|
|
51
51
|
* `minReader` checks that pass on a published chant. Every floor the checkout
|
|
52
52
|
* declares is at or below `NEXT_RELEASE`, so the local build passes each one.
|
|
53
|
+
* A checkout's NEXT_RELEASE can name a release that already shipped, since a
|
|
54
|
+
* release train needs no commit to move it on (#5260), so the version is at
|
|
55
|
+
* least the patch after core's newest release tag in the checkout.
|
|
53
56
|
* The build is marked local by the `chantLocal` field on each installed copy,
|
|
54
57
|
* not in the version, because a prerelease of `NEXT_RELEASE` sorts below it.
|
|
55
58
|
*/
|
package/dist/local-chant.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* {@link resetLocalChant} goes back: `npm ci`, then a check that every
|
|
26
26
|
* installed chant package is the version the lock pins, with no mark.
|
|
27
27
|
*/
|
|
28
|
-
import { spawnSync } from "node:child_process";
|
|
28
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
29
29
|
import { createHash } from "node:crypto";
|
|
30
30
|
import { existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
31
31
|
import { tmpdir } from "node:os";
|
|
@@ -139,13 +139,39 @@ function compareCore(a, b) {
|
|
|
139
139
|
* hand (0.124.34 while 0.124.87 was out), which failed a product's floor and
|
|
140
140
|
* `minReader` checks that pass on a published chant. Every floor the checkout
|
|
141
141
|
* declares is at or below `NEXT_RELEASE`, so the local build passes each one.
|
|
142
|
+
* A checkout's NEXT_RELEASE can name a release that already shipped, since a
|
|
143
|
+
* release train needs no commit to move it on (#5260), so the version is at
|
|
144
|
+
* least the patch after core's newest release tag in the checkout.
|
|
142
145
|
* The build is marked local by the `chantLocal` field on each installed copy,
|
|
143
146
|
* not in the version, because a prerelease of `NEXT_RELEASE` sorts below it.
|
|
144
147
|
*/
|
|
145
148
|
export function localChantVersion(chantDir, coreVersion) {
|
|
146
149
|
const f = join(chantDir, "packages/core/src/release-floors.ts");
|
|
147
150
|
const next = existsSync(f) ? /export const NEXT_RELEASE = "(\d+\.\d+\.\d+)"/.exec(readFileSync(f, "utf8"))?.[1] : undefined;
|
|
148
|
-
|
|
151
|
+
const released = newestCoreRelease(chantDir);
|
|
152
|
+
const afterRelease = released === undefined ? undefined : released.replace(/\d+$/, (p) => String(Number(p) + 1));
|
|
153
|
+
let out = coreVersion;
|
|
154
|
+
for (const v of [next, afterRelease])
|
|
155
|
+
if (v !== undefined && compareCore(v, out) > 0)
|
|
156
|
+
out = v;
|
|
157
|
+
return out;
|
|
158
|
+
}
|
|
159
|
+
/** The newest core release a chant checkout's tags name (`release/npm/core/<v>`, `release/npm/<v>`, `chant-v<v>`), or undefined. */
|
|
160
|
+
function newestCoreRelease(chantDir) {
|
|
161
|
+
let tags;
|
|
162
|
+
try {
|
|
163
|
+
tags = execFileSync("git", ["tag", "-l", "release/npm/core/*", "release/npm/[0-9]*", "chant-v*"], { cwd: chantDir, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
let out;
|
|
169
|
+
for (const t of tags.split("\n")) {
|
|
170
|
+
const v = /^(?:release\/npm\/core\/|release\/npm\/|chant-v)(\d+\.\d+\.\d+)$/.exec(t.trim())?.[1];
|
|
171
|
+
if (v !== undefined && (out === undefined || compareCore(v, out) > 0))
|
|
172
|
+
out = v;
|
|
173
|
+
}
|
|
174
|
+
return out;
|
|
149
175
|
}
|
|
150
176
|
/**
|
|
151
177
|
* Set the version of one packed tarball's package.json, and every chant
|