@wtf/release-oci 2.1.0 → 4.0.0
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/README.md +101 -79
- package/dist/ecosystem.d.ts +76 -17
- package/dist/ecosystem.d.ts.map +1 -1
- package/dist/ecosystem.js +117 -8
- package/dist/ecosystem.js.map +1 -1
- package/dist/errors.d.ts +9 -9
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +9 -9
- package/dist/errors.js.map +1 -1
- package/dist/images.d.ts +7 -7
- package/dist/images.d.ts.map +1 -1
- package/dist/images.js +9 -9
- package/dist/images.js.map +1 -1
- package/dist/index.d.ts +14 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -11
- package/dist/index.js.map +1 -1
- package/dist/pages.d.ts +57 -0
- package/dist/pages.d.ts.map +1 -0
- package/dist/pages.js +61 -0
- package/dist/pages.js.map +1 -0
- package/dist/publish.d.ts +61 -19
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +100 -49
- package/dist/publish.js.map +1 -1
- package/dist/tags.d.ts +9 -22
- package/dist/tags.d.ts.map +1 -1
- package/dist/tags.js +24 -48
- package/dist/tags.js.map +1 -1
- package/package.json +9 -11
- package/dist/registry.d.ts +0 -60
- package/dist/registry.d.ts.map +0 -1
- package/dist/registry.js +0 -56
- package/dist/registry.js.map +0 -1
package/dist/publish.js
CHANGED
|
@@ -1,33 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The images of a release published, of no rebuild, by crane: {@link smokeImages} finds the tested
|
|
3
3
|
* image of each, its source, by its digest, and the platforms it is of; {@link publishImages} copies
|
|
4
|
-
* that digest to
|
|
5
|
-
* each blob of the source's repository rather than moving it
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* every time.
|
|
4
|
+
* that digest to the tag of the version, `crane copy <source>@<digest> <image>:<version>`, which
|
|
5
|
+
* mounts each blob of the source's repository rather than moving it; and {@link moveImages} points
|
|
6
|
+
* the tags that move at the version, as `1.4` and `1` of `1.4.2`, or `12.12` and `latest` of
|
|
7
|
+
* `12.12-wtf.1`, by the digest the registry has of it. The tag of the version is copied once: a
|
|
8
|
+
* registry that has it at the same digest is skipped, so a release that stopped part way is finished
|
|
9
|
+
* by running it again, and at another digest is refused (`EOCIRETAG`), as a released version never
|
|
10
|
+
* moves. The tags that move are copied every time.
|
|
11
11
|
*
|
|
12
|
-
* crane runs by the
|
|
13
|
-
* of the registry of its own config, as `crane auth login`
|
|
12
|
+
* crane runs by the platform it is given, in the folder of the repo and of the platform's
|
|
13
|
+
* environment: it reads the credentials of the registry of its own config, as `crane auth login`
|
|
14
|
+
* writes it, or of the docker config.
|
|
14
15
|
*
|
|
15
16
|
* ```ts
|
|
16
|
-
* import {
|
|
17
|
-
* import {
|
|
18
|
-
* import type { System } from '@wtf/release-system'
|
|
17
|
+
* import type { RepoPlatform } from '@wtf/release'
|
|
18
|
+
* import { moveImages, publishImages } from '@wtf/release-oci/publish'
|
|
19
19
|
*
|
|
20
|
-
* export async function release(
|
|
20
|
+
* export async function release(platform: RepoPlatform): Promise<void> {
|
|
21
|
+
* const repository = 'registry.gitlab.com/acme/images/base'
|
|
21
22
|
* await publishImages({
|
|
22
|
-
* context: {
|
|
23
|
+
* context: { platform },
|
|
23
24
|
* images: [
|
|
24
25
|
* {
|
|
25
|
-
* repository
|
|
26
|
-
* source: { repository:
|
|
26
|
+
* repository,
|
|
27
|
+
* source: { repository: `${repository}/snapshot`, tag: 'base-v1-4-2' }
|
|
27
28
|
* }
|
|
28
29
|
* ],
|
|
30
|
+
* version: '1.4.2'
|
|
31
|
+
* })
|
|
32
|
+
* await moveImages({
|
|
33
|
+
* context: { platform },
|
|
34
|
+
* repositories: [repository],
|
|
29
35
|
* version: '1.4.2',
|
|
30
|
-
* moving:
|
|
36
|
+
* moving: ['1.4', '1']
|
|
31
37
|
* })
|
|
32
38
|
* }
|
|
33
39
|
* ```
|
|
@@ -35,8 +41,8 @@
|
|
|
35
41
|
* @packageDocumentation
|
|
36
42
|
* @module @wtf/release-oci/publish
|
|
37
43
|
*/
|
|
38
|
-
import { throwAll } from '@wtf/release
|
|
39
|
-
import {
|
|
44
|
+
import { throwAll } from '@wtf/release/errors';
|
|
45
|
+
import { run } from '@wtf/release/process';
|
|
40
46
|
import { OciError } from "./errors.js";
|
|
41
47
|
import { checkReleaseTags } from "./tags.js";
|
|
42
48
|
/** The reference of a source, of its repository and its tag. */
|
|
@@ -46,15 +52,14 @@ const isAbsent = (stderr) => /MANIFEST_UNKNOWN|NAME_UNKNOWN|NOT_FOUND|not found|
|
|
|
46
52
|
/** The command of crane of `context`. */
|
|
47
53
|
const craneOf = (context) => context.crane ?? 'crane';
|
|
48
54
|
/**
|
|
49
|
-
* Runs crane with `args`,
|
|
55
|
+
* Runs crane with `args`, by the platform of `context`, in its folder and of its environment.
|
|
50
56
|
*
|
|
51
57
|
* @param args - The arguments of crane, as `['digest', 'registry.example/a:1']`.
|
|
52
58
|
* @param context - Where crane runs, and its command.
|
|
53
59
|
* @returns What crane wrote, and its exit code.
|
|
54
60
|
*/
|
|
55
61
|
async function crane(args, context) {
|
|
56
|
-
|
|
57
|
-
return system.exec(craneOf(context), args, { cwd, env });
|
|
62
|
+
return run(context.platform, craneOf(context), args);
|
|
58
63
|
}
|
|
59
64
|
/**
|
|
60
65
|
* The digest of the image `ref`, as `crane digest` gives it: none of a repository or a tag the
|
|
@@ -133,52 +138,98 @@ export async function smokeImages(images, context, platforms = []) {
|
|
|
133
138
|
throwAll(errors);
|
|
134
139
|
return smoked;
|
|
135
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Copies `source` to `target` by crane, or of a dry run, says it would. Throws `EOCITAG` of a copy
|
|
143
|
+
* crane cannot make.
|
|
144
|
+
*
|
|
145
|
+
* @param source - The image copied, by its digest, as `registry.example/a/snapshot@sha256:…`.
|
|
146
|
+
* @param target - The tag it is copied to, as `registry.example/a:1.4.2`.
|
|
147
|
+
* @param context - Where crane runs, and its command.
|
|
148
|
+
* @param release - Whether it is a dry run, and where the copy is said.
|
|
149
|
+
*/
|
|
150
|
+
async function copyImage(source, target, context, release) {
|
|
151
|
+
if (release.dryRun === true) {
|
|
152
|
+
release.log(`Would copy ${source} to ${target}.`);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const { stderr, code } = await crane(['copy', source, target], context);
|
|
156
|
+
if (code !== 0)
|
|
157
|
+
throw new OciError('EOCITAG', `crane cannot copy ${source} to ${target}: ${stderr.trim() || `exit code ${code}`}`, 'Check that crane is logged in to the registry of a token that may write the repository, and run the release of the tag again: what is published is skipped.');
|
|
158
|
+
release.log(`Copied ${source.slice(source.lastIndexOf('@') + 1)} to ${target}.`);
|
|
159
|
+
}
|
|
136
160
|
/**
|
|
137
161
|
* The images of a release published: each source smoked ({@link smokeImages}), then copied by its
|
|
138
|
-
* digest to the tag of the version, of an image the registry has not at it
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
162
|
+
* digest to the tag of the version, of an image the registry has not at it. Throws `EOCIVERSION` of
|
|
163
|
+
* a version that is no tag of an image, before it asks the registry anything; then, together,
|
|
164
|
+
* `EOCIRETAG` of each image whose version the registry has at another digest, before anything is
|
|
165
|
+
* copied; and `EOCITAG` of a copy crane cannot make. A dry run asks the registry, and copies
|
|
166
|
+
* nothing.
|
|
142
167
|
*
|
|
143
|
-
* @param release - The images
|
|
144
|
-
* @returns Each image, of
|
|
168
|
+
* @param release - The images and the version, and where crane runs.
|
|
169
|
+
* @returns Each image, of its digest, and whether its version was there already.
|
|
145
170
|
*/
|
|
146
171
|
export async function publishImages(release) {
|
|
147
172
|
const { context } = release;
|
|
148
173
|
const log = release.log ?? (() => undefined);
|
|
149
|
-
const
|
|
174
|
+
const { version } = checkReleaseTags({ version: release.version, moving: [] });
|
|
150
175
|
const smoked = await smokeImages(release.images, context, release.platforms ?? []);
|
|
151
176
|
const errors = [];
|
|
152
177
|
const has = new Map();
|
|
153
178
|
for (const image of smoked) {
|
|
154
179
|
// oxlint-disable-next-line no-await-in-loop -- crane asks the registry one image at a time
|
|
155
|
-
const at = await digestOf(`${image.repository}:${
|
|
180
|
+
const at = await digestOf(`${image.repository}:${version}`, context);
|
|
156
181
|
has.set(image.repository, at);
|
|
157
182
|
if (at !== undefined && at !== image.digest)
|
|
158
|
-
errors.push(new OciError('EOCIRETAG', `${image.repository}:${
|
|
183
|
+
errors.push(new OciError('EOCIRETAG', `${image.repository}:${version} is ${at} already, not ${image.digest}, the tested image of the release.`, 'Release a new version: a released version is never moved. Delete the tag in the registry yourself only where nothing pulls it yet.'));
|
|
159
184
|
}
|
|
160
185
|
throwAll(errors);
|
|
161
186
|
const published = [];
|
|
162
187
|
for (const image of smoked) {
|
|
163
|
-
const skipped = has.get(image.repository) === image.digest
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
// oxlint-disable-next-line no-await-in-loop -- one copy at a time
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
throw new OciError('EOCITAG', `crane cannot copy ${image.source.repository}@${image.digest} to ${target}: ${stderr.trim() || `exit code ${code}`}`, 'Check that crane is logged in to the registry of a token that may write the repository, and run the release of the tag again: what is published is skipped.');
|
|
171
|
-
log(`Copied ${image.digest} to ${target}.`);
|
|
172
|
-
}
|
|
173
|
-
for (const tag of skipped)
|
|
174
|
-
log(`${image.repository}:${tag} is ${image.digest} already.`);
|
|
175
|
-
published.push({
|
|
176
|
-
...image,
|
|
177
|
-
version: tags.version,
|
|
178
|
-
tags: [tags.version, ...tags.moving],
|
|
179
|
-
skipped
|
|
180
|
-
});
|
|
188
|
+
const skipped = has.get(image.repository) === image.digest;
|
|
189
|
+
if (skipped)
|
|
190
|
+
log(`${image.repository}:${version} is ${image.digest} already.`);
|
|
191
|
+
else
|
|
192
|
+
// oxlint-disable-next-line no-await-in-loop -- one copy at a time
|
|
193
|
+
await copyImage(`${image.source.repository}@${image.digest}`, `${image.repository}:${version}`, context, { dryRun: release.dryRun, log });
|
|
194
|
+
published.push({ ...image, version, skipped });
|
|
181
195
|
}
|
|
182
196
|
return published;
|
|
183
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* Points the tags that move of each image at the version of the release: the digest the registry has
|
|
200
|
+
* of the version, copied to each, `crane copy <image>@<digest> <image>:<tag>`, every time. Throws
|
|
201
|
+
* `EOCIVERSION` of a tag that is no tag of an image, or given twice, before it asks the registry
|
|
202
|
+
* anything; then, together, `EOCIMOVE` of each image whose version the registry has not, before
|
|
203
|
+
* anything is copied; and `EOCITAG` of a copy crane cannot make. A dry run asks the registry, and
|
|
204
|
+
* copies nothing.
|
|
205
|
+
*
|
|
206
|
+
* @param move - The repositories, the version and the tags that move, and where crane runs.
|
|
207
|
+
* @returns Each image, of the digest of its version and the tags copied of it.
|
|
208
|
+
*/
|
|
209
|
+
export async function moveImages(move) {
|
|
210
|
+
const { context } = move;
|
|
211
|
+
const log = move.log ?? (() => undefined);
|
|
212
|
+
const tags = checkReleaseTags({ version: move.version, moving: move.moving });
|
|
213
|
+
if (tags.moving.length === 0)
|
|
214
|
+
return [];
|
|
215
|
+
const errors = [];
|
|
216
|
+
const moved = [];
|
|
217
|
+
for (const repository of move.repositories) {
|
|
218
|
+
// oxlint-disable-next-line no-await-in-loop -- crane asks the registry one image at a time
|
|
219
|
+
const digest = await digestOf(`${repository}:${tags.version}`, context);
|
|
220
|
+
if (digest === undefined)
|
|
221
|
+
errors.push(new OciError('EOCIMOVE', `The registry has no ${repository}:${tags.version}, which the tags ${tags.moving.join(', ')} would point at.`, 'Publish the version first, then move its tags.'));
|
|
222
|
+
else
|
|
223
|
+
moved.push({ repository, digest, tags: tags.moving });
|
|
224
|
+
}
|
|
225
|
+
throwAll(errors);
|
|
226
|
+
for (const { repository, digest } of moved)
|
|
227
|
+
for (const tag of tags.moving)
|
|
228
|
+
// oxlint-disable-next-line no-await-in-loop -- one copy at a time
|
|
229
|
+
await copyImage(`${repository}@${digest}`, `${repository}:${tag}`, context, {
|
|
230
|
+
dryRun: move.dryRun,
|
|
231
|
+
log
|
|
232
|
+
});
|
|
233
|
+
return moved;
|
|
234
|
+
}
|
|
184
235
|
//# sourceMappingURL=publish.js.map
|
package/dist/publish.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAE9C,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AA2C5C,gEAAgE;AAChE,MAAM,SAAS,GAAG,CAAC,EAAE,UAAU,EAAE,GAAG,EAAa,EAAU,EAAE,CAAC,GAAG,UAAU,IAAI,GAAG,EAAE,CAAA;AAEpF,0EAA0E;AAC1E,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAW,EAAE,CAC3C,wDAAwD,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAEvE,yCAAyC;AACzC,MAAM,OAAO,GAAG,CAAC,OAAqB,EAAU,EAAE,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,CAAA;AAE3E;;;;;;GAMG;AACH,KAAK,UAAU,KAAK,CAClB,IAAuB,EACvB,OAAqB;IAErB,OAAO,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAA;AACtD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,GAAW,EAAE,OAAqB;IAC/D,MAAM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,EAAE,OAAO,CAAC,CAAA;QACvE,IAAI,MAAM,KAAK,SAAS;YACtB,MAAM,CAAC,IAAI,CACT,IAAI,QAAQ,CACV,UAAU,EACV,uBAAuB,UAAU,IAAI,IAAI,CAAC,OAAO,oBAAoB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAC7G,gDAAgD,CACjD,CACF,CAAA;;YACE,KAAK,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;IAC5D,CAAC;IACD,QAAQ,CAAC,MAAM,CAAC,CAAA;IAChB,KAAK,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,KAAK;QACxC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM;YAC3B,kEAAkE;YAClE,MAAM,SAAS,CAAC,GAAG,UAAU,IAAI,MAAM,EAAE,EAAE,GAAG,UAAU,IAAI,GAAG,EAAE,EAAE,OAAO,EAAE;gBAC1E,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,GAAG;aACJ,CAAC,CAAA;IACN,OAAO,KAAK,CAAA;AACd,CAAC"}
|
package/dist/tags.d.ts
CHANGED
|
@@ -2,42 +2,29 @@
|
|
|
2
2
|
export interface ReleaseTags {
|
|
3
3
|
/** The tag of the version, as `1.4.2`, which a release never moves once it is published. */
|
|
4
4
|
readonly version: string;
|
|
5
|
-
/** The tags that move to each release of their line, as `1.4` and `1`:
|
|
5
|
+
/** The tags that move to each release of their line, as `1.4` and `1`: `[]` of none. */
|
|
6
6
|
readonly moving: readonly string[];
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
* move; of a release of the major `0`, its minor alone, as a minor of `0` breaks what the one before
|
|
11
|
-
* gave; of a prerelease, none that moves.
|
|
9
|
+
* Whether `tag` is a tag the OCI distribution spec takes, `[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}`.
|
|
12
10
|
*
|
|
13
|
-
* @param
|
|
14
|
-
* @
|
|
15
|
-
* @returns The tags.
|
|
16
|
-
* @throws `TypeError` of a version that is no semver.
|
|
11
|
+
* @param tag - The tag, as `1.4.2`.
|
|
12
|
+
* @returns Whether an image can have it.
|
|
17
13
|
*/
|
|
18
|
-
export declare
|
|
14
|
+
export declare const isImageTag: (tag: string) => boolean;
|
|
19
15
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @param moving - Whether a release moves its minor and its major: `true` by default.
|
|
24
|
-
* @returns The tags, as `['1.4.2', '1.4', '1']`.
|
|
25
|
-
*/
|
|
26
|
-
export declare function tagsOfRelease(version: string, moving?: boolean): string[];
|
|
27
|
-
/**
|
|
28
|
-
* The tags of a release that its caller gives, as of a version that is no semver, checked: each a
|
|
29
|
-
* tag the OCI distribution spec takes, `[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}`, none twice, and the tag
|
|
30
|
-
* of the version not among those that move.
|
|
16
|
+
* The tags of a release, as its caller gives them, checked: each a tag the OCI distribution spec
|
|
17
|
+
* takes ({@link isImageTag}), none twice, and the tag of the version not among those that move.
|
|
18
|
+
* Throws, together, `EOCIVERSION` of the tags the spec does not take, and of the tags given twice.
|
|
31
19
|
*
|
|
32
20
|
* ```ts
|
|
33
21
|
* import { checkReleaseTags } from '@wtf/release-oci/tags'
|
|
34
22
|
*
|
|
35
|
-
* export const tags = checkReleaseTags({ version: '
|
|
23
|
+
* export const tags = checkReleaseTags({ version: '1.4.2', moving: ['1.4', '1'] })
|
|
36
24
|
* ```
|
|
37
25
|
*
|
|
38
26
|
* @param tags - The tag of the version, and those that move.
|
|
39
27
|
* @returns The same tags.
|
|
40
|
-
* @throws `TypeError` of a tag the spec does not take, or of a tag given twice.
|
|
41
28
|
*/
|
|
42
29
|
export declare function checkReleaseTags(tags: ReleaseTags): ReleaseTags;
|
|
43
30
|
//# sourceMappingURL=tags.d.ts.map
|
package/dist/tags.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":"AAoBA,8FAA8F;AAC9F,MAAM,WAAW,WAAW;IAC1B,4FAA4F;IAC5F,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,wFAAwF;IACxF,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;CACnC;AAKD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,OAAwB,CAAA;AAEjE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW,CAuB/D"}
|
package/dist/tags.js
CHANGED
|
@@ -1,78 +1,54 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The tags of a release of an image ({@link
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
* The tags of a release of an image ({@link ReleaseTags}): the tag of its version, which a release
|
|
3
|
+
* never moves once it is published, and the tags that move to each release of their line, as `1.4`
|
|
4
|
+
* and `1` of `1.4.2`, or `12.12` and `latest` of `12.12-wtf.1`, which a consumer pins to take each
|
|
5
|
+
* fix of its line. A release takes them as its caller gives them, and derives none: a release tool
|
|
6
|
+
* names those of its own rules. {@link checkReleaseTags} checks them, each a tag an image can have.
|
|
7
7
|
*
|
|
8
8
|
* ```ts
|
|
9
|
-
* import {
|
|
9
|
+
* import { checkReleaseTags } from '@wtf/release-oci/tags'
|
|
10
10
|
*
|
|
11
|
-
* export const tags =
|
|
11
|
+
* export const tags = checkReleaseTags({ version: '12.12-wtf.1', moving: ['12.12', 'latest'] })
|
|
12
12
|
* ```
|
|
13
13
|
*
|
|
14
14
|
* @packageDocumentation
|
|
15
15
|
* @module @wtf/release-oci/tags
|
|
16
16
|
*/
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* gave; of a prerelease, none that moves.
|
|
22
|
-
*
|
|
23
|
-
* @param version - The version of the release, as `1.4.2`.
|
|
24
|
-
* @param moving - Whether a release moves its minor and its major: `true` by default.
|
|
25
|
-
* @returns The tags.
|
|
26
|
-
* @throws `TypeError` of a version that is no semver.
|
|
27
|
-
*/
|
|
28
|
-
export function releaseTagsOf(version, moving = true) {
|
|
29
|
-
const parsed = semver.parse(version);
|
|
30
|
-
if (parsed === null)
|
|
31
|
-
throw new TypeError(`${version} is no semver version.`);
|
|
32
|
-
if (!moving || parsed.prerelease.length > 0)
|
|
33
|
-
return { version: parsed.version, moving: [] };
|
|
34
|
-
const minor = `${parsed.major}.${parsed.minor}`;
|
|
35
|
-
return {
|
|
36
|
-
version: parsed.version,
|
|
37
|
-
moving: parsed.major === 0 ? [minor] : [minor, `${parsed.major}`]
|
|
38
|
-
};
|
|
39
|
-
}
|
|
17
|
+
import { throwAll } from '@wtf/release/errors';
|
|
18
|
+
import { OciError } from "./errors.js";
|
|
19
|
+
/** A tag of an image, as the OCI distribution spec takes it: at most 128 characters. */
|
|
20
|
+
const TAG = /^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$/;
|
|
40
21
|
/**
|
|
41
|
-
*
|
|
22
|
+
* Whether `tag` is a tag the OCI distribution spec takes, `[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}`.
|
|
42
23
|
*
|
|
43
|
-
* @param
|
|
44
|
-
* @
|
|
45
|
-
* @returns The tags, as `['1.4.2', '1.4', '1']`.
|
|
24
|
+
* @param tag - The tag, as `1.4.2`.
|
|
25
|
+
* @returns Whether an image can have it.
|
|
46
26
|
*/
|
|
47
|
-
export
|
|
48
|
-
const tags = releaseTagsOf(version, moving);
|
|
49
|
-
return [tags.version, ...tags.moving];
|
|
50
|
-
}
|
|
51
|
-
/** A tag of an image, as the OCI distribution spec takes it: at most 128 characters. */
|
|
52
|
-
const TAG = /^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$/;
|
|
27
|
+
export const isImageTag = (tag) => TAG.test(tag);
|
|
53
28
|
/**
|
|
54
|
-
* The tags of a release
|
|
55
|
-
*
|
|
56
|
-
* of the
|
|
29
|
+
* The tags of a release, as its caller gives them, checked: each a tag the OCI distribution spec
|
|
30
|
+
* takes ({@link isImageTag}), none twice, and the tag of the version not among those that move.
|
|
31
|
+
* Throws, together, `EOCIVERSION` of the tags the spec does not take, and of the tags given twice.
|
|
57
32
|
*
|
|
58
33
|
* ```ts
|
|
59
34
|
* import { checkReleaseTags } from '@wtf/release-oci/tags'
|
|
60
35
|
*
|
|
61
|
-
* export const tags = checkReleaseTags({ version: '
|
|
36
|
+
* export const tags = checkReleaseTags({ version: '1.4.2', moving: ['1.4', '1'] })
|
|
62
37
|
* ```
|
|
63
38
|
*
|
|
64
39
|
* @param tags - The tag of the version, and those that move.
|
|
65
40
|
* @returns The same tags.
|
|
66
|
-
* @throws `TypeError` of a tag the spec does not take, or of a tag given twice.
|
|
67
41
|
*/
|
|
68
42
|
export function checkReleaseTags(tags) {
|
|
69
43
|
const all = [tags.version, ...tags.moving];
|
|
70
|
-
const
|
|
44
|
+
const errors = [];
|
|
45
|
+
const invalid = all.filter((tag) => !isImageTag(tag));
|
|
71
46
|
if (invalid.length > 0)
|
|
72
|
-
|
|
47
|
+
errors.push(new OciError('EOCIVERSION', `${invalid.map((tag) => JSON.stringify(tag)).join(', ')} is no tag of an image: a tag is [A-Za-z0-9_][A-Za-z0-9_.-]{0,127}.`, 'Release a version that is a tag of an image, as `1.4.2` or `12.12-wtf.1`, and name each tag that moves of the same characters, as `12.12` or `latest`.'));
|
|
73
48
|
const twice = all.filter((tag, index) => all.indexOf(tag) !== index);
|
|
74
49
|
if (twice.length > 0)
|
|
75
|
-
|
|
50
|
+
errors.push(new OciError('EOCIVERSION', `The tags of the release name ${[...new Set(twice)].join(', ')} twice: the tag of the version moves never, and each other tag once.`, 'Name each tag that moves once, and not the tag of the version among them.'));
|
|
51
|
+
throwAll(errors);
|
|
76
52
|
return tags;
|
|
77
53
|
}
|
|
78
54
|
//# sourceMappingURL=tags.js.map
|
package/dist/tags.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAUtC,wFAAwF;AACxF,MAAM,GAAG,GAAG,qCAAqC,CAAA;AAEjD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAW,EAAW,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAEjE;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAiB;IAChD,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,CAAA;IAC1C,MAAM,MAAM,GAAe,EAAE,CAAA;IAC7B,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAA;IACrD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;QACpB,MAAM,CAAC,IAAI,CACT,IAAI,QAAQ,CACV,aAAa,EACb,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,qEAAqE,EAC5H,wJAAwJ,CACzJ,CACF,CAAA;IACH,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,CAAA;IACpE,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAClB,MAAM,CAAC,IAAI,CACT,IAAI,QAAQ,CACV,aAAa,EACb,gCAAgC,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,sEAAsE,EACpI,2EAA2E,CAC5E,CACF,CAAA;IACH,QAAQ,CAAC,MAAM,CAAC,CAAA;IAChB,OAAO,IAAI,CAAA;AACb,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wtf/release-oci",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "The OCI images of a repo released
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": "The OCI images of a repo released and tagged in their registry, of no release tool and no rebuild, each function by the platform it is given: the ecosystem of OCI images, its default export (., ./ecosystem), a releasing ecosystem of the contract of @wtf/release, its steps verify, smoke, publish and move over the plan of a release; the images of a repo, each folder of a Dockerfile, a Containerfile or a .devcontainer/devcontainer.json git tracks, of the working tree or of a commit (./images), the tags of a release checked, its version and the tags that move, as its caller names them (./tags), the tested image of each found by its digest and copied to the tag of the version by crane, a version the registry has at another digest refused, and the tags that move pointed at the digest of the version (./publish), each image as the links of its release name it, of its page on Docker Hub or Quay, else of the registry whose forge knows its page (./pages), and OciError, the class of its errors, with their codes (./errors).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"container",
|
|
7
7
|
"docker",
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
"image",
|
|
10
10
|
"oci",
|
|
11
11
|
"release",
|
|
12
|
-
"release-train",
|
|
13
12
|
"tags"
|
|
14
13
|
],
|
|
15
14
|
"homepage": "https://gitlab.com/wetryfun/release/release/-/tree/main/packages/release-oci",
|
|
@@ -47,14 +46,14 @@
|
|
|
47
46
|
"types": "./dist/images.d.ts",
|
|
48
47
|
"default": "./dist/images.js"
|
|
49
48
|
},
|
|
49
|
+
"./pages": {
|
|
50
|
+
"types": "./dist/pages.d.ts",
|
|
51
|
+
"default": "./dist/pages.js"
|
|
52
|
+
},
|
|
50
53
|
"./publish": {
|
|
51
54
|
"types": "./dist/publish.d.ts",
|
|
52
55
|
"default": "./dist/publish.js"
|
|
53
56
|
},
|
|
54
|
-
"./registry": {
|
|
55
|
-
"types": "./dist/registry.d.ts",
|
|
56
|
-
"default": "./dist/registry.js"
|
|
57
|
-
},
|
|
58
57
|
"./tags": {
|
|
59
58
|
"types": "./dist/tags.d.ts",
|
|
60
59
|
"default": "./dist/tags.js"
|
|
@@ -68,13 +67,12 @@
|
|
|
68
67
|
"build": "tsc -b"
|
|
69
68
|
},
|
|
70
69
|
"dependencies": {
|
|
71
|
-
"@wtf/
|
|
72
|
-
"@wtf/
|
|
73
|
-
"
|
|
70
|
+
"@wtf/platform": "^2.0.0",
|
|
71
|
+
"@wtf/platform-fs": "^1.1.0",
|
|
72
|
+
"@wtf/release": "^2.0.0"
|
|
74
73
|
},
|
|
75
74
|
"devDependencies": {
|
|
76
75
|
"@types/node": "^24.10.0",
|
|
77
|
-
"@types/semver": "^7.7.0",
|
|
78
76
|
"vitest": "^5.0.5"
|
|
79
77
|
},
|
|
80
78
|
"engines": {
|
package/dist/registry.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The page of an image in the container registry of GitLab ({@link registryPageOf}), which the
|
|
3
|
-
* GitLab release of a tag links each image by: the Container Registry API of the project lists its
|
|
4
|
-
* repositories, `GET /projects/<id>/registry/repositories`, each of its `location`, as
|
|
5
|
-
* `registry.gitlab.com/acme/images/base`, and its ID, whose page is
|
|
6
|
-
* `<project>/container_registry/<id>`. An image is linked where it lives, never uploaded.
|
|
7
|
-
* {@link checkRegistryAccess} asks the same API once, before anything is released, whether the
|
|
8
|
-
* headers may read it: GitLab's job token may not, so a run of it alone fails there, not after the
|
|
9
|
-
* images are copied.
|
|
10
|
-
*
|
|
11
|
-
* ```ts
|
|
12
|
-
* import { registryPageOf } from '@wtf/release-oci/registry'
|
|
13
|
-
* import { gitlabHeadersOf, gitlabProjectOf } from '@wtf/release-trains/gitlab'
|
|
14
|
-
*
|
|
15
|
-
* const env = { CI_PROJECT_PATH: 'acme/images', GITLAB_TOKEN: 'token' }
|
|
16
|
-
* export const page = await registryPageOf({
|
|
17
|
-
* fetch,
|
|
18
|
-
* project: gitlabProjectOf({}, env, undefined),
|
|
19
|
-
* repository: 'registry.gitlab.com/acme/images/base',
|
|
20
|
-
* headers: gitlabHeadersOf(env)
|
|
21
|
-
* })
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* @packageDocumentation
|
|
25
|
-
* @module @wtf/release-oci/registry
|
|
26
|
-
*/
|
|
27
|
-
import type { GitLabProject, HttpFetch } from '@wtf/release-trains/gitlab';
|
|
28
|
-
/** What {@link registryPageOf} looks up. */
|
|
29
|
-
export interface RegistryQuery {
|
|
30
|
-
/** The `fetch` the request is made by. */
|
|
31
|
-
readonly fetch: HttpFetch;
|
|
32
|
-
/** The project whose container registry holds the image. */
|
|
33
|
-
readonly project: GitLabProject;
|
|
34
|
-
/** The repository of the image, as `registry.gitlab.com/acme/images/base`. */
|
|
35
|
-
readonly repository: string;
|
|
36
|
-
/** The headers the request authenticates by: none of a public project. */
|
|
37
|
-
readonly headers: Readonly<Record<string, string>>;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* The page of the image `repository` in the container registry of `project`: the repository of its
|
|
41
|
-
* `location`, of the first page of a hundred, at `<project>/container_registry/<id>`. Throws
|
|
42
|
-
* `EOCILINK` of a request GitLab refuses or that cannot be made, and of a registry that lists no
|
|
43
|
-
* repository of the location.
|
|
44
|
-
*
|
|
45
|
-
* @param query - The `fetch`, the project, the repository and the headers.
|
|
46
|
-
* @returns The URL of the page of the image.
|
|
47
|
-
*/
|
|
48
|
-
export declare function registryPageOf(query: RegistryQuery): Promise<string>;
|
|
49
|
-
/** What {@link checkRegistryAccess} asks: a registry query of no repository. */
|
|
50
|
-
export type RegistryAccess = Omit<RegistryQuery, 'repository'>;
|
|
51
|
-
/**
|
|
52
|
-
* Checks that `headers` may read the container registry of `project`, by one request of no
|
|
53
|
-
* effect, `GET /projects/<id>/registry/repositories?per_page=1`, as {@link registryPageOf} needs it
|
|
54
|
-
* to: a token of the `read_api` or `api` scope may; the job token of a pipeline, `CI_JOB_TOKEN`, may
|
|
55
|
-
* not. Throws `EOCILINK` of a request GitLab refuses or that cannot be made.
|
|
56
|
-
*
|
|
57
|
-
* @param query - The `fetch`, the project and the headers.
|
|
58
|
-
*/
|
|
59
|
-
export declare function checkRegistryAccess(query: RegistryAccess): Promise<void>;
|
|
60
|
-
//# sourceMappingURL=registry.d.ts.map
|
package/dist/registry.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAI1E,4CAA4C;AAC5C,MAAM,WAAW,aAAa;IAC5B,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;IACzB,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAA;IAC/B,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CACnD;AAQD;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CA+B1E;AAED,gFAAgF;AAChF,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,CAAA;AAE9D;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAc9E"}
|
package/dist/registry.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { OciError } from "./errors.js";
|
|
2
|
-
/**
|
|
3
|
-
* The page of the image `repository` in the container registry of `project`: the repository of its
|
|
4
|
-
* `location`, of the first page of a hundred, at `<project>/container_registry/<id>`. Throws
|
|
5
|
-
* `EOCILINK` of a request GitLab refuses or that cannot be made, and of a registry that lists no
|
|
6
|
-
* repository of the location.
|
|
7
|
-
*
|
|
8
|
-
* @param query - The `fetch`, the project, the repository and the headers.
|
|
9
|
-
* @returns The URL of the page of the image.
|
|
10
|
-
*/
|
|
11
|
-
export async function registryPageOf(query) {
|
|
12
|
-
const { fetch, project, repository, headers } = query;
|
|
13
|
-
const url = `${project.api}/projects/${project.id}/registry/repositories?per_page=100`;
|
|
14
|
-
let text;
|
|
15
|
-
try {
|
|
16
|
-
const response = await fetch(url, { method: 'GET', headers: { ...headers } });
|
|
17
|
-
text = await response.text();
|
|
18
|
-
if (!response.ok)
|
|
19
|
-
throw new Error(`GitLab answered ${response.status}: ${text}`);
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
throw new OciError('EOCILINK', `The container registry of ${project.path} cannot be asked for ${repository}, at ${url}: ${error.message}`, 'Give the run a token that may read the registry of the project, `GITLAB_TOKEN` of the `read_api` scope, and check the URL of GitLab.');
|
|
23
|
-
}
|
|
24
|
-
let listed;
|
|
25
|
-
try {
|
|
26
|
-
listed = JSON.parse(text);
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
listed = undefined;
|
|
30
|
-
}
|
|
31
|
-
const found = (Array.isArray(listed) ? listed : []).find(({ location }) => location === repository);
|
|
32
|
-
if (found?.id === undefined)
|
|
33
|
-
throw new OciError('EOCILINK', `The container registry of ${project.path} lists no repository ${repository}.`, 'Publish the image to the registry of the project of the release, whose page the release links: its repository is `CI_REGISTRY_IMAGE`, of its folder.');
|
|
34
|
-
return `${project.url}/container_registry/${found.id}`;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Checks that `headers` may read the container registry of `project`, by one request of no
|
|
38
|
-
* effect, `GET /projects/<id>/registry/repositories?per_page=1`, as {@link registryPageOf} needs it
|
|
39
|
-
* to: a token of the `read_api` or `api` scope may; the job token of a pipeline, `CI_JOB_TOKEN`, may
|
|
40
|
-
* not. Throws `EOCILINK` of a request GitLab refuses or that cannot be made.
|
|
41
|
-
*
|
|
42
|
-
* @param query - The `fetch`, the project and the headers.
|
|
43
|
-
*/
|
|
44
|
-
export async function checkRegistryAccess(query) {
|
|
45
|
-
const { fetch, project, headers } = query;
|
|
46
|
-
const url = `${project.api}/projects/${project.id}/registry/repositories?per_page=1`;
|
|
47
|
-
try {
|
|
48
|
-
const response = await fetch(url, { method: 'GET', headers: { ...headers } });
|
|
49
|
-
if (!response.ok)
|
|
50
|
-
throw new Error(`GitLab answered ${response.status}: ${await response.text()}`);
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
throw new OciError('EOCILINK', `The container registry of ${project.path} cannot be read, at ${url}: ${error.message}`, 'Give the run a token that may read the API of the project, `GITLAB_TOKEN` of the `read_api` or `api` scope: GitLab refuses the job token, `CI_JOB_TOKEN`, there.');
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=registry.js.map
|
package/dist/registry.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,C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