1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
name: Publish Python π distributions π¦ to PyPI and TestPyPI
on:
push:
branches:
- releases/*
tags:
- v*
jobs:
build_wheels:
name: Build wheels on ${{ matrix.platform }}
runs-on: ${{ matrix.platform }}
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest, ubuntu-24.04-arm, windows-11-arm]
env:
CIBW_ARCHS_LINUX: "native"
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
# Include latest Python beta
CIBW_PRERELEASE_PYTHONS: True
steps:
- name: Checkout ποΈ
uses: actions/checkout@v4
with:
fetch-depth: 20
- name: Fetch release tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python π
uses: actions/setup-python@v6
with:
python-version: 3.13
- name: Install cibuildwheel & build wheels
run: |
python -m pip install -U pip
python -m pip install -U cibuildwheel
python -m cibuildwheel --output-dir wheelhouse
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.platform }}
path: wheelhouse/*.whl
build_source_dist:
name: Build source dist
runs-on: ubuntu-latest
steps:
- name: Checkout ποΈ
uses: actions/checkout@v4
with:
fetch-depth: 20
- name: Fetch release tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python π
uses: actions/setup-python@v6
with:
python-version: 3.13
- name: Build source distribution & wheelsπ‘
run: |
python -m pip install -U pip setuptools setuptools_scm[toml] build
python -m build --sdist
- name: Upload source distribution
uses: actions/upload-artifact@v4
with:
name: artifact-source
path: dist/*.tar.gz
pypi-publish:
name: publish Python π distributions π¦ to PyPI and TestPyPI
runs-on: ubuntu-latest
needs: [build_wheels, build_source_dist]
environment: pypi
permissions:
id-token: write
steps:
- name: download dist artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Publish distribution π¦ to Test PyPI
if: ${{ startsWith(github.event.ref, 'refs/heads/releases') }}
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # release/v1.12.4
with:
repository-url: https://test.pypi.org/legacy/
- name: Publish distribution π¦ to PyPI
if: startsWith(github.event.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # release/v1.12.4
|