Skip to content

packaging

packaging #53

Workflow file for this run

name: packaging
on:
push:
tags:
- "*"
jobs:
wheel:
name: Python ${{ matrix.python-version }}, ${{ matrix.platform.name }}
runs-on: ${{ matrix.platform.os }}
strategy:
matrix:
# This list needs to be kept in sync with:
# - push.yml (rust_impl and c_impl)
# - maturin_build_wheel.py
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
platform: [
# This list should be kept in sync with push.yml.
{ os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu", name: "Linux x64" },
{ os: "macOS-latest", python-architecture: "x64", rust-target: "x86_64-apple-darwin", name: "macOS x64" },
{ os: "macOS-11", python-architecture: "x64", rust-target: "aarch64-apple-darwin", name: "macOS ARM" },
{ os: "windows-latest", python-architecture: "x64", rust-target: "x86_64-pc-windows-msvc", name: "Windows x86" },
{ os: "windows-latest", python-architecture: "x86", rust-target: "i686-pc-windows-msvc", name: "Windows x64" },
]
exclude:
# aarch64 macOS has no support for Python version lower than 3.8
- python-version: 3.7
platform:
os: "macOS-11"
rust-target: "aarch64-apple-darwin"
fail-fast: false
env:
CARGO_BUILD_TARGET: ${{ matrix.platform.rust-target }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.platform.python-architecture }}
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.platform.rust-target }}
- name: install maturin
# Keep the Maturin version in sync with pyproject.toml.
run: pip install "maturin>=0.14,<0.15"
# On Linux we'll run Maturin in a Docker container.
if: matrix.platform.os != 'ubuntu-latest'
- name: build wheel
id: build_wheel
run: python -u .github/workflows/maturin_build_wheel.py
- name: install PyGithub
run: pip install PyGithub
- name: upload release asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TAG: ${{ github.ref }}
run: python -u .github/workflows/upload_github_release_asset.py ${{ steps.build_wheel.outputs.wheel_path }}
# The sdist could be built automatically by each of the wheel jobs above (if
# we didn't set the --no-sdist flag), but we give it its own job here to
# avoid having different platforms race to upload it. The platform shouldn't
# matter for generating the sdist, but in case it ever does, it would be
# better to be consistent.
sdist:
name: sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.8
architecture: x64
- name: install maturin
run: pip install maturin
- name: build sdist
id: build_sdist
run: python -u .github/workflows/maturin_build_sdist.py
- name: install PyGithub
run: pip install PyGithub
- name: upload release asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TAG: ${{ github.ref }}
run: python -u .github/workflows/upload_github_release_asset.py ${{ steps.build_sdist.outputs.sdist_path }}
pypi:
name: pypi
needs:
- wheel
- sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
architecture: x64
- name: install PyGithub
run: pip install PyGithub
- name: install twine
run: pip install twine
- name: twine upload
env:
GITHUB_TAG: ${{ github.ref }}
run: python -u .github/workflows/twine_upload.py