mirror of
https://github.com/akadeepesh/contextzip.git
synced 2026-10-20 08:36:20 +02:00
ci: improve PyPI release validation
This commit is contained in:
@@ -20,14 +20,14 @@ jobs:
|
||||
|
||||
- name: Check tag matches package version
|
||||
run: |
|
||||
# Extract version from __init__.py
|
||||
PKG_VERSION=$(python -c "import re; content=open('contextzip/__init__.py').read(); print(re.search(r'__version__\s*=\s*[\"\'](.*?)[\"\']', content).group(1))")
|
||||
# GitHub release tag (strips leading 'v' if present, e.g. v0.1.1 → 0.1.1)
|
||||
TOML_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
|
||||
TAG_VERSION="${GITHUB_REF_NAME#v}"
|
||||
echo "Package version : $PKG_VERSION"
|
||||
echo "Release tag : $TAG_VERSION"
|
||||
if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
|
||||
echo "Version mismatch — update __init__.py and pyproject.toml before releasing"
|
||||
echo "Package version (__init__.py): $PKG_VERSION"
|
||||
echo "Package version (pyproject.toml): $TOML_VERSION"
|
||||
echo "Release tag: $TAG_VERSION"
|
||||
if [ "$PKG_VERSION" != "$TAG_VERSION" ] || [ "$TOML_VERSION" != "$TAG_VERSION" ]; then
|
||||
echo "Version mismatch — update __init__.py and/or pyproject.toml before releasing"
|
||||
exit 1
|
||||
fi
|
||||
echo "Versions match"
|
||||
|
||||
Reference in New Issue
Block a user