Skip to content

Commit 1fdfa2c

Browse files
jeffjensenclaude
andcommitted
ci: Guard release tag against project version mismatch
The deploy publishes the POM version while the GitHub Release title came from the tag suffix, so a mistyped tag could publish one version and announce another. Resolve the version from the POM, fail unless the tag encodes exactly that version, and title the GitHub Release from the resolved version. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0133BgD2ro4ZJh1TaXHrZSff
1 parent de3fe85 commit 1fdfa2c

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
runs-on: ubuntu-latest
2121
timeout-minutes: 120
2222
environment: release
23+
outputs:
24+
version: ${{ steps.resolve.outputs.version }}
2325
steps:
2426
- uses: actions/checkout@v7
2527
with:
@@ -33,6 +35,22 @@ jobs:
3335
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
3436
gpg-passphrase: MAVEN_GPG_PASSPHRASE
3537

38+
# Guard against a mistyped tag releasing the wrong version: the POM is the
39+
# source of truth for what gets deployed, so the tag must encode exactly that
40+
# version. The resolved version also titles the GitHub Release below.
41+
- name: Verify tag matches project version
42+
id: resolve
43+
env:
44+
TAG: ${{ github.ref_name }}
45+
run: |
46+
version="$(${{ env.MAVEN_COMMAND }} help:evaluate -Dexpression=project.version -q -DforceStdout)"
47+
expected="v${version}"
48+
if [ "$TAG" != "$expected" ]; then
49+
echo "::error::Tag '$TAG' does not match project version (expected '$expected'). Refusing to release."
50+
exit 1
51+
fi
52+
echo "version=${version}" >> "$GITHUB_OUTPUT"
53+
3654
# Tests already ran during release:prepare; skip surefire and the archetype
3755
# integration tests (archetype.test.skip — -DskipTests does not cover them).
3856
- name: Deploy release to Maven Central
@@ -57,9 +75,10 @@ jobs:
5775
env:
5876
GH_TOKEN: ${{ github.token }}
5977
TAG: ${{ github.ref_name }} # via env to avoid script injection
78+
VERSION: ${{ needs.release.outputs.version }}
6079
run: |
6180
gh release create "$TAG" \
6281
--repo "${{ github.repository }}" \
63-
--title "${TAG#v}" \
82+
--title "$VERSION" \
6483
--generate-notes \
6584
--verify-tag

0 commit comments

Comments
 (0)