Skip to content

Commit 1f0f99d

Browse files
committed
ci: add version consistency check before PyPI publish
1 parent 5d084fc commit 1f0f99d

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,27 @@ on:
55
types: [published]
66

77
jobs:
8+
check-version:
9+
name: Verify version matches tag
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v6
14+
15+
- name: Extract and compare versions
16+
run: |
17+
TAG_VERSION="${GITHUB_REF_NAME#v}"
18+
TOML_VERSION=$(python3 -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
19+
20+
if [ "$TAG_VERSION" != "$TOML_VERSION" ]; then
21+
echo "Version mismatch: tag is v$TAG_VERSION, pyproject.toml is $TOML_VERSION"
22+
exit 1
23+
fi
24+
echo "Versions match: $TOML_VERSION"
25+
826
pypi-publish:
927
name: Publish to PyPI
28+
needs: check-version
1029
environment: release
1130
runs-on: ubuntu-latest
1231
permissions:

0 commit comments

Comments
 (0)