From 5e6f2b7f53c8a53a23852cc0ac2c843a35d0b14f Mon Sep 17 00:00:00 2001 From: Elvis Pranskevichus Date: Mon, 14 Aug 2023 15:53:53 -0700 Subject: [PATCH] Modernize the release workflow Copy the approach from `asyncpg` to make the build matrix more granular --- .github/workflows/release.yml | 69 ++++++++++++++++++++--------------- pyproject.toml | 14 +++++++ 2 files changed, 53 insertions(+), 30 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5d05ff07..0c83ffe6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,33 +59,48 @@ jobs: python -m pip install -U setuptools wheel pip python setup.py sdist - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: dist path: dist/*.tar.* - build-wheels: + build-wheels-matrix: needs: validate-release-request + runs-on: ubuntu-latest + outputs: + include: ${{ steps.set-matrix.outputs.include }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.x" + - run: pip install cibuildwheel==2.15.0 + - id: set-matrix + run: | + MATRIX_INCLUDE=$( + { + cibuildwheel --print-build-identifiers --platform linux --arch x86_64,aarch64 | grep cp | jq -nRc '{"only": inputs, "os": "ubuntu-latest"}' \ + && cibuildwheel --print-build-identifiers --platform macos --arch x86_64,arm64 | grep cp | jq -nRc '{"only": inputs, "os": "macos-latest"}' \ + && cibuildwheel --print-build-identifiers --platform windows --arch x86,AMD64 | grep cp | jq -nRc '{"only": inputs, "os": "windows-latest"}' + } | jq -sc + ) + echo "include=$MATRIX_INCLUDE" >> $GITHUB_OUTPUT + + build-wheels: + needs: build-wheels-matrix runs-on: ${{ matrix.os }} + name: Build ${{ matrix.only }} + strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - cibw_arch: ["auto64", "aarch64", "universal2"] - cibw_python: - - "cp38-*" - - "cp39-*" - - "cp310-*" - - "cp311-*" - - "cp312-*" - exclude: - - os: ubuntu-latest - cibw_arch: universal2 - - os: macos-latest - cibw_arch: aarch64 - - os: windows-latest - cibw_arch: universal2 - - os: windows-latest - cibw_arch: aarch64 + include: ${{ fromJson(needs.build-wheels-matrix.outputs.include) }} + + defaults: + run: + shell: bash + + env: + PIP_DISABLE_PIP_VERSION_CHECK: 1 steps: - uses: actions/checkout@v3 @@ -94,23 +109,17 @@ jobs: submodules: true - name: Set up QEMU - if: matrix.os == 'ubuntu-latest' && matrix.cibw_arch == 'aarch64' + if: runner.os == 'Linux' uses: docker/setup-qemu-action@v2 - with: - platforms: arm64 - - uses: pypa/cibuildwheel@v2.9.0 + - uses: pypa/cibuildwheel@39a63b5912f086dd459cf6fcb13dcdd3fe3bc24d # v2.15.0 + with: + only: ${{ matrix.only }} env: CIBW_BUILD_VERBOSITY: 1 - CIBW_BUILD: ${{ matrix.cibw_python }} - CIBW_ARCHS: ${{ matrix.cibw_arch }} - CIBW_TEST_EXTRAS: "test" - CIBW_TEST_COMMAND: "cd .. && python {project}/tests/__init__.py" - CIBW_TEST_COMMAND_WINDOWS: "cd .. && python {project}\\tests\\__init__.py" - CIBW_TEST_SKIP: "*universal2:arm64" CIBW_ENVIRONMENT: "IMMU_SKIP_MYPY_TESTS=1" - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: dist path: wheelhouse/*.whl diff --git a/pyproject.toml b/pyproject.toml index a2f803b9..20126523 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,7 @@ name = "immutables" description = "Immutable Collections" authors = [{name = "MagicStack Inc", email = "hello@magic.io"}] +requires-python = '>=3.8.0' readme = "README.rst" license = {text = "Apache License, Version 2.0"} dynamic = ["version"] @@ -78,3 +79,16 @@ ignore_errors = true [[tool.mypy.overrides]] module = "immutables._testutils" ignore_errors = true + +[tool.cibuildwheel] +build-frontend = "build" +test-extras = "test" + +[tool.cibuildwheel.macos] +test-command = "python {project}/tests/__init__.py" + +[tool.cibuildwheel.windows] +test-command = "python {project}\\tests\\__init__.py" + +[tool.cibuildwheel.linux] +test-command = "python {project}/tests/__init__.py"