Skip to content

Commit 5e6f2b7

Browse files
committed
Modernize the release workflow
Copy the approach from `asyncpg` to make the build matrix more granular
1 parent 2c4e7a6 commit 5e6f2b7

File tree

2 files changed

+53
-30
lines changed

2 files changed

+53
-30
lines changed

.github/workflows/release.yml

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -59,33 +59,48 @@ jobs:
5959
python -m pip install -U setuptools wheel pip
6060
python setup.py sdist
6161
62-
- uses: actions/upload-artifact@v2
62+
- uses: actions/upload-artifact@v3
6363
with:
6464
name: dist
6565
path: dist/*.tar.*
6666

67-
build-wheels:
67+
build-wheels-matrix:
6868
needs: validate-release-request
69+
runs-on: ubuntu-latest
70+
outputs:
71+
include: ${{ steps.set-matrix.outputs.include }}
72+
steps:
73+
- uses: actions/checkout@v3
74+
- uses: actions/setup-python@v4
75+
with:
76+
python-version: "3.x"
77+
- run: pip install cibuildwheel==2.15.0
78+
- id: set-matrix
79+
run: |
80+
MATRIX_INCLUDE=$(
81+
{
82+
cibuildwheel --print-build-identifiers --platform linux --arch x86_64,aarch64 | grep cp | jq -nRc '{"only": inputs, "os": "ubuntu-latest"}' \
83+
&& cibuildwheel --print-build-identifiers --platform macos --arch x86_64,arm64 | grep cp | jq -nRc '{"only": inputs, "os": "macos-latest"}' \
84+
&& cibuildwheel --print-build-identifiers --platform windows --arch x86,AMD64 | grep cp | jq -nRc '{"only": inputs, "os": "windows-latest"}'
85+
} | jq -sc
86+
)
87+
echo "include=$MATRIX_INCLUDE" >> $GITHUB_OUTPUT
88+
89+
build-wheels:
90+
needs: build-wheels-matrix
6991
runs-on: ${{ matrix.os }}
92+
name: Build ${{ matrix.only }}
93+
7094
strategy:
7195
matrix:
72-
os: [ubuntu-latest, macos-latest, windows-latest]
73-
cibw_arch: ["auto64", "aarch64", "universal2"]
74-
cibw_python:
75-
- "cp38-*"
76-
- "cp39-*"
77-
- "cp310-*"
78-
- "cp311-*"
79-
- "cp312-*"
80-
exclude:
81-
- os: ubuntu-latest
82-
cibw_arch: universal2
83-
- os: macos-latest
84-
cibw_arch: aarch64
85-
- os: windows-latest
86-
cibw_arch: universal2
87-
- os: windows-latest
88-
cibw_arch: aarch64
96+
include: ${{ fromJson(needs.build-wheels-matrix.outputs.include) }}
97+
98+
defaults:
99+
run:
100+
shell: bash
101+
102+
env:
103+
PIP_DISABLE_PIP_VERSION_CHECK: 1
89104

90105
steps:
91106
- uses: actions/checkout@v3
@@ -94,23 +109,17 @@ jobs:
94109
submodules: true
95110

96111
- name: Set up QEMU
97-
if: matrix.os == 'ubuntu-latest' && matrix.cibw_arch == 'aarch64'
112+
if: runner.os == 'Linux'
98113
uses: docker/setup-qemu-action@v2
99-
with:
100-
platforms: arm64
101114

102-
- uses: pypa/[email protected]
115+
- uses: pypa/cibuildwheel@39a63b5912f086dd459cf6fcb13dcdd3fe3bc24d # v2.15.0
116+
with:
117+
only: ${{ matrix.only }}
103118
env:
104119
CIBW_BUILD_VERBOSITY: 1
105-
CIBW_BUILD: ${{ matrix.cibw_python }}
106-
CIBW_ARCHS: ${{ matrix.cibw_arch }}
107-
CIBW_TEST_EXTRAS: "test"
108-
CIBW_TEST_COMMAND: "cd .. && python {project}/tests/__init__.py"
109-
CIBW_TEST_COMMAND_WINDOWS: "cd .. && python {project}\\tests\\__init__.py"
110-
CIBW_TEST_SKIP: "*universal2:arm64"
111120
CIBW_ENVIRONMENT: "IMMU_SKIP_MYPY_TESTS=1"
112121

113-
- uses: actions/upload-artifact@v2
122+
- uses: actions/upload-artifact@v3
114123
with:
115124
name: dist
116125
path: wheelhouse/*.whl

pyproject.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "immutables"
33
description = "Immutable Collections"
44
authors = [{name = "MagicStack Inc", email = "[email protected]"}]
5+
requires-python = '>=3.8.0'
56
readme = "README.rst"
67
license = {text = "Apache License, Version 2.0"}
78
dynamic = ["version"]
@@ -78,3 +79,16 @@ ignore_errors = true
7879
[[tool.mypy.overrides]]
7980
module = "immutables._testutils"
8081
ignore_errors = true
82+
83+
[tool.cibuildwheel]
84+
build-frontend = "build"
85+
test-extras = "test"
86+
87+
[tool.cibuildwheel.macos]
88+
test-command = "python {project}/tests/__init__.py"
89+
90+
[tool.cibuildwheel.windows]
91+
test-command = "python {project}\\tests\\__init__.py"
92+
93+
[tool.cibuildwheel.linux]
94+
test-command = "python {project}/tests/__init__.py"

0 commit comments

Comments
 (0)