Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ jobs:
run: python -m pip install build
- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/
- name: Check distribution with twine
run: |
pip install twine
twine check dist/*
ls -la dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.8
uses: pypa/gh-action-pypi-publish@release/v1.12.4
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }} # Use OIDC token as the default password
password: ${{ secrets.PYPI_API_TOKEN }}
8 changes: 7 additions & 1 deletion .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ jobs:
- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/
- name: Check distribution
run: twine check dist/*
run: |
pip install twine
twine check dist/*
echo "Contents of dist directory:"
ls -la dist/
echo -e "\nChecking wheel metadata:"
python -c "import zipfile, glob; whl = glob.glob('dist/*.whl')[0]; z = zipfile.ZipFile(whl); print(z.read([f for f in z.namelist() if f.endswith('METADATA')][0]).decode()[:500])"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
6 changes: 6 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include LICENSE
include README.md
include pyproject.toml
recursive-exclude * __pycache__
recursive-exclude * *.py[co]
recursive-exclude tests *
87 changes: 87 additions & 0 deletions test_build_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash
# Script to test the build process locally, simulating GitHub Actions

echo "=== Simulating GitHub Actions Build Process ==="
echo

# Clean up any existing build artifacts
echo "1. Cleaning build artifacts..."
rm -rf dist/ build/ *.egg-info

# Install dependencies
echo -e "\n2. Installing dependencies..."
pip install --upgrade pip
pip install -r requirements.txt
pip install -r test-requirements.txt

# Simulate bump2version (without actually bumping)
echo -e "\n3. Current version in pyproject.toml:"
grep "version = " pyproject.toml

# Run tests
echo -e "\n4. Running tests..."
python -m unittest discover -s tests || { echo "Tests failed!"; exit 1; }

# Install build tools
echo -e "\n5. Installing build tools..."
pip install --upgrade build twine

# Build the package
echo -e "\n6. Building package..."
python -m build --sdist --wheel --outdir dist/

# Check with twine
echo -e "\n7. Checking distribution with twine..."
twine check dist/*

# List dist contents
echo -e "\n8. Contents of dist directory:"
ls -la dist/

# Check wheel metadata
echo -e "\n9. Checking wheel metadata:"
python -c "import zipfile, glob; whl = glob.glob('dist/*.whl')[0]; z = zipfile.ZipFile(whl); print(z.read([f for f in z.namelist() if f.endswith('METADATA')][0]).decode()[:500])"

# Simulate the pypa/gh-action-pypi-publish check
echo -e "\n10. Simulating PyPI publish action check..."
python -c "
import zipfile
import glob
import sys

wheel_file = glob.glob('dist/*.whl')[0]
print(f'Checking wheel: {wheel_file}')

with zipfile.ZipFile(wheel_file, 'r') as z:
metadata_files = [f for f in z.namelist() if f.endswith('METADATA')]
if not metadata_files:
print('ERROR: No METADATA file found in wheel!')
sys.exit(1)

metadata_content = z.read(metadata_files[0]).decode('utf-8')

# Check for required fields
required_fields = ['Name:', 'Version:']
missing_fields = []

for field in required_fields:
if field not in metadata_content:
missing_fields.append(field)

if missing_fields:
print(f'ERROR: Missing required fields: {missing_fields}')
print('First 1000 chars of METADATA:')
print(metadata_content[:1000])
sys.exit(1)

# Extract name and version
for line in metadata_content.split('\\n'):
if line.startswith('Name:'):
print(f' {line}')
elif line.startswith('Version:'):
print(f' {line}')

print('✓ Metadata check passed')
"

echo -e "\n=== Build test complete ==="