Skip to content

Commit 0f94614

Browse files
committed
Fail publish workflow when release tag and VERSION file disagree
It is too easy to push a vX.Y.Z tag and cut a release without first bumping the VERSION file. When that happens hatchling reads the stale VERSION, produces a wheel/sdist for the previous version, and the publish step tries to upload artifacts whose filenames disagree with the release the workflow was triggered by. Add a first-step guard in the build job that strips the optional v prefix off the tag and compares against cat VERSION. On mismatch it prints a workflow annotation, dumps both values, explains the usual cause, and exits non-zero before any build or upload happens.
1 parent b699ba6 commit 0f94614

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@ jobs:
1313
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
1414
steps:
1515
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
16+
- name: Verify tag matches VERSION file
17+
run: |
18+
TAG="${GITHUB_REF#refs/tags/}"
19+
TAG_VERSION="${TAG#v}"
20+
FILE_VERSION="$(cat VERSION)"
21+
if [ "$TAG_VERSION" != "$FILE_VERSION" ]; then
22+
echo "::error::Release tag does not match VERSION file."
23+
echo " Tag (raw): $TAG"
24+
echo " Tag (normalized): $TAG_VERSION"
25+
echo " VERSION file: $FILE_VERSION"
26+
echo ""
27+
echo "This almost always means VERSION was not bumped before the tag was cut."
28+
echo "Fix: bump VERSION on master, delete the bad tag and release, re-tag, recreate the release."
29+
exit 1
30+
fi
31+
echo "OK: tag $TAG matches VERSION $FILE_VERSION"
1632
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
1733
with:
1834
python-version: "3.12"

0 commit comments

Comments
 (0)