Skip to content

Publish package (PyPI) #14

Publish package (PyPI)

Publish package (PyPI) #14

Workflow file for this run

# Build wheels and sdist and publish new version of the package to PyPI.
name: Publish package (PyPI)
on:
release:
branches: [main]
types: [published]
workflow_dispatch:
# inputs:
# CIBW_BUILD:
# description: 'Override build targets to build. See https://cibuildwheel.pypa.io/en/1.x/options/#build-skip.'
# required: true
env:
CIBW_BUILD: cp39-* cp310-* cp311-* cp312-* cp313-*
jobs:
build-wheels:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019, macos-12]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Build wheels
uses: pypa/[email protected]
with:
output-dir: dist
env:
CIBW_BUILD: ${{ env.CIBW_BUILD }}
CIBW_ARCHS_WINDOWS: auto
CIBW_ARCHS_MACOS: "x86_64 arm64"
CIBW_ARCHS_LINUX: auto
CIBW_BUILD_FRONTEND: pip
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: pytest {project}/tests
- name: Upload wheels to artifact
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.os }}
path: ./dist/*.whl
build-sdist:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build
- name: Build source distribution
run:
python -m build --sdist
- name: Upload source distribution to artifact
uses: actions/upload-artifact@v4
with:
name: dist-source
path: ./dist/*.tar.gz
publish-wheels:
runs-on: ubuntu-latest
needs: [build-wheels, build-sdist]
steps:
- name: Download wheels from artifact
uses: actions/download-artifact@v4
with:
pattern: dist-*
path: ./dist
merge-multiple: true
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: dist