name: Publish Python package to PyPI
on:
workflow_call:
inputs:
tag:
description: "Tag to publish, e.g. v0.1.0"
required: true
type: string
workflow_dispatch:
inputs:
tag:
description: "Tag to publish, e.g. v0.2.0"
required: true
type: string
push:
tags:
- "v*"
permissions:
contents: read
jobs:
linux:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 with:
ref: ${{ inputs.tag || github.ref }}
- uses: PyO3/maturin-action@3e2bdf6ba6453a61e649744019b8a2d906c7eb38 with:
command: build
args: --release --locked --target ${{ matrix.target }}-unknown-linux-gnu --out dist --manifest-path Cargo.toml
manylinux: auto
working-directory: python
- name: Upload wheels
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with:
name: wheels-linux-${{ matrix.target }}
path: python/dist
windows:
runs-on: windows-latest
strategy:
matrix:
target: [x64]
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 with:
ref: ${{ inputs.tag || github.ref }}
- uses: PyO3/maturin-action@3e2bdf6ba6453a61e649744019b8a2d906c7eb38 with:
command: build
args: --release --locked --target ${{ matrix.target }}-pc-windows-msvc --out dist --manifest-path Cargo.toml
working-directory: python
- name: Upload wheels
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with:
name: wheels-windows-${{ matrix.target }}
path: python/dist
macos:
runs-on: macos-latest
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 with:
ref: ${{ inputs.tag || github.ref }}
- uses: PyO3/maturin-action@3e2bdf6ba6453a61e649744019b8a2d906c7eb38 with:
command: build
args: --release --locked --target ${{ matrix.target }}-apple-darwin --out dist --manifest-path Cargo.toml
working-directory: python
- name: Upload wheels
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with:
name: wheels-macos-${{ matrix.target }}
path: python/dist
sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 with:
ref: ${{ inputs.tag || github.ref }}
- uses: PyO3/maturin-action@3e2bdf6ba6453a61e649744019b8a2d906c7eb38 with:
command: sdist
args: --out dist --manifest-path Cargo.toml
working-directory: python
- name: Upload sdist
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with:
name: sdist
path: python/dist
release:
name: Release
runs-on: ubuntu-latest
needs: [linux, windows, macos, sdist]
permissions:
id-token: write
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c with:
path: dist
pattern: wheels-*
merge-multiple: true
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c with:
path: dist
pattern: sdist
merge-multiple: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@6733eb7d741f0b11ec6a39b58540dab7590f9b7d with:
packages-dir: dist