name: build-publish
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
only:
description: "Limit to a platform (linux/macos/windows/all)"
default: "linux"
type: choice
options: [linux, macos, windows, all]
jobs:
plan:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set.outputs.matrix }}
steps:
- id: set
shell: bash
run: |
if [[ "${{ github.event_name }}" == "push" || "${{ inputs.only }}" == "all" ]]; then
echo 'matrix={"os":["ubuntu-latest","macos-latest","windows-latest"], "py":["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]}' >> "$GITHUB_OUTPUT"
elif [[ "${{ inputs.only }}" == "linux" ]]; then
echo 'matrix={"os":["ubuntu-latest"], "py":["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]}' >> "$GITHUB_OUTPUT"
elif [[ "${{ inputs.only }}" == "macos" ]]; then
echo 'matrix={"os":["macos-latest"], "py":["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]}' >> "$GITHUB_OUTPUT"
else
echo 'matrix={"os":["windows-latest"], "py":["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]}' >> "$GITHUB_OUTPUT"
fi
build:
needs: plan
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.plan.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.py }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py }}
- name: Build wheels for fastnnt-py ${{ runner.os }}-py${{ matrix.py }}
uses: PyO3/maturin-action@v1
with:
manylinux: "auto"
args: --release -m fastnnt-py/Cargo.toml -i python${{ matrix.py }}
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ runner.os }}-py${{ matrix.py }}
path: fastnnt-py/target/wheels/*.whl
publish:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all wheels
uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
path: dist
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Publish to PyPI
env:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
python -m pip install --upgrade pip twine
twine upload -u __token__ -p "$PYPI_API_TOKEN" --skip-existing dist/*