| 1 |
# Because this library provides extension modules for macOS, but not for other |
| 2 |
# platforms, we want to provide built distributions for each macOS platform, but we |
| 3 |
# explicitly DON'T want to provide a cross-platform pure-Python wheel to fall back on. |
| 4 |
# |
| 5 |
# This is because in the event that a new Python version is released or a new |
| 6 |
# macOS platform is released, macOS users won't be able to install the built |
| 7 |
# distributions we've provided and should fall back to the source distribution, |
| 8 |
# but pip's behavior is to prefer a pure-Python wheel first, which will be |
| 9 |
# missing the extension modules. |
| 10 |
# |
| 11 |
# However, to provide built distributions for Linux and Windows (which don't |
| 12 |
# have extension modules) we can just build a pure-Python wheel on that |
| 13 |
# platform and override the platform name manually via wheel's --plat-name |
| 14 |
# feature, to provide a platform-specific wheel for all platforms. |
| 15 |
|
| 16 |
name: Build & Publish |
| 17 |
|
| 18 |
on: |
| 19 |
push: |
| 20 |
branches: |
| 21 |
- master |
| 22 |
pull_request: |
| 23 |
branches: |
| 24 |
- "**" |
| 25 |
|
| 26 |
workflow_dispatch: |
| 27 |
inputs: |
| 28 |
branch: |
| 29 |
description: "The branch, tag or SHA to release from" |
| 30 |
required: true |
| 31 |
default: "master" |
| 32 |
|
| 33 |
concurrency: |
| 34 |
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name != 'pull_request' && github.sha || '' }} |
| 35 |
cancel-in-progress: true |
| 36 |
|
| 37 |
jobs: |
| 38 |
macos-built-distributions: |
| 39 |
name: Build macOS wheels |
| 40 |
runs-on: macos-latest |
| 41 |
timeout-minutes: 20 |
| 42 |
steps: |
| 43 |
- name: Checkout |
| 44 |
uses: actions/checkout@v4 |
| 45 |
with: |
| 46 |
ref: ${{ github.event.inputs.branch }} |
| 47 |
- name: Install Python |
| 48 |
uses: actions/setup-python@v5 |
| 49 |
with: |
| 50 |
python-version: "3.11" |
| 51 |
- name: Install build dependencies |
| 52 |
run: python -m pip install cibuildwheel |
| 53 |
- name: Build wheels |
| 54 |
run: python -m cibuildwheel |
| 55 |
env: |
| 56 |
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64" |
| 57 |
- name: Artifacts list |
| 58 |
run: ls -l wheelhouse |
| 59 |
- uses: actions/upload-artifact@v4 |
| 60 |
with: |
| 61 |
name: python-package-distributions-macos |
| 62 |
path: ./wheelhouse/*.whl |
| 63 |
|
| 64 |
pure-built-distributions: |
| 65 |
name: Build pure wheels |
| 66 |
runs-on: ubuntu-latest |
| 67 |
timeout-minutes: 5 |
| 68 |
steps: |
| 69 |
- name: Checkout |
| 70 |
uses: actions/checkout@v4 |
| 71 |
with: |
| 72 |
ref: ${{ github.event.inputs.branch }} |
| 73 |
- name: Install Python |
| 74 |
uses: actions/setup-python@v5 |
| 75 |
with: |
| 76 |
python-version: "3.11" |
| 77 |
- name: Install build dependencies |
| 78 |
run: python -m pip install -U setuptools wheel |
| 79 |
- name: Build wheels |
| 80 |
run: | |
| 81 |
for platform in 'manylinux2014_x86_64' 'manylinux2014_i686' 'manylinux2014_aarch64' 'manylinux2014_armv7l' 'manylinux2014_ppc64' 'manylinux2014_ppc64le' 'manylinux2014_s390x' 'win32' 'win_amd64' 'win_ia64' |
| 82 |
do |
| 83 |
python setup.py bdist_wheel --plat-name $platform |
| 84 |
done |
| 85 |
- name: Artifacts list |
| 86 |
run: ls -l dist |
| 87 |
- uses: actions/upload-artifact@v4 |
| 88 |
with: |
| 89 |
name: python-package-distributions-pure-wheels |
| 90 |
path: ./dist/*.whl |
| 91 |
|
| 92 |
source-distribution: |
| 93 |
name: Build source distribution |
| 94 |
runs-on: ubuntu-latest |
| 95 |
timeout-minutes: 5 |
| 96 |
steps: |
| 97 |
- name: Checkout |
| 98 |
uses: actions/checkout@v4 |
| 99 |
with: |
| 100 |
ref: ${{ github.event.inputs.branch }} |
| 101 |
- name: Install Python |
| 102 |
uses: actions/setup-python@v5 |
| 103 |
with: |
| 104 |
python-version: "3.11" |
| 105 |
- name: Build source distribution |
| 106 |
run: python setup.py sdist |
| 107 |
- name: Artifacts list |
| 108 |
run: ls -l dist |
| 109 |
- name: Store the source distribution |
| 110 |
uses: actions/upload-artifact@v4 |
| 111 |
with: |
| 112 |
name: python-package-distributions-source |
| 113 |
path: dist/*.tar.gz |
| 114 |
|
| 115 |
publish: |
| 116 |
needs: |
| 117 |
- macos-built-distributions |
| 118 |
- pure-built-distributions |
| 119 |
- source-distribution |
| 120 |
runs-on: ubuntu-latest |
| 121 |
timeout-minutes: 5 |
| 122 |
steps: |
| 123 |
- name: Download all the dists |
| 124 |
uses: actions/download-artifact@v4 |
| 125 |
with: |
| 126 |
pattern: python-package-distributions-* |
| 127 |
merge-multiple: true |
| 128 |
path: dist/ |
| 129 |
- name: What will we publish? |
| 130 |
run: ls -l dist |
| 131 |
- name: Publish |
| 132 |
if: github.event.inputs.branch != '' |
| 133 |
uses: pypa/gh-action-pypi-publish@release/v1 |
| 134 |
with: |
| 135 |
user: __token__ |
| 136 |
password: ${{ secrets.PYPI_API_TOKEN }} |
| 137 |
skip-existing: true |