Skip to content

Commit 0bd24a2

Browse files
committed
improve publish workflow with checks
1 parent 4767697 commit 0bd24a2

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

.github/workflows/publish.yml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,49 @@ jobs:
3131
run: |
3232
python -m build
3333
34-
# Step 5: Publish to PyPI
34+
# Step 5: Verify the built package
35+
- name: Verify package
36+
run: |
37+
if [ ! -f "dist/*.whl" ] || [ ! -f "dist/*.tar.gz" ]; then
38+
echo "Expected wheel and source distribution files not found in dist/"
39+
exit 1
40+
fi
41+
python -m twine check dist/*
42+
43+
# Step 6: Verify version matches the release tag
44+
- name: Verify version
45+
if: github.event_name == 'release'
46+
run: |
47+
# Extract version from pyproject.toml
48+
PROJECT_VERSION=$(grep "^version = " pyproject.toml | cut -d'"' -f2)
49+
# Remove 'v' prefix from tag if present
50+
TAG_VERSION=${GITHUB_REF#refs/tags/}
51+
TAG_VERSION=${TAG_VERSION#v}
52+
53+
if [ "$PROJECT_VERSION" != "$TAG_VERSION" ]; then
54+
echo "Version mismatch: pyproject.toml version ($PROJECT_VERSION) doesn't match release tag ($TAG_VERSION)"
55+
exit 1
56+
fi
57+
58+
# Step 7: Publish to PyPI
3559
- name: Publish to PyPI
3660
env:
3761
TWINE_USERNAME: __token__
3862
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
3963
run: |
40-
python -m twine check dist/*
4164
python -m twine upload --skip-existing dist/*
65+
66+
# Step 8: Verify package is available on PyPI
67+
- name: Verify PyPI upload
68+
run: |
69+
# Wait a bit for PyPI to process the upload
70+
sleep 30
71+
72+
# Extract package name from pyproject.toml
73+
PACKAGE_NAME=$(grep "^name = " pyproject.toml | cut -d'"' -f2)
74+
75+
# Check if package exists on PyPI
76+
if ! pip install $PACKAGE_NAME==`python setup.py --version` --no-deps --dry-run; then
77+
echo "Failed to verify package on PyPI"
78+
exit 1
79+
fi

0 commit comments

Comments
 (0)