Skip to content

[not ready] Splitting builds by Python version to speed-up CI #386

[not ready] Splitting builds by Python version to speed-up CI

[not ready] Splitting builds by Python version to speed-up CI #386

Workflow file for this run

name: Build Status
on: [push, pull_request]
jobs:
build:
strategy:
max-parallel: 16
fail-fast: false
matrix:
# macos-13 is an intel runner, macos-14 is apple silicon
python: [38, 39, 310, 311, 312]
include:
- os: ubuntu-latest
platform_id: manylinux_x86_64
- os: windows-latest
platform_id: win_amd64
- os: macos-13
platform_id: macosx_x86_64
- os: macos-14
platform_id: macosx_arm64
name: Build wheel on ${{ matrix.os }} for cp${{ matrix.python }}-${{ matrix.platform_id }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout project
uses: actions/checkout@v3
with:
submodules: recursive
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Lint with flake8
run: |
pip3 install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=lib
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude=lib
- name: Build and test wheels
uses: pypa/cibuildwheel@v2.16.5
env:
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
CIBW_ARCHS: all
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
build_sdist:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
submodules: recursive
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Upgrade pip and install build dependency
run: |
python -m pip install --upgrade pip
pip install build
- name: Create source distribution
run: |
pipx run build --sdist
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz
upload_to_pypi:
needs: [build, build_sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- name: Download cibw artifacts
uses: actions/download-artifact@v4
with:
# unpacks all CIBW artifacts into dist/
pattern: cibw-*
path: dist
merge-multiple: true
- name: Publish distribution Test PyPI
if: |
job.status == 'success'
&& github.event_name == 'push'
&& github.ref == 'refs/heads/dev'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution to PyPI
if: |
job.status == 'success'
&& github.event_name == 'push'
&& startsWith(github.event.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_password }}