Skip to content

2.0.3

2.0.3 #82

Workflow file for this run

name: Python package build and publish with uv
on:
release:
types: [created]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Set up Python
run: uv python install ${{ matrix.python-version }}
- name: Build wheels on Ubuntu (manylinux)
if: matrix.os == 'ubuntu-latest'
uses: RalfG/python-wheels-manylinux-build@v0.7.1-manylinux2014_x86_64
with:
python-versions: 'cp310-cp310 cp311-cp311 cp312-cp312'
build-requirements: 'uv setuptools>=74.0.0 Cython>=3.0.11 wheel>=0.44.0'
system-packages: 'libmemcached-devel openssl-devel zlib-devel'
pre-build-command: 'uv sync --extra build --no-dev'
package-path: '.'
- name: Build wheels on Windows
if: matrix.os == 'windows-latest'
run: |
# Install build dependencies
uv sync --extra build --no-dev
# Install cibuildwheel with uv
uv tool install cibuildwheel
# Build wheels
uv tool run cibuildwheel --output-dir dist
env:
# Configure cibuildwheel
CIBW_SKIP: "pp* *-musllinux*" # Skip PyPy and musl builds
CIBW_BUILD: "cp310-* cp311-* cp312-*"
CIBW_ARCHS_WINDOWS: "AMD64"
# Install build dependencies in the wheel building environment
CIBW_BEFORE_BUILD: "pip install setuptools>=74.0.0 Cython>=3.0.11 wheel>=0.44.0"
# Build Cython extensions
CIBW_BUILD_VERBOSITY: 1
- name: Upload wheel artifacts
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}-py${{ matrix.python-version }}
path: dist/*.whl
build-source:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Set up Python
run: uv python install 3.11
- name: Build source distribution
run: |
# Install build dependencies
uv sync --extra build --no-dev
# Build source distribution
uv build --sdist
- name: Upload source artifacts
uses: actions/upload-artifact@v4
with:
name: source-dist
path: dist/*.tar.gz
deploy:
needs: [build, build-source]
runs-on: ubuntu-latest
if: github.event_name == 'release'
environment:
name: pypi
url: https://pypi.org/p/navconfig
permissions:
id-token: write # For trusted publishing to PyPI
steps:
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist-artifacts
- name: Organize distribution files
run: |
mkdir -p dist
# Move all wheel files to dist directory
find dist-artifacts -name '*.whl' -exec mv {} dist/ \;
# Move source distribution to dist directory
find dist-artifacts -name '*.tar.gz' -exec mv {} dist/ \;
- name: Check for wheel types
id: check_wheels
run: |
echo "Checking for wheel types..."
# Check for manylinux wheels
if ls dist/*-manylinux*.whl 1> /dev/null 2>&1; then
echo "Found manylinux wheels:"
ls -la dist/*-manylinux*.whl
echo "HAS_MANYLINUX_WHEELS=true" >> $GITHUB_ENV
else
echo "No manylinux wheels found."
echo "HAS_MANYLINUX_WHEELS=false" >> $GITHUB_ENV
fi
# Check for Windows wheels
if ls dist/*-win_*.whl 1> /dev/null 2>&1; then
echo "Found Windows wheels:"
ls -la dist/*-win_*.whl
echo "HAS_WINDOWS_WHEELS=true" >> $GITHUB_ENV
else
echo "No Windows wheels found."
echo "HAS_WINDOWS_WHEELS=false" >> $GITHUB_ENV
fi
# Check for source distribution
if ls dist/*.tar.gz 1> /dev/null 2>&1; then
echo "Found source distribution:"
ls -la dist/*.tar.gz
echo "HAS_SOURCE_DIST=true" >> $GITHUB_ENV
else
echo "No source distribution found."
echo "HAS_SOURCE_DIST=false" >> $GITHUB_ENV
fi
- name: List all distribution files
run: |
echo "All files in dist directory:"
ls -la dist/
echo ""
echo "File count: $(ls -1 dist/ | wc -l)"
- name: Publish manylinux wheels to PyPI
run: |
uv tool install twine
uv tool run twine upload dist/*-manylinux*.whl --username __token__ --password ${{ secrets.NAVCONFIG_PYPI_API_TOKEN }}
- name: Publish Windows wheels to PyPI
run: |
uv tool install twine
uv tool run twine upload dist/*-win_*.whl --username __token__ --password ${{ secrets.NAVCONFIG_PYPI_API_TOKEN }}
- name: Publish source distribution to PyPI
run: |
uv tool install twine
uv tool run twine upload dist/*.tar.gz --username __token__ --password ${{ secrets.NAVCONFIG_PYPI_API_TOKEN }}
# Optional: Test installation job
test-install:
needs: deploy
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Set up Python
run: uv python install ${{ matrix.python-version }}
- name: Wait for PyPI propagation
run: sleep 60
- name: Test installation from PyPI
run: |
# Create a temporary environment and test installation
uv venv test-env
source test-env/bin/activate || test-env\Scripts\activate
# Install from PyPI
uv pip install navconfig
# Test basic import
python -c "import navconfig; print(f'NavConfig {navconfig.__version__} installed successfully')"
python -c "from navconfig import config; print('Config object created successfully')"
continue-on-error: true # Don't fail the release if tests fail