Build & Publish Wheels #29
Workflow file for this run
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: Build & Publish Wheels | |
on: | |
workflow_dispatch: | |
inputs: | |
deploy-pypi-test: | |
description: Deploy Test PyPI? | |
required: true | |
default: "yes" | |
deploy-pypi-production: | |
description: Deploy Production PyPI? | |
required: true | |
default: "no" | |
jobs: | |
build-sdist: | |
name: Build sdist package | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Althaia | |
uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Install Poetry | |
run: | | |
export POETRY_HOME=/opt/poetry | |
mkdir -p $POETRY_HOME | |
curl -sSL https://install.python-poetry.org | python3 - | |
pip install taskipy | |
- name: Build sdist | |
run: | | |
export PATH="/opt/poetry/bin:$PATH" | |
poetry run task build-sdist | |
- uses: actions/upload-artifact@v4 | |
if: ${{ !env.ACT }} | |
with: | |
name: wheels-sdist | |
path: ./dist/*.tar.gz | |
# copied from NumPy repo, and tweaked for our needs: | |
# https://github.com/numpy/numpy/blob/main/.github/workflows/wheels.yml | |
build-wheels: | |
name: Build wheel for ${{ matrix.python }}-${{ matrix.buildplat[1] }} | |
runs-on: ${{ matrix.buildplat[0] }} | |
strategy: | |
fail-fast: false | |
matrix: | |
# Github Actions doesn't support pairing matrix values together, let's improvise | |
# https://github.com/github/feedback/discussions/7835#discussioncomment-1769026 | |
buildplat: | |
- [ubuntu-20.04, manylinux_x86_64] | |
- [ubuntu-20.04, musllinux_x86_64] | |
- [ubuntu-20.04, manylinux_aarch64] | |
- [ubuntu-20.04, musllinux_aarch64] | |
- [macos-11, macosx_x86_64] | |
# not supported by github actions, see | |
# https://github.com/actions/virtual-environments/issues/2187 | |
#- [macos-11, macosx_arm64] | |
- [windows-2019, win_amd64] | |
python: | |
- cp39 | |
- cp310 | |
- cp311 | |
- cp312 | |
# looks like pypy can just use sdist, unless we try cffi one day | |
#include: | |
# - buildplat: [ubuntu-20.04, manylinux_x86_64] | |
# python: pp38 | |
# - buildplat: [macos-11, macosx_x86_64] | |
# python: pp38 | |
# - buildplat: [windows-2019, win_amd64] | |
# python: pp38 | |
steps: | |
- name: Checkout Althaia | |
uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Fix missing dependencies | |
run: | | |
python -m pip install pipx | |
python -m pipx ensurepath | |
- name: Set up QEMU | |
if: runner.os == 'Linux' | |
uses: docker/setup-qemu-action@v3 | |
- name: Build wheels | |
uses: pypa/[email protected] | |
with: | |
output-dir: dist | |
env: | |
# most CIBW_* vars are in pyproject.toml | |
DISTUTILS_DEBUG: '1' | |
CIBW_ARCHS_LINUX: "auto aarch64" | |
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }} | |
- uses: actions/upload-artifact@v4 | |
if: ${{ !env.ACT }} | |
with: | |
name: wheels-${{ matrix.python }}-${{ matrix.buildplat[0] }}-${{ matrix.buildplat[1] }} | |
path: ./dist/*.whl | |
- name: Inspect | |
run: | | |
unzip -l 'dist/*.whl' | |
merge: | |
runs-on: ubuntu-latest | |
needs: | |
- build-sdist | |
- build-wheels | |
steps: | |
- name: Merge Artifacts | |
uses: actions/upload-artifact/merge@v4 | |
with: | |
name: wheels | |
pattern: wheels-* | |
testpypi_upload: | |
runs-on: ubuntu-latest | |
environment: staging | |
if: ${{ github.event.inputs.deploy-pypi-test == 'yes' }} | |
needs: | |
- merge | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: wheels | |
path: dist | |
- uses: pypa/[email protected] | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_TOKEN }} | |
repository_url: ${{ secrets.PYPI_REPOSITORY }} | |
skip_existing: true | |
verbose: true | |
# TODO: move to a separate action w/ params for environment | |
prodpypi_upload: | |
runs-on: ubuntu-latest | |
environment: production | |
if: ${{ github.event.inputs.deploy-pypi-production == 'yes' }} | |
needs: | |
- merge | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: wheels | |
path: dist | |
- uses: pypa/[email protected] | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_TOKEN }} | |
repository_url: ${{ secrets.PYPI_REPOSITORY }} | |
skip_existing: true | |
verbose: true |