Skip to content

workflow

workflow #4

Workflow file for this run

name: Build and Test Wheels
on:
pull_request:
push:
branches:
- main
- update
tags:
- 'v*'
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.x' # cibuildwheel will use its own Python versions
- name: Install cibuildwheel
run: python -m pip install cibuildwheel
- name: Download test image file
run: |
# Photo by Dillon Hunt (https://unsplash.com/@dillon_hunt) on https://unsplash.com/photos/an-aerial-view-of-the-ocean-and-rocks-zQLd8RXbenw
curl -L -o test_image.jpg "https://unsplash.com/photos/zQLd8RXbenw/download?ixid=M3wxMjA3fDB8MXx0b3BpY3x8NnNNVmpUTFNrZVF8fHx8fDJ8fDE3MzY0MDA3NTd8&force=true&w=2400"
# This step needs to be available for the test command
# For Windows, use PowerShell equivalent
shell: bash
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD_VERBOSITY: 1
CIBW_SKIP: "cp37-* cp38-* pp*" # Skip Python 3.7, 3.8 and PyPy as per existing workflows
CIBW_ARCHS_MACOS: "x86_64 arm64" # Build for both architectures on macOS
CIBW_TEST_COMMAND: >
pip install -r {project}/requirements.txt -r {project}/requirements-dev.txt
python {project}/tests/test_all.py --image test_image.jpg --method pillow &&
python {project}/tests/test_all.py --image test_image.jpg --method cpp
CIBW_BEFORE_BUILD: >
pip install setuptools wheel rich requests pillow
CIBW_ENVIRONMENT: >
PURE_PYTHON=False
- uses: actions/upload-artifact@v4
with:
name: cibuildwheel-wheels-${{ matrix.os }}
path: wheelhouse/*.whl
deploy:
name: Publish to PyPI
needs: build_wheels
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/checkout@v4
- name: Download all wheels
uses: actions/download-artifact@v4
with:
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: dist