From 9c7e5739a666e5e7b20807d3fa52381b9ce46b58 Mon Sep 17 00:00:00 2001 From: Matt Graham Date: Tue, 8 Oct 2024 15:58:56 +0100 Subject: [PATCH 1/5] Add workflow for building wheels and publishing releases to PyPI --- .github/workflows/build.yml | 100 ++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..2ec3e787 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,100 @@ +# Adapted from example at +# https://github.com/pypa/cibuildwheel/blob/0319c431dedc020eb/examples/github-deploy.yml +# +# Original license: +# +# This project is licensed under the 'BSD 2-clause license'. +# +# Copyright (c) 2017-2023, Joe Rickerby and contributors. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +name: Build (and upload to PyPI for published releases) + +on: + workflow_dispatch: + pull_request: + push: + branches: + - main + release: + types: + - published + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + # macos-13 is an intel runner, macos-14 is apple silicon + os: [ubuntu-latest, windows-latest, macos-13, macos-14] + + steps: + - uses: actions/checkout@v4 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.21.2 + + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl + + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Build sdist + run: pipx run build --sdist + + - uses: actions/upload-artifact@v4 + with: + name: cibw-sdist + path: dist/*.tar.gz + + upload_pypi: + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + environment: pypi + permissions: + id-token: write + if: github.event_name == 'release' && github.event.action == 'published' + steps: + - uses: actions/download-artifact@v4 + with: + # Unpack all CIBW artifacts (wheels + sdist) into dist/ + # pypa/gh-action-pypi-publish action uploads contents of dist/ unconditionally + pattern: cibw-* + path: dist + merge-multiple: true + # Try publishing to Test PyPI first - if there are issues this should + # cause job to fail before attempting to publish on PyPI itself + - name: Publish package distribution to Test PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + - name: Publish package distribution to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + From b9b039a0e8400d7baadd72eda5a378951e28e3b3 Mon Sep 17 00:00:00 2001 From: Matt Graham Date: Tue, 8 Oct 2024 17:00:20 +0100 Subject: [PATCH 2/5] Remove Windows from OS matrix --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2ec3e787..d9f6a0eb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,7 +47,7 @@ jobs: strategy: matrix: # macos-13 is an intel runner, macos-14 is apple silicon - os: [ubuntu-latest, windows-latest, macos-13, macos-14] + os: [ubuntu-latest, macos-13, macos-14] steps: - uses: actions/checkout@v4 From 4651ad69928f2056ca898443b78334a1611830c3 Mon Sep 17 00:00:00 2001 From: Matt Graham Date: Tue, 8 Oct 2024 17:00:37 +0100 Subject: [PATCH 3/5] Don't fail fast in build wheels job --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d9f6a0eb..fb142351 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,6 +45,7 @@ jobs: name: Build wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: # macos-13 is an intel runner, macos-14 is apple silicon os: [ubuntu-latest, macos-13, macos-14] From 825b1e6e46d858079b72cae933f925d2d97178df Mon Sep 17 00:00:00 2001 From: Matt Graham Date: Wed, 9 Oct 2024 09:22:26 +0100 Subject: [PATCH 4/5] Try skipping Python 3.8 MacOS x86_64 build --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fb142351..4fc3b1f5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,6 +44,8 @@ jobs: build_wheels: name: Build wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} + env: + CIBW_SKIP: cp38-macosx_x86_64 strategy: fail-fast: false matrix: From 837b0e484c84f91cf79e861c97b0ea9f63d1b301 Mon Sep 17 00:00:00 2001 From: Matt Graham Date: Wed, 9 Oct 2024 09:27:19 +0100 Subject: [PATCH 5/5] Skip building on `macos-13` (x86_64) entirely --- .github/workflows/build.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4fc3b1f5..d844ac6a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,13 +44,10 @@ jobs: build_wheels: name: Build wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} - env: - CIBW_SKIP: cp38-macosx_x86_64 strategy: fail-fast: false matrix: - # macos-13 is an intel runner, macos-14 is apple silicon - os: [ubuntu-latest, macos-13, macos-14] + os: [ubuntu-latest, macos-latest] steps: - uses: actions/checkout@v4