Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,30 @@ jobs:
# When they disagree, v1.3.0 silently publishes 1.4.0 (or worse, republishes an
# existing version), which is exactly the ambiguity that let this repo's main and
# Maven Central diverge. Refuse rather than guess.
- name: Verify the tag matches the pom version
if: startsWith(github.ref, 'refs/tags/v')
# Runs on BOTH triggers. Gating this on github.ref made it skip on every
# workflow_dispatch, because that sets github.ref to the branch holding the workflow
# file (refs/heads/main) no matter which ref was checked out - so the guard was absent
# from exactly the path used to re-drive a failed release. Read the ref that was
# actually built instead.
- name: Verify the ref's version claim matches the pom
env:
BUILT_REF: ${{ github.event.inputs.ref || github.ref_name }}
run: |
case "$BUILT_REF" in
v[0-9]*)
claimed="${BUILT_REF#v}"
;;
*)
# A SHA or branch name asserts no version, so there is nothing to contradict.
echo "Ref '$BUILT_REF' makes no version claim; skipping the cross-check."
echo "Publishing pom version $(mvn -B -q -DforceStdout help:evaluate -Dexpression=project.version)."
exit 0
;;
esac
pom_version=$(mvn -B -q -DforceStdout help:evaluate -Dexpression=project.version)
tag_version="${GITHUB_REF_NAME#v}"
echo "tag: $tag_version pom: $pom_version"
if [ "$pom_version" != "$tag_version" ]; then
echo "::error::Tag $GITHUB_REF_NAME does not match pom version $pom_version. Bump the pom and re-tag."
echo "ref claims: $claimed pom says: $pom_version"
if [ "$pom_version" != "$claimed" ]; then
echo "::error::Ref $BUILT_REF claims version $claimed but the pom is $pom_version. Publishing would ship $pom_version under a $BUILT_REF label."
exit 1
fi

Expand Down
Loading