@catladder/cli 0.0.0-next-dccc0a36 → 0.0.0-next-89bce6d0
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/apps/cli/src/catci.js +23 -0
- package/dist/apps/cli/src/catci.js.map +1 -1
- package/dist/apps/cli/src/release/githubQueuedRelease.d.ts +14 -0
- package/dist/apps/cli/src/release/githubQueuedRelease.js +152 -0
- package/dist/apps/cli/src/release/githubQueuedRelease.js.map +1 -0
- package/dist/bundles/catci/index.js +3 -3
- package/dist/bundles/catenv/index.js +340 -109
- package/dist/bundles/cli/index.js +340 -109
- package/dist/bundles/skills/catladder-deploys/references/deploy-types.md +1 -1
- package/dist/bundles/skills/catladder-releases/SKILL.md +13 -2
- package/dist/packages/bash/src/variables/VariableValueContainingReferences.d.ts +6 -0
- package/dist/packages/bash/src/variables/VariableValueContainingReferences.js +8 -0
- package/dist/packages/bash/src/variables/VariableValueContainingReferences.js.map +1 -1
- package/dist/packages/bash/src/variables/resolveAllReferences.d.ts +1 -2
- package/dist/packages/bash/src/variables/resolveAllReferences.js +4 -2
- package/dist/packages/bash/src/variables/resolveAllReferences.js.map +1 -1
- package/dist/packages/bash/src/variables/resolveAllReferencesOnce.d.ts +1 -4
- package/dist/packages/bash/src/variables/resolveAllReferencesOnce.js +4 -2
- package/dist/packages/bash/src/variables/resolveAllReferencesOnce.js.map +1 -1
- package/dist/packages/pipeline/src/backends/github/GithubBackend.js +7 -0
- package/dist/packages/pipeline/src/backends/github/GithubBackend.js.map +1 -1
- package/dist/packages/pipeline/src/backends/github/githubReleaseJobs.d.ts +18 -2
- package/dist/packages/pipeline/src/backends/github/githubReleaseJobs.js +92 -10
- package/dist/packages/pipeline/src/backends/github/githubReleaseJobs.js.map +1 -1
- package/dist/packages/pipeline/src/backends/gitlab/GitlabBackend.js +31 -5
- package/dist/packages/pipeline/src/backends/gitlab/GitlabBackend.js.map +1 -1
- package/dist/packages/pipeline/src/backends/gitlab/gitlabReleaseJobs.d.ts +285 -3
- package/dist/packages/pipeline/src/backends/gitlab/gitlabReleaseJobs.js +142 -54
- package/dist/packages/pipeline/src/backends/gitlab/gitlabReleaseJobs.js.map +1 -1
- package/dist/packages/pipeline/src/context/getEnvironmentVariables.js +17 -9
- package/dist/packages/pipeline/src/context/getEnvironmentVariables.js.map +1 -1
- package/dist/packages/pipeline/src/deploy/cloudRun/index.js +2 -2
- package/dist/packages/pipeline/src/deploy/cloudRun/index.js.map +1 -1
- package/dist/packages/pipeline/src/deploy/cloudRun/utils/database.d.ts +7 -9
- package/dist/packages/pipeline/src/deploy/cloudRun/utils/database.js +32 -24
- package/dist/packages/pipeline/src/deploy/cloudRun/utils/database.js.map +1 -1
- package/dist/packages/pipeline/src/deploy/index.d.ts +2 -2
- package/dist/packages/pipeline/src/types/github-types.d.ts +1 -0
- package/dist/packages/pipeline/src/types/release.d.ts +7 -1
- package/dist/skills/catladder-deploys/references/deploy-types.md +1 -1
- package/dist/skills/catladder-releases/SKILL.md +13 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/catci.ts +30 -0
- package/src/release/githubQueuedRelease.ts +173 -0
|
@@ -17,6 +17,7 @@ const evaluateSecurityAudit_1 = require("./security/evaluateSecurityAudit");
|
|
|
17
17
|
const createSecurityAuditMergeRequest_1 = require("./security/createSecurityAuditMergeRequest");
|
|
18
18
|
const changesetsReleaseJob_1 = require("./release/changesetsReleaseJob");
|
|
19
19
|
const changesetCheckJob_1 = require("./release/changesetCheckJob");
|
|
20
|
+
const githubQueuedRelease_1 = require("./release/githubQueuedRelease");
|
|
20
21
|
const npmPublishJob_1 = require("./publish/npmPublishJob");
|
|
21
22
|
const GITLAB_HOST = "https://git.panter.ch";
|
|
22
23
|
const USAGE = `catci — catladder CI companion
|
|
@@ -46,6 +47,18 @@ usage:
|
|
|
46
47
|
github only: dispatches the generated taggedRelease workflow for
|
|
47
48
|
the tag (tags pushed with the job token don't trigger it)
|
|
48
49
|
|
|
50
|
+
catci release github-queue-check
|
|
51
|
+
github only, first step of the manual create-release task:
|
|
52
|
+
releases right away when the main workflow run for HEAD is green
|
|
53
|
+
(queued=false step output), queues the release when it is still
|
|
54
|
+
running (queued=true, marker ref for the release-on-green
|
|
55
|
+
workflow), fails when it concluded red
|
|
56
|
+
|
|
57
|
+
catci release github-queued-guard <head-sha> <conclusion>
|
|
58
|
+
github only, guard of the release-on-green workflow: consumes the
|
|
59
|
+
queue marker when it matches the completed main run and decides
|
|
60
|
+
whether the release step runs (release=true step output)
|
|
61
|
+
|
|
49
62
|
catci publish npm --dir <dir> --env-type <envType> [--access <access>] [--registry <url>] [--dist-tag <tag>]
|
|
50
63
|
npmPackage deploy job: derives version + dist-tag from the
|
|
51
64
|
pipeline trigger (tagged release -> tag version @latest; branch/MR
|
|
@@ -126,6 +139,16 @@ const main = async () => {
|
|
|
126
139
|
args.length === 1) {
|
|
127
140
|
return (0, changesetsReleaseJob_1.dispatchTaggedReleaseWorkflow)(args[0]);
|
|
128
141
|
}
|
|
142
|
+
if (group === "release" &&
|
|
143
|
+
command === "github-queue-check" &&
|
|
144
|
+
args.length === 0) {
|
|
145
|
+
return (0, githubQueuedRelease_1.githubQueueCheckJob)();
|
|
146
|
+
}
|
|
147
|
+
if (group === "release" &&
|
|
148
|
+
command === "github-queued-guard" &&
|
|
149
|
+
args.length === 2) {
|
|
150
|
+
return (0, githubQueuedRelease_1.githubQueuedGuardJob)(args[0], args[1]);
|
|
151
|
+
}
|
|
129
152
|
if (group === "publish" && command === "npm") {
|
|
130
153
|
const options = (0, npmPublishJob_1.parseNpmPublishArgs)(args);
|
|
131
154
|
if (options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catci.js","sourceRoot":"","sources":["../../../../src/catci.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;GAWG;AACH,0CAAyC;AACzC,4EAG0C;AAC1C,gGAGoD;AACpD,yEAGwC;AACxC,mEAAgE;AAChE,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BAAqB;QACjC,IAAI,CAAC,MAAM,KAAK,CAAC,EACjB,CAAC;QACD,OAAO,IAAA,0CAAoB,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,CAAC;IACD,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,EAAE,CAAC;QAC7C,MAAM,OAAO,GAAG,IAAA,mCAAmB,EAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,IAAA,6BAAa,EAAC,OAAO,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,CAAC;AACd,CAAC,CAAC;AAEF,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,IAAI,CAAC,iBAAiB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `catci release github-queue-check` — first step of the manual
|
|
3
|
+
* create-release dispatch job. Decides between releasing right away
|
|
4
|
+
* (queued=false) and queueing for the running main workflow
|
|
5
|
+
* (queued=true).
|
|
6
|
+
*/
|
|
7
|
+
export declare const githubQueueCheckJob: () => Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* `catci release github-queued-guard <head-sha> <conclusion>` — guard
|
|
10
|
+
* step of the release-on-green workflow, running on every completed
|
|
11
|
+
* main workflow run. Consumes the marker when it matches the run and
|
|
12
|
+
* decides whether the release step runs (release=true).
|
|
13
|
+
*/
|
|
14
|
+
export declare const githubQueuedGuardJob: (headSha: string, conclusion: string) => Promise<void>;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.githubQueuedGuardJob = exports.githubQueueCheckJob = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* "release once the pipeline succeeds" on github.
|
|
6
|
+
*
|
|
7
|
+
* gitlab expresses this natively inside the pipeline (the `create
|
|
8
|
+
* release` button job plus an executor with `needs` on the whole
|
|
9
|
+
* pipeline); github has no cross-workflow needs, so catladder uses a
|
|
10
|
+
* marker ref plus a workflow_run-triggered workflow instead:
|
|
11
|
+
*
|
|
12
|
+
* - the manual `create-release` dispatch runs `github-queue-check`:
|
|
13
|
+
* - the main workflow run for HEAD completed green (or never ran) →
|
|
14
|
+
* release right away (queued=false, the job's release step runs)
|
|
15
|
+
* - still running → push the marker ref and stop (queued=true skips
|
|
16
|
+
* the release step); the release-on-green workflow takes over
|
|
17
|
+
* - completed red → fail with a pointer to the force task
|
|
18
|
+
* - the release-on-green workflow (`on: workflow_run` of the main
|
|
19
|
+
* workflow) runs `github-queued-guard` on every completed main run:
|
|
20
|
+
* it consumes the marker when it matches the run's head sha and
|
|
21
|
+
* releases only when the run concluded green
|
|
22
|
+
*/
|
|
23
|
+
const fs_1 = require("fs");
|
|
24
|
+
const releaseGit_1 = require("./releaseGit");
|
|
25
|
+
/**
|
|
26
|
+
* the generated main-branch workflow whose runs gate a queued release.
|
|
27
|
+
* Keep in sync with `workflowFileName` / GENERATED_FILE_PREFIX in
|
|
28
|
+
* pipeline/src/backends/github/GithubBackend.ts.
|
|
29
|
+
*/
|
|
30
|
+
const GITHUB_MAIN_WORKFLOW = "catladder-main.yml";
|
|
31
|
+
/**
|
|
32
|
+
* where a queued release is recorded: a ref outside refs/heads and
|
|
33
|
+
* refs/tags, pointing at the commit the release was queued for.
|
|
34
|
+
* Writable with the job token (`permissions: contents: write`).
|
|
35
|
+
*/
|
|
36
|
+
const QUEUE_MARKER_REF = "refs/catladder/release-queued";
|
|
37
|
+
/**
|
|
38
|
+
* github container jobs: the workspace volume is owned by the host
|
|
39
|
+
* runner user while catci runs as the container user — git refuses the
|
|
40
|
+
* repo ("dubious ownership") without a safe.directory entry. The
|
|
41
|
+
* release entrypoint scripts do the same, but the queue commands run
|
|
42
|
+
* before them.
|
|
43
|
+
*/
|
|
44
|
+
const ensureGitSafeDirectory = async () => {
|
|
45
|
+
await (0, releaseGit_1.git)("config", "--global", "--add", "safe.directory", process.cwd());
|
|
46
|
+
};
|
|
47
|
+
const requireEnv = (name) => {
|
|
48
|
+
const value = process.env[name];
|
|
49
|
+
if (!value) {
|
|
50
|
+
throw new Error(`${name} is not set`);
|
|
51
|
+
}
|
|
52
|
+
return value;
|
|
53
|
+
};
|
|
54
|
+
const fail = (message) => {
|
|
55
|
+
console.error(message);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* step outputs of the github-actions step running the command
|
|
60
|
+
* (`$GITHUB_OUTPUT` is always set in workflow steps)
|
|
61
|
+
*/
|
|
62
|
+
const setStepOutput = (name, value) => {
|
|
63
|
+
const file = process.env.GITHUB_OUTPUT;
|
|
64
|
+
if (!file) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
(0, fs_1.appendFileSync)(file, `${name}=${value}\n`);
|
|
68
|
+
};
|
|
69
|
+
const getMainWorkflowRun = async (sha) => {
|
|
70
|
+
var _a, _b, _c;
|
|
71
|
+
const apiUrl = (_a = process.env.GITHUB_API_URL) !== null && _a !== void 0 ? _a : "https://api.github.com";
|
|
72
|
+
const repository = requireEnv("GITHUB_REPOSITORY");
|
|
73
|
+
const token = requireEnv("GITHUB_TOKEN");
|
|
74
|
+
const response = await fetch(`${apiUrl}/repos/${repository}/actions/workflows/${GITHUB_MAIN_WORKFLOW}/runs?head_sha=${sha}&per_page=5`, {
|
|
75
|
+
headers: {
|
|
76
|
+
authorization: `Bearer ${token}`,
|
|
77
|
+
accept: "application/vnd.github+json",
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
if (!response.ok) {
|
|
81
|
+
throw new Error(`listing ${GITHUB_MAIN_WORKFLOW} runs failed: ${response.status} ${await response.text()}`);
|
|
82
|
+
}
|
|
83
|
+
const data = (await response.json());
|
|
84
|
+
// newest first — re-runs replace older attempts
|
|
85
|
+
return (_c = (_b = data.workflow_runs) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : null;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* `catci release github-queue-check` — first step of the manual
|
|
89
|
+
* create-release dispatch job. Decides between releasing right away
|
|
90
|
+
* (queued=false) and queueing for the running main workflow
|
|
91
|
+
* (queued=true).
|
|
92
|
+
*/
|
|
93
|
+
const githubQueueCheckJob = async () => {
|
|
94
|
+
await ensureGitSafeDirectory();
|
|
95
|
+
const sha = await (0, releaseGit_1.git)("rev-parse", "HEAD");
|
|
96
|
+
const run = await getMainWorkflowRun(sha);
|
|
97
|
+
if (!run) {
|
|
98
|
+
console.log(`no main workflow run found for ${sha} — releasing right away`);
|
|
99
|
+
setStepOutput("queued", "false");
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (run.status === "completed") {
|
|
103
|
+
if (run.conclusion === "success") {
|
|
104
|
+
console.log(`main workflow for ${sha} succeeded — releasing right away`);
|
|
105
|
+
setStepOutput("queued", "false");
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
fail(`the main workflow for ${sha} concluded '${run.conclusion}' — ` +
|
|
109
|
+
`fix the pipeline, or use the force-create-release task to release anyway`);
|
|
110
|
+
}
|
|
111
|
+
// queued / in_progress / waiting: record the intent and let the
|
|
112
|
+
// release-on-green workflow do the release. Force-push: a re-queue
|
|
113
|
+
// (or a stale marker of an older commit) just moves the marker.
|
|
114
|
+
await (0, releaseGit_1.git)("push", "origin", `+${sha}:${QUEUE_MARKER_REF}`);
|
|
115
|
+
console.log(`main workflow for ${sha} is ${run.status} — release queued: ` +
|
|
116
|
+
`the 'release on green' workflow creates the release as soon as the run succeeds`);
|
|
117
|
+
setStepOutput("queued", "true");
|
|
118
|
+
};
|
|
119
|
+
exports.githubQueueCheckJob = githubQueueCheckJob;
|
|
120
|
+
/**
|
|
121
|
+
* `catci release github-queued-guard <head-sha> <conclusion>` — guard
|
|
122
|
+
* step of the release-on-green workflow, running on every completed
|
|
123
|
+
* main workflow run. Consumes the marker when it matches the run and
|
|
124
|
+
* decides whether the release step runs (release=true).
|
|
125
|
+
*/
|
|
126
|
+
const githubQueuedGuardJob = async (headSha, conclusion) => {
|
|
127
|
+
var _a;
|
|
128
|
+
await ensureGitSafeDirectory();
|
|
129
|
+
const markerLine = await (0, releaseGit_1.git)("ls-remote", "origin", QUEUE_MARKER_REF);
|
|
130
|
+
const marker = (_a = markerLine.split(/\s+/)[0]) !== null && _a !== void 0 ? _a : "";
|
|
131
|
+
if (!marker) {
|
|
132
|
+
console.log("no release queued — nothing to do");
|
|
133
|
+
setStepOutput("release", "false");
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (marker !== headSha) {
|
|
137
|
+
console.log(`queued release is for ${marker}, this run is for ${headSha} — leaving the queue untouched`);
|
|
138
|
+
setStepOutput("release", "false");
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
// consume the marker either way: the queued intent applied to exactly
|
|
142
|
+
// this run, whatever its outcome
|
|
143
|
+
await (0, releaseGit_1.git)("push", "origin", `:${QUEUE_MARKER_REF}`);
|
|
144
|
+
if (conclusion !== "success") {
|
|
145
|
+
fail(`queued release not executed: the main workflow concluded '${conclusion}' — ` +
|
|
146
|
+
`fix the pipeline and queue again (create-release task)`);
|
|
147
|
+
}
|
|
148
|
+
console.log(`main workflow for ${headSha} succeeded — releasing`);
|
|
149
|
+
setStepOutput("release", "true");
|
|
150
|
+
};
|
|
151
|
+
exports.githubQueuedGuardJob = githubQueuedGuardJob;
|
|
152
|
+
//# sourceMappingURL=githubQueuedRelease.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"githubQueuedRelease.js","sourceRoot":"","sources":["../../../../../src/release/githubQueuedRelease.ts"],"names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