Build Python wheels #3
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 Python wheels | |
on: | |
workflow_dispatch: | |
inputs: | |
upload: | |
description: 'Upload wheels to PyPI? (0: no, 1: yes)' | |
required: true | |
default: '0' | |
jobs: | |
build_wheels: | |
strategy: | |
matrix: | |
os: [ubuntu-20.04, windows-latest, macos-latest] | |
python: [cp38, cp39, cp310, cp311, cp312, cp313] | |
fail-fast: false | |
name: > | |
${{ matrix.python }} wheel for ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: Wandalen/[email protected] | |
with: | |
action: actions/checkout@v3 | |
with: | | |
submodules: recursive | |
attempt_limit: 3 | |
attempt_delay: 2000 | |
- uses: actions/setup-python@v4 | |
name: Install Python | |
with: | |
python-version: '3.10' | |
- name: Prepare compiler environment for Windows | |
if: runner.os == 'Windows' | |
uses: ilammy/msvc-dev-cmd@v1 | |
with: | |
arch: x64 | |
- name: Install cibuildwheel | |
run: | | |
python -m pip install cibuildwheel==2.20.0 | |
- name: Build wheels | |
env: | |
CIBW_BUILD: ${{ matrix.python }}-* | |
run: | | |
python -m cibuildwheel --output-dir wheelhouse | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: ./wheelhouse/*.whl | |
upload_pypi: | |
name: Upload wheels to PyPI | |
runs-on: ubuntu-latest | |
if: ${{ github.event.inputs.upload == '1'}} | |
needs: [build_wheels] | |
steps: | |
- uses: actions/download-artifact@v2 | |
with: | |
name: wheels | |
path: dist | |
- uses: pypa/[email protected] | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_PASSWORD }} |