Publish Python #2
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: Publish Python | |
on: | |
workflow_run: | |
branches: | |
- main | |
workflows: | |
- Tests & Checks | |
types: | |
- completed | |
workflow_dispatch: | |
permissions: write-all | |
jobs: | |
linux-gnu: | |
name: Build Linux (GNU) | |
runs-on: ${{ matrix.platform.runner }} | |
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} | |
strategy: | |
matrix: | |
platform: | |
- runner: ubuntu-latest | |
target: x86_64 | |
rustflags: -Ctarget-cpu=x86-64-v2 | |
- runner: ubuntu-latest | |
target: x86 | |
- runner: ubuntu-latest | |
target: aarch64 | |
- runner: ubuntu-latest | |
target: armv7 | |
- runner: ubuntu-latest | |
target: ppc64le | |
toolchain: | |
- stable | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
show-progress: false | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
env: | |
RUSTFLAGS: ${{ matrix.platform.rustflags }} | |
with: | |
target: ${{ matrix.platform.target }} | |
rust-toolchain: ${{ matrix.toolchain }} | |
args: --release --out dist --zig | |
sccache: false | |
manylinux: manylinux_2_28 | |
working-directory: packages/python | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-linux-${{ matrix.platform.target }} | |
path: packages/python/dist | |
linux-musl: | |
name: Build Linux (musl) | |
runs-on: ${{ matrix.platform.runner }} | |
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} | |
strategy: | |
matrix: | |
platform: | |
- runner: ubuntu-latest | |
target: x86_64 | |
rustflags: -Ctarget-cpu=x86-64-v2 | |
- runner: ubuntu-latest | |
target: x86 | |
- runner: ubuntu-latest | |
target: aarch64 | |
- runner: ubuntu-latest | |
target: armv7 | |
toolchain: | |
- stable | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
show-progress: false | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
env: | |
RUSTFLAGS: ${{ matrix.platform.rustflags }} | |
with: | |
target: ${{ matrix.platform.target }} | |
rust-toolchain: ${{ matrix.toolchain }} | |
args: --release --out dist --zig | |
sccache: false | |
manylinux: musllinux_1_2 | |
working-directory: packages/python | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-musllinux-${{ matrix.platform.target }} | |
path: packages/python/dist | |
windows: | |
name: Build Windows | |
runs-on: ${{ matrix.platform.runner }} | |
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} | |
strategy: | |
matrix: | |
platform: | |
- runner: windows-latest | |
target: x64 | |
rustflags: -Ctarget-cpu=x86-64-v2 -Ctarget-feature=+crt-static | |
- runner: windows-latest | |
target: x86 | |
rustflags: -Ctarget-feature=+crt-static | |
toolchain: | |
- stable | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
show-progress: false | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
architecture: ${{ matrix.platform.target }} | |
- name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.platform.target }} | |
rust-toolchain: ${{ matrix.toolchain }} | |
args: --release --out dist | |
sccache: false | |
working-directory: packages/python | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-windows-${{ matrix.platform.target }} | |
path: packages/python/dist | |
macos: | |
name: Build macOS | |
runs-on: ${{ matrix.platform.runner }} | |
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} | |
strategy: | |
matrix: | |
platform: | |
- runner: macos-13 | |
target: x86_64 | |
- runner: macos-14 | |
target: aarch64 | |
toolchain: | |
- stable | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
show-progress: false | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.platform.target }} | |
rust-toolchain: ${{ matrix.toolchain }} | |
args: --release --out dist | |
sccache: false | |
working-directory: packages/python | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-macos-${{ matrix.platform.target }} | |
path: packages/python/dist | |
sdist: | |
name: Build sdist | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
show-progress: false | |
- name: Build sdist | |
uses: PyO3/maturin-action@v1 | |
with: | |
command: sdist | |
args: --out dist | |
working-directory: packages/python | |
- name: Upload sdist | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-sdist | |
path: packages/python/dist | |
publish: | |
name: Publish | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} | |
needs: [linux-gnu, linux-musl, windows, macos, sdist] | |
steps: | |
- name: Download wheels | |
uses: actions/download-artifact@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Publish (dry-run) | |
if: github.ref == 'refs/heads/main' && github.repository_owner == 'Systemcluster' && env.MATURIN_PYPI_TOKEN == '' | |
env: | |
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_REGISTRY_TOKEN }} | |
run: | | |
python -m pip install --upgrade twine | |
python -m twine check --strict wheels-*/* | |
- name: Publish | |
if: github.ref == 'refs/heads/main' && github.repository_owner == 'Systemcluster' && env.MATURIN_PYPI_TOKEN != '' | |
uses: PyO3/maturin-action@v1 | |
env: | |
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_REGISTRY_TOKEN }} | |
with: | |
command: upload | |
args: --non-interactive --skip-existing wheels-*/* | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python | |
path: wheels-* |