@catladder/cli 0.0.0-next-401fe684 → 0.0.0-next-23a53e9e
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/bundles/catci/index.js +4 -4
- package/dist/bundles/catenv/index.js +62 -14
- package/dist/bundles/cli/index.js +62 -14
- package/dist/bundles/runner-images/changesets/Dockerfile +13 -0
- package/dist/bundles/runner-images/changesets/scripts/changesetsRelease +37 -0
- package/dist/bundles/runner-images/semantic-release/Dockerfile +4 -0
- package/dist/bundles/runner-images/semantic-release/scripts/semanticRelease +43 -4
- package/dist/cli/src/catci.js +16 -0
- package/dist/cli/src/catci.js.map +1 -1
- package/dist/cli/src/release/changesets.d.ts +44 -0
- package/dist/cli/src/release/changesets.js +124 -0
- package/dist/cli/src/release/changesets.js.map +1 -0
- package/dist/cli/src/release/changesetsReleaseJob.d.ts +9 -0
- package/dist/cli/src/release/changesetsReleaseJob.js +160 -0
- package/dist/cli/src/release/changesetsReleaseJob.js.map +1 -0
- package/dist/pipeline/src/backends/github/GithubBackend.js +5 -1
- package/dist/pipeline/src/backends/github/GithubBackend.js.map +1 -1
- package/dist/pipeline/src/backends/github/githubReleaseJobs.js +21 -9
- package/dist/pipeline/src/backends/github/githubReleaseJobs.js.map +1 -1
- package/dist/pipeline/src/backends/gitlab/gitlabReleaseJobs.js +5 -3
- package/dist/pipeline/src/backends/gitlab/gitlabReleaseJobs.js.map +1 -1
- package/dist/pipeline/src/constants.js +1 -1
- package/dist/pipeline/src/customImages/shippedImages.js +1 -0
- package/dist/pipeline/src/customImages/shippedImages.js.map +1 -1
- package/dist/pipeline/src/index.d.ts +1 -0
- package/dist/pipeline/src/index.js +1 -0
- package/dist/pipeline/src/index.js.map +1 -1
- package/dist/pipeline/src/release/index.d.ts +23 -0
- package/dist/pipeline/src/release/index.js +21 -0
- package/dist/pipeline/src/release/index.js.map +1 -0
- package/dist/pipeline/src/runner/index.d.ts +1 -1
- package/dist/pipeline/src/runner/index.js.map +1 -1
- package/dist/pipeline/src/types/release.d.ts +18 -0
- package/dist/runner-images/changesets/Dockerfile +13 -0
- package/dist/runner-images/changesets/scripts/changesetsRelease +37 -0
- package/dist/runner-images/semantic-release/Dockerfile +4 -0
- package/dist/runner-images/semantic-release/scripts/semanticRelease +43 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/src/catci.ts +23 -0
- package/src/release/__tests__/changesets.test.ts +168 -0
- package/src/release/changesets.ts +156 -0
- package/src/release/changesetsReleaseJob.ts +213 -0
|
@@ -1,7 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* how releases are created:
|
|
3
|
+
* - "semantic-release" (default): the version is derived automatically
|
|
4
|
+
* from conventional commit messages since the last release
|
|
5
|
+
* - "changesets": developers declare changes intentionally as
|
|
6
|
+
* `.changeset/*.md` files (bump type + human-written summary,
|
|
7
|
+
* official changesets format); the release job consumes them and
|
|
8
|
+
* derives the version from the last `v*` git tag
|
|
9
|
+
*
|
|
10
|
+
* Both methods gate on the security audit, commit a changelog and push
|
|
11
|
+
* a `vX.Y.Z` tag that triggers the taggedRelease pipeline.
|
|
12
|
+
*/
|
|
13
|
+
export type ReleaseMethod = "semantic-release" | "changesets";
|
|
1
14
|
export type ReleaseConfig = {
|
|
2
15
|
/**
|
|
3
16
|
* Whether to release automatically or manually on main branch.
|
|
4
17
|
* Defaults to "manuel"
|
|
5
18
|
*/
|
|
6
19
|
when?: "manual" | "auto";
|
|
20
|
+
/**
|
|
21
|
+
* how the release version and changelog are created.
|
|
22
|
+
* Defaults to "semantic-release".
|
|
23
|
+
*/
|
|
24
|
+
method?: ReleaseMethod;
|
|
7
25
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
FROM node:lts-alpine
|
|
2
|
+
|
|
3
|
+
RUN apk add --no-cache bash git git-lfs
|
|
4
|
+
|
|
5
|
+
# no release tooling baked in: the changesets release logic lives in
|
|
6
|
+
# catci, which is materialized into the repository checkout
|
|
7
|
+
# (.catladder-generated/catci) by pipeline generation
|
|
8
|
+
|
|
9
|
+
RUN mkdir -p /scripts
|
|
10
|
+
COPY ./scripts/* /scripts/
|
|
11
|
+
RUN chmod +x /scripts/*
|
|
12
|
+
|
|
13
|
+
ENV PATH="/scripts:${PATH}"
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
# 0. check and evaluate security audit or create MR with security audit template (and exit 1)
|
|
5
|
+
# 1. compute the next version from the last v* tag + pending .changeset/*.md files
|
|
6
|
+
# 2. write the changelog, commit, tag and push (all done by catci)
|
|
7
|
+
|
|
8
|
+
# NOTE: keep the security-audit gate below in sync with
|
|
9
|
+
# runner-images/semantic-release/scripts/semanticRelease
|
|
10
|
+
|
|
11
|
+
if [ "$GITHUB_ACTIONS" = "true" ]; then
|
|
12
|
+
# github container jobs: the workspace volume is owned by the host
|
|
13
|
+
# runner user while this step runs as the container user, and the
|
|
14
|
+
# safe.directory entry actions/checkout writes goes to a temporary
|
|
15
|
+
# HOME that is gone by now — git would refuse the repo ("dubious
|
|
16
|
+
# ownership")
|
|
17
|
+
git config --global --add safe.directory "$(pwd)"
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
echo "doing security audit check"
|
|
21
|
+
CATCI=".catladder-generated/catci/index.js"
|
|
22
|
+
if [ -f "$CATCI" ]; then
|
|
23
|
+
# catci is materialized by pipeline generation — always the exact
|
|
24
|
+
# catladder version that generated this pipeline
|
|
25
|
+
if [ "$GITHUB_ACTIONS" = "true" ]; then
|
|
26
|
+
# github: gate only — the MR remediation is gitlab-specific
|
|
27
|
+
node "$CATCI" security-audit check ./
|
|
28
|
+
else
|
|
29
|
+
node "$CATCI" security-audit ci-job ./ "$GL_TOKEN" "$CI_DEFAULT_BRANCH" "$CI_PROJECT_ID" "$GITLAB_USER_ID"
|
|
30
|
+
fi
|
|
31
|
+
else
|
|
32
|
+
echo "$CATCI not found — regenerate the pipeline with a current catladder version (catenv)"
|
|
33
|
+
exit 1
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
echo "doing changesets release"
|
|
37
|
+
node "$CATCI" release changesets
|
|
@@ -7,6 +7,10 @@ FROM node:22-alpine
|
|
|
7
7
|
RUN apk add --no-cache bash git git-lfs
|
|
8
8
|
|
|
9
9
|
# add semantic release
|
|
10
|
+
# NOTE: keep every plugin pinned to a major that is compatible with
|
|
11
|
+
# semantic-release@19 (they declare `semantic-release` as a peer dependency).
|
|
12
|
+
# Unpinned plugins drift to their latest major on image rebuild, which now
|
|
13
|
+
# requires semantic-release>=20 and fails with "plugins configuration is invalid".
|
|
10
14
|
RUN yarn global add \
|
|
11
15
|
semantic-release@19.0.5 \
|
|
12
16
|
@semantic-release/commit-analyzer@13.0.1 \
|
|
@@ -8,6 +8,15 @@ set -e
|
|
|
8
8
|
|
|
9
9
|
# better branches settings: https://github.com/semantic-release/semantic-release/issues/1581
|
|
10
10
|
|
|
11
|
+
if [ "$GITHUB_ACTIONS" = "true" ]; then
|
|
12
|
+
# github container jobs: the workspace volume is owned by the host
|
|
13
|
+
# runner user while this step runs as the container user, and the
|
|
14
|
+
# safe.directory entry actions/checkout writes goes to a temporary
|
|
15
|
+
# HOME that is gone by now — git would refuse the repo ("dubious
|
|
16
|
+
# ownership", surfacing as ENOGITREPO from semantic-release)
|
|
17
|
+
git config --global --add safe.directory "$(pwd)"
|
|
18
|
+
fi
|
|
19
|
+
|
|
11
20
|
echo "doing security audit check"
|
|
12
21
|
CATCI=".catladder-generated/catci/index.js"
|
|
13
22
|
if [ -f "$CATCI" ]; then
|
|
@@ -30,6 +39,18 @@ fi
|
|
|
30
39
|
|
|
31
40
|
echo "doing semantic release"
|
|
32
41
|
|
|
42
|
+
if [ "$GITHUB_ACTIONS" = "true" ]; then
|
|
43
|
+
# the gitlab publish plugin would fail on github; skip it (the tag
|
|
44
|
+
# and changelog commit still happen, only the gitlab release entry
|
|
45
|
+
# is gitlab-specific)
|
|
46
|
+
PUBLISH_PLUGIN=""
|
|
47
|
+
else
|
|
48
|
+
PUBLISH_PLUGIN=',
|
|
49
|
+
["@semantic-release/gitlab", {
|
|
50
|
+
"gitlabUrl": "https://git.panter.ch"
|
|
51
|
+
}]'
|
|
52
|
+
fi
|
|
53
|
+
|
|
33
54
|
if [ ! -e .releaserc ]; then
|
|
34
55
|
cat >.releaserc <<EOF
|
|
35
56
|
{
|
|
@@ -58,10 +79,7 @@ if [ ! -e .releaserc ]; then
|
|
|
58
79
|
"@semantic-release/changelog",
|
|
59
80
|
["@semantic-release/git", {
|
|
60
81
|
"message": "chore(\${branch.type}): \${nextRelease.version}\n\n\${nextRelease.notes}"
|
|
61
|
-
}]
|
|
62
|
-
["@semantic-release/gitlab", {
|
|
63
|
-
"gitlabUrl": "https://git.panter.ch"
|
|
64
|
-
}]
|
|
82
|
+
}]${PUBLISH_PLUGIN}
|
|
65
83
|
],
|
|
66
84
|
"branches": [
|
|
67
85
|
"+([0-9])?(.{+([0-9]),x}).x",
|
|
@@ -81,4 +99,25 @@ if [ ! -e .releaserc ]; then
|
|
|
81
99
|
}
|
|
82
100
|
EOF
|
|
83
101
|
fi
|
|
102
|
+
|
|
103
|
+
if [ "$GITHUB_ACTIONS" = "true" ]; then
|
|
104
|
+
TAGS_BEFORE=$(git tag --list 'v[0-9]*')
|
|
105
|
+
fi
|
|
106
|
+
|
|
84
107
|
semantic-release
|
|
108
|
+
|
|
109
|
+
# tags pushed with the default GITHUB_TOKEN don't trigger `on: push:
|
|
110
|
+
# tags` workflows (github's recursion guard) — dispatch the
|
|
111
|
+
# taggedRelease workflow explicitly for a tag semantic-release created
|
|
112
|
+
if [ "$GITHUB_ACTIONS" = "true" ] && [ -f "$CATCI" ]; then
|
|
113
|
+
if [ -z "$TAGS_BEFORE" ]; then
|
|
114
|
+
NEW_TAG=$(git tag --list 'v[0-9]*' | tail -n1)
|
|
115
|
+
else
|
|
116
|
+
NEW_TAG=$(git tag --list 'v[0-9]*' | grep -Fxv -f <(printf '%s\n' "$TAGS_BEFORE") | tail -n1 || true)
|
|
117
|
+
fi
|
|
118
|
+
if [ -n "$NEW_TAG" ]; then
|
|
119
|
+
node "$CATCI" release dispatch-tagged-workflow "$NEW_TAG"
|
|
120
|
+
else
|
|
121
|
+
echo "no new release tag created — skipping taggedRelease dispatch"
|
|
122
|
+
fi
|
|
123
|
+
fi
|