@@ -31,11 +31,49 @@ jobs:
31
31
run : |
32
32
python -m build
33
33
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
35
59
- name : Publish to PyPI
36
60
env :
37
61
TWINE_USERNAME : __token__
38
62
TWINE_PASSWORD : ${{ secrets.PYPI_TOKEN }}
39
63
run : |
40
- python -m twine check dist/*
41
64
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