Build wheels #413
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 wheels | |
on: | |
workflow_dispatch: | |
jobs: | |
build_wheels: | |
name: Build wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false # Allow one of the matrix builds to fail without failing others | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
- name: Install cibuildwheel | |
run: | | |
pip install --upgrade pip | |
pip install cibuildwheel==2.15.0 | |
- name: Build wheels | |
env: | |
CIBW_BUILD: 'cp38-* cp39-* cp310-* cp311-* cp312-*' | |
CIBW_ARCHS_MACOS: x86_64 arm64 | |
CIBW_SKIP: pp* *-musllinux_* *-manylinux_i686 # skip PyPy, musllinux, 32-bit Linux | |
run: | | |
pip install cibuildwheel --upgrade; | |
python -m cibuildwheel --output-dir dist; | |
- name: Store artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: python-package-distributions | |
path: dist/*.whl | |
package_source: | |
name: Package source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
- name: Install build | |
run: python -m pip install build | |
- name: Run sdist | |
run: python -m build --sdist | |
- name: Store artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: python-package-distributions | |
path: ./dist/*.tar.gz | |
publish_to_pypi: | |
needs: | |
- build_wheels | |
- package_source | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/master' # Only publish from the master branch | |
steps: | |
- name: Download build files | |
uses: actions/download-artifact@v3 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Upload to PyPI | |
env: | |
PYPI_PASSWORD: ${{ secrets.pypi_password }} | |
run: | | |
pip install twine; | |
python -m twine upload dist/* -u tommyod -p "$PYPI_PASSWORD" --skip-existing; |