Skip to content

Commit 5eeaa9f

Browse files
committed
ci: refactor wheels workflow to use matrix strategy for builds
- Consolidated multiple build jobs into a single job using a matrix strategy for different platforms (Windows, macOS, Ubuntu). - Added triggers for pushes to the master branch and version tags. - Updated publish step to depend on the new consolidated build job.
1 parent 3e401ad commit 5eeaa9f

1 file changed

Lines changed: 41 additions & 74 deletions

File tree

.github/workflows/wheels.yml

Lines changed: 41 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ name: Build and publish wheels
22

33
on:
44
push:
5+
branches:
6+
- "master"
7+
tags:
8+
- "v*"
59
workflow_dispatch:
6-
release:
7-
types: [published]
810

911
concurrency:
1012
group: ${{ github.workflow }}-${{ github.ref }}
@@ -35,82 +37,46 @@ jobs:
3537
name: sdist
3638
path: dist/*.tar.gz
3739

38-
build_wheels_windows:
39-
name: Build wheels on windows-latest
40-
runs-on: windows-latest
41-
needs: [build_sdist]
42-
43-
steps:
44-
- uses: actions/checkout@v6
45-
with:
46-
submodules: recursive
47-
48-
- name: Build wheels
49-
uses: pypa/cibuildwheel@v3.4.0
50-
env:
51-
CIBW_TEST_SKIP: "*"
52-
CIBW_ARCHS_WINDOWS: "AMD64 x86"
53-
54-
- uses: actions/upload-artifact@v7
55-
with:
56-
name: windows
57-
path: ./wheelhouse/*.whl
58-
retention-days: 1
59-
60-
build_wheels_windows_arm64:
61-
name: Build wheels on windows-11-arm
62-
runs-on: windows-11-arm
63-
needs: [build_sdist]
64-
65-
steps:
66-
- uses: actions/checkout@v4
67-
with:
68-
submodules: recursive
69-
70-
- name: Build wheels
71-
uses: pypa/cibuildwheel@v3.4.0
72-
env:
73-
CIBW_TEST_SKIP: "*"
74-
CIBW_ARCHS_WINDOWS: "ARM64"
75-
76-
- uses: actions/upload-artifact@v4
77-
with:
78-
name: windows-arm64
79-
path: ./wheelhouse/*.whl
80-
retention-days: 1
81-
82-
build_wheels_macos:
83-
name: Build wheels on macos-latest
84-
runs-on: macos-latest
85-
needs: [build_sdist]
86-
87-
steps:
88-
- uses: actions/checkout@v4
89-
with:
90-
submodules: recursive
91-
92-
- name: Build wheels
93-
uses: pypa/cibuildwheel@v3.4.0
94-
env:
95-
CIBW_TEST_SKIP: "*"
96-
97-
- uses: actions/upload-artifact@v4
98-
with:
99-
name: macos-latest
100-
path: ./wheelhouse/*.whl
101-
retention-days: 1
102-
103-
build_manylinux_wheels_ubuntu:
104-
name: Build manylinux wheels on ubuntu-latest
105-
runs-on: ubuntu-latest
40+
build_wheels:
41+
name: Build wheels on ${{ matrix.name }}
42+
runs-on: ${{ matrix.runs_on }}
10643
needs: [build_sdist]
44+
strategy:
45+
fail-fast: true
46+
matrix:
47+
include:
48+
- name: windows-latest
49+
runs_on: windows-latest
50+
artifact_name: windows
51+
cibw_archs_windows: "AMD64 x86"
52+
cibw_skip: ""
53+
setup_qemu: false
54+
- name: windows-11-arm
55+
runs_on: windows-11-arm
56+
artifact_name: windows-arm64
57+
cibw_archs_windows: "ARM64"
58+
cibw_skip: ""
59+
setup_qemu: false
60+
- name: macos-latest
61+
runs_on: macos-latest
62+
artifact_name: macos-latest
63+
cibw_archs_windows: ""
64+
cibw_skip: ""
65+
setup_qemu: false
66+
- name: ubuntu-latest
67+
runs_on: ubuntu-latest
68+
artifact_name: manylinux
69+
cibw_archs_windows: ""
70+
cibw_skip: "*-musllinux*"
71+
setup_qemu: true
10772

10873
steps:
10974
- uses: actions/checkout@v6
11075
with:
11176
submodules: recursive
11277

11378
- name: Set up QEMU
79+
if: ${{ matrix.setup_qemu }}
11480
uses: docker/setup-qemu-action@v4
11581
with:
11682
platforms: all
@@ -119,19 +85,20 @@ jobs:
11985
uses: pypa/cibuildwheel@v3.4.0
12086
env:
12187
CIBW_TEST_SKIP: "*"
122-
CIBW_SKIP: "*-musllinux*"
88+
CIBW_ARCHS_WINDOWS: ${{ matrix.cibw_archs_windows }}
89+
CIBW_SKIP: ${{ matrix.cibw_skip }}
12390

12491
- uses: actions/upload-artifact@v7
12592
with:
126-
name: manylinux
93+
name: ${{ matrix.artifact_name }}
12794
path: ./wheelhouse/*.whl
12895
retention-days: 1
12996

13097
publish:
131-
if: github.event_name == 'release'
13298
name: Publish to PyPI
133-
needs: [build_sdist, build_wheels_windows, build_wheels_windows_arm64, build_wheels_macos, build_manylinux_wheels_ubuntu]
13499
runs-on: ubuntu-latest
100+
needs: [build_sdist, build_wheels]
101+
if: ${{ success() && startsWith(github.ref, 'refs/tags/v') }}
135102
permissions:
136103
id-token: write
137104

0 commit comments

Comments
 (0)