Skip to content

Commit 43ed0c7

Browse files
release: check the tag against the version in pyproject.toml
The release fails before it looks for the build runs when the tag is not the version of the tagged commit, instead of publishing a draft with packages named after another version. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 9554cc6 commit 43ed0c7

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,23 @@ jobs:
1818
actions: read
1919

2020
steps:
21+
- name: Check the tag against the version in pyproject.toml
22+
env:
23+
GH_TOKEN: ${{ github.token }}
24+
TAG: ${{ github.ref_name }}
25+
run: |
26+
version=$(gh api -H "Accept: application/vnd.github.raw+json" \
27+
"repos/${GITHUB_REPOSITORY}/contents/pyproject.toml?ref=${GITHUB_SHA}" \
28+
| sed -n 's/^version = "\(.*\)"$/\1/p' | head -n1)
29+
if [ -z "$version" ]; then
30+
echo "::error::Could not read the version from pyproject.toml at ${GITHUB_SHA}."
31+
exit 1
32+
fi
33+
if [ "v$version" != "$TAG" ]; then
34+
echo "::error::The tag $TAG does not match the version $version in pyproject.toml. Bump the version before tagging."
35+
exit 1
36+
fi
37+
2138
- name: Find main-branch build runs for this commit
2239
id: find_runs
2340
env:

0 commit comments

Comments
 (0)