Build and upload to PyPI #40
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_BUILD: "cp${{ matrix.python-version }}-*" | |
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 |