Build and publish #20
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 publish | |
on: | |
push: | |
tags: | |
- 'v*.*.*' | |
workflow_dispatch: | |
permissions: | |
contents: read | |
concurrency: | |
group: deploy-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build_wheels: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: ubuntu-latest | |
archs: x86_64 | |
- os: macos-latest | |
archs: x86_64 arm64 | |
- os: ubuntu-latest | |
archs: aarch64 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Set up QEMU to build non-native architectures | |
if: ${{ matrix.archs == 'aarch64' }} | |
uses: docker/setup-qemu-action@v3 | |
- name: Install required Python packages | |
run: | | |
python -m pip install --upgrade pip setuptools wheel cython | |
python -m pip install 'cibuildwheel>=2.2.0' twine | |
- name: Build wheels | |
run: python -m cibuildwheel --output-dir dist | |
env: | |
CIBW_ARCHS: ${{ matrix.archs }} | |
CIBW_SKIP: | | |
cp38-musllinux_* | |
pp38-* | |
pp*-manylinux_i686 | |
${{ matrix.archs == 'aarch64' && 'pp*' }} | |
- name: Check packages | |
run: twine check dist/* | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: "packages-${{ matrix.os }}-${{ matrix.archs }}" | |
path: dist/ | |
build_sdist: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Install required Python packages | |
run: | | |
python -m pip install --upgrade pip setuptools wheel cython numpy | |
python -m pip install build twine | |
- name: Build sdist | |
run: | | |
python setup.py sdist | |
- name: Check packages | |
run: twine check dist/* | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: packages-sdist | |
path: dist/ | |
upload_pypi: | |
needs: [build_wheels, build_sdist] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
path: dist | |
pattern: packages-* | |
- name: Display structure of downloaded files | |
run: ls -R dist/ | |
- name: Publish to PyPI | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && github.repository_owner == 'dleemiller' | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |