Skip to content

Commit e3415c7

Browse files
committed
add a single place to control python versions
1 parent 581518f commit e3415c7

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

.github/workflows/build.yml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
release:
1212
types: [ published ]
1313

14+
env:
15+
PYTHON_VERSIONS: "3.10,3.11,3.12,3.13,3.14"
16+
1417
concurrency:
1518
cancel-in-progress: false
1619
# This creates different concurrency groups depending on the trigger
@@ -25,13 +28,30 @@ defaults:
2528
shell: bash
2629

2730
jobs:
31+
setup:
32+
runs-on: ubuntu-latest
33+
outputs:
34+
python-versions: ${{ steps.set-matrix.outputs.python-versions }}
35+
cibw-build: ${{ steps.set-matrix.outputs.cibw-build }}
36+
steps:
37+
- id: set-matrix
38+
run: |
39+
# Convert "3.10,3.11,3.12" to ["3.10","3.11","3.12"]
40+
python_array=$(echo '["${{ env.PYTHON_VERSIONS }}"]' | sed 's/,/","/g')
41+
echo "python-versions=$python_array" >> $GITHUB_OUTPUT
42+
43+
# Convert "3.10,3.11,3.12" to "cp310-* cp311-* cp312-*"
44+
cibw=$(echo "${{ env.PYTHON_VERSIONS }}" | sed 's/\.//g; s/,/ /g; s/\([0-9]*\)/cp\1-*/g')
45+
echo "cibw-build=$cibw" >> $GITHUB_OUTPUT
46+
2847
build_wheels_windows:
2948
name: Build wheels on Windows
49+
needs: setup
3050
runs-on: windows-latest
3151
strategy:
3252
fail-fast: False
3353
matrix:
34-
python-version: [ '3.10', '3.11', '3.12', '3.13', '3.14' ]
54+
python-version: ${{ fromJSON(needs.setup.outputs.python-versions) }}
3555
steps:
3656
- name: Checkout repository
3757
uses: actions/checkout@v4
@@ -57,6 +77,7 @@ jobs:
5777

5878
build_wheels_unix:
5979
name: Build wheels on ${{ matrix.os }}
80+
needs: setup
6081
runs-on: ${{ matrix.os }}
6182
strategy:
6283
fail-fast: False
@@ -75,8 +96,8 @@ jobs:
7596

7697
- name: Build wheels
7798
env:
78-
# only build CPython-3.9+ and skip 32-bit builds
79-
CIBW_BUILD: cp39-* cp310-* cp311-* cp312-* cp313-*
99+
# only build CPython-3.10+ and skip 32-bit builds
100+
CIBW_BUILD: ${{ needs.setup.outputs.cibw-build }}
80101
CIBW_SKIP: "*-manylinux_i686 *-musllinux*"
81102
# use latest build
82103
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux2014_x86_64
@@ -95,12 +116,12 @@ jobs:
95116

96117
test-wheels:
97118
name: Test wheels
98-
needs: [ build_wheels_windows, build_wheels_unix ]
119+
needs: [ setup, build_wheels_windows, build_wheels_unix ]
99120
runs-on: ${{ matrix.os }}
100121
strategy:
101122
matrix:
102123
os: [ windows-latest, ubuntu-latest, macos-latest, macos-14 ]
103-
python-version: [ '3.10', '3.11', '3.12', '3.13', '3.14' ]
124+
python-version: ${{ fromJSON(needs.setup.outputs.python-versions) }}
104125

105126
steps:
106127
- name: Checkout repository

0 commit comments

Comments
 (0)