From 111ebff6bb3c8251bd1f3e8424d8c9d785d88fac Mon Sep 17 00:00:00 2001 From: Peter Spackman Date: Sat, 25 Nov 2023 08:30:48 +0800 Subject: [PATCH] Rework build wheels --- .github/workflows/pythonpackage.yml | 73 +++++++++++++++++++++++++++-- .github/workflows/wheels.yml | 68 --------------------------- 2 files changed, 70 insertions(+), 71 deletions(-) delete mode 100644 .github/workflows/wheels.yml diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index bed5281..b5c1553 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -1,6 +1,6 @@ -name: Test +name: Build package -on: [push] +on: [push, pull_request] jobs: build: @@ -10,7 +10,7 @@ jobs: max-parallel: 4 matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ['3.9', '3.10', '3.11'] + python-version: ['3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v4 @@ -64,3 +64,70 @@ jobs: - name: Run tests run: | python -m pytest + + + build_wheels: + runs-on: ${{matrix.os}} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + pyver: [cp39, cp310, cp311, cp312] + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.16.1 + env: + CIBW_BUILD: ${{matrix.pyver}}-* + CIBW_ARCHS_LINUX: auto + CIBW_ARCHS_MACOS: auto universal2 + CIBW_ARCHS_WINDOWS: auto + # musllinux tests fail with some pid mixup + # cross-build macos images can't be tested on this runner. + CIBW_TEST_SKIP: >- + *-* + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: wheels + path: ./wheelhouse/*.whl + + create-release: + runs-on: ubuntu-latest + needs: build_wheels + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + steps: + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Download Artifacts + uses: actions/download-artifact@v3 + with: + name: wheels + + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: | + wheels/* + + + upload_all: + runs-on: ubuntu-latest + needs: build_wheels + environment: pypi + permissions: + id-token: write + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + steps: + - uses: actions/download-artifact@v3 + with: + name: wheels + path: dist + + - uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml deleted file mode 100644 index ba74de9..0000000 --- a/.github/workflows/wheels.yml +++ /dev/null @@ -1,68 +0,0 @@ -name: Build - -on: [push, pull_request] - -jobs: - build_wheels: - name: Build wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - - steps: - - uses: actions/checkout@v4 - - # Used to host cibuildwheel - - uses: actions/setup-python@v3 - - - name: Install cibuildwheel - run: python -m pip install cibuildwheel==2.16.2 - - - name: Build wheels - run: python -m cibuildwheel --output-dir wheelhouse - # to supply options, put them in 'env', like: - # env: - # CIBW_SOME_OPTION: value - - - uses: actions/upload-artifact@v3 - with: - name: wheels - path: ./wheelhouse/*.whl - - - create-release: - runs-on: ubuntu-latest - needs: build_wheels - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') - steps: - - - name: Checkout code - uses: actions/checkout@v2 - - - name: Download Artifacts - uses: actions/download-artifact@v3 - with: - name: wheels - - - name: Release - uses: softprops/action-gh-release@v1 - with: - files: | - wheels/* - - - upload_all: - runs-on: ubuntu-latest - needs: build_wheels - environment: pypi - permissions: - id-token: write - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') - steps: - - uses: actions/download-artifact@v3 - with: - name: wheels - path: dist - - - uses: pypa/gh-action-pypi-publish@release/v1