Skip to content

Commit 10d8b3e

Browse files
committed
ci(release): drop @master third-party action; install commitizen direct
The commitizen-tools/commitizen-action@master reference pulled HEAD of an external action's master branch into a job that holds contents:write and AWS OIDC credentials. Replace it with an inline pinned pip install of commitizen==4.16.2 plus a direct cz bump call. Also handle the NoCommitsFoundError (exit 21) and no-op cases so non-semantic main commits still deploy at the existing version; the bump push is gated on a bumped=true output so we never push when there is nothing new. Refs #599
1 parent 238dba9 commit 10d8b3e

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,30 @@ jobs:
123123
ssh-key: ${{ secrets.COMMIT_KEY }}
124124

125125
- name: Bump version with commitizen
126-
uses: commitizen-tools/commitizen-action@master
127-
with:
128-
push: false
126+
id: bump
127+
env:
128+
COMMITIZEN_VERSION: "4.16.2"
129+
run: |
130+
python3 -m pip install --user "commitizen==${COMMITIZEN_VERSION}"
131+
git config user.name "github-actions[bot]"
132+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
133+
PRE_SHA=$(git rev-parse HEAD)
134+
set +e
135+
"$HOME/.local/bin/cz" bump --yes
136+
EXIT_CODE=$?
137+
set -e
138+
POST_SHA=$(git rev-parse HEAD)
139+
if [ "$EXIT_CODE" = "0" ] && [ "$PRE_SHA" != "$POST_SHA" ]; then
140+
echo "bumped=true" >> $GITHUB_OUTPUT
141+
elif [ "$EXIT_CODE" = "0" ] || [ "$EXIT_CODE" = "21" ]; then
142+
# cz returned 21 (NoCommitsFoundError) or succeeded without
143+
# changing HEAD: nothing semantic to bump, deploy at the
144+
# existing version.
145+
echo "bumped=false" >> $GITHUB_OUTPUT
146+
else
147+
echo "cz bump failed unexpectedly with exit code $EXIT_CODE" >&2
148+
exit "$EXIT_CODE"
149+
fi
129150
130151
- name: Identify bump commit
131152
id: bump_commit
@@ -207,7 +228,9 @@ jobs:
207228
208229
- name: Push bump commit and tag to main
209230
# Only happens after every ECR push above has succeeded; a failure
210-
# in the build leaves no stranded bump on the branch.
231+
# in the build leaves no stranded bump on the branch. Skipped when
232+
# commitizen had nothing semantic to bump.
233+
if: steps.bump.outputs.bumped == 'true'
211234
run: |
212235
git push origin main --tags
213236

0 commit comments

Comments
 (0)