Skip to content

Build and upload to PyPI #41

Build and upload to PyPI

Build and upload to PyPI #41

Workflow file for this run

name: Build and upload to PyPI
on:
release:
types: [published]
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }} for Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.10", "3.11", "3.12"] # Specify the Python versions here
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }} # Use matrix to set Python version
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build cibuildwheel
- name: Build wheels with cibuildwheel
uses: pypa/[email protected]
with:
# Builds for specific Python versions specified in matrix
python-version: ${{ matrix.python-version }}
env:
CIBW_SKIP: "pp*" # Skip non-CPython implementations
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ matrix.python-version }}
path: ./wheelhouse/*.whl
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
run: pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz
upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1