diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 640b505..f0bbfb1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -70,66 +70,169 @@ jobs: - name: Check matrix job result run: test "$DEPS_RESULT" = "success" - build: - name: Build distribution packages + build-linux: + runs-on: ${{ matrix.platform.runner }} strategy: - fail-fast: false matrix: - target: - - ubuntu-24.04 - - ubuntu-24.04-arm - - windows-latest - - macos-15-intel - - macos-15 - python: - - "3.11" - - "3.12" - - "3.13" - - "3.14" - runs-on: ${{ matrix.target }} + platform: + - runner: ubuntu-22.04 + target: x86_64 + - runner: ubuntu-22.04 + target: aarch64 steps: - - name: Setup Git - uses: frequenz-floss/gh-action-setup-git@v1.0.0 + - uses: actions/checkout@v5 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist --find-interpreter + sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} + manylinux: auto + - name: Upload wheels + uses: actions/upload-artifact@v5 + with: + name: wheels-linux-${{ matrix.platform.target }} + path: dist - - name: Fetch sources - uses: actions/checkout@v5 + build-musllinux: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: ubuntu-22.04 + target: x86_64 + - runner: ubuntu-22.04 + target: aarch64 + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-python@v5 with: - submodules: true + python-version: 3.x + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist --find-interpreter + sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} + manylinux: musllinux_1_2 + - name: Upload wheels + uses: actions/upload-artifact@v5 + with: + name: wheels-musllinux-${{ matrix.platform.target }} + path: dist - - name: Setup Python - uses: frequenz-floss/gh-action-setup-python-with-deps@v1.0.1 + build-windows: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: windows-latest + target: x64 + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python }} - dependencies: build + python-version: 3.x + architecture: ${{ matrix.platform.target }} + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist --find-interpreter + sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} + - name: Upload wheels + uses: actions/upload-artifact@v5 + with: + name: wheels-windows-${{ matrix.platform.target }} + path: dist - - name: Build the source and binary distribution - run: python -m build + build-macos: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: macos-15-intel + target: x86_64 + - runner: macos-15 + target: aarch64 + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist --find-interpreter + sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} + - name: Upload wheels + uses: actions/upload-artifact@v5 + with: + name: wheels-macos-${{ matrix.platform.target }} + path: dist - - name: Upload distribution files + build-sdist: + name: Build source distribution packages + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v5 + - name: Build sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --out dist + - name: Upload sdist uses: actions/upload-artifact@v5 with: - name: dist-packages-${{ matrix.target }}-${{ matrix.python }} - path: dist/ - if-no-files-found: error + name: wheels-sdist + path: dist/*.tar.gz test-installation: name: Test package installation - needs: ["build"] + needs: + - "build-linux" + - "build-musllinux" + - "build-windows" + - "build-macos" + - "build-sdist" strategy: fail-fast: false matrix: - target: - - ubuntu-24.04 - - ubuntu-24.04-arm - - windows-latest - - macos-15-intel - - macos-15 + platform: + - runner: ubuntu-24.04 + image: linux + tag: manylinux + target: x86_64 + - runner: ubuntu-24.04-arm + image: linux + tag: manylinux + target: aarch64 + - runner: windows-latest + image: windows + tag: win + target: x64 + - runner: macos-15-intel + image: macos + tag: macosx + target: x86_64 + - runner: macos-15 + image: macos + tag: macosx + target: aarch64 python: - - "3.11" - - "3.12" - - "3.13" - - "3.14" - runs-on: ${{ matrix.target }} + - semver: "3.11" + wheelver: cp311 + - semver: "3.12" + wheelver: cp312 + - semver: "3.13" + wheelver: cp313 + - semver: "3.14" + wheelver: cp314 + runs-on: ${{ matrix.platform.runner }} steps: - name: Setup Git @@ -141,7 +244,7 @@ jobs: - name: Download package uses: actions/download-artifact@v6 with: - name: dist-packages-${{ matrix.target }}-${{ matrix.python }} + name: wheels-${{ matrix.platform.image }}-${{ matrix.platform.target }} path: dist # This is necessary for the `pip` caching in the setup-python action to work @@ -162,8 +265,8 @@ jobs: - name: Setup Python uses: frequenz-floss/gh-action-setup-python-with-deps@v1.0.1 with: - python-version: ${{ matrix.python }} - dependencies: dist/*.whl + python-version: ${{ matrix.python.semver }} + dependencies: dist/*${{ matrix.python.wheelver }}-${{ matrix.platform.tag }}*.whl - name: Print installed packages (debug) run: python -m pip freeze @@ -325,7 +428,7 @@ jobs: --generate-notes \ $extra_opts \ $REF_NAME \ - dist/dist-packages-*/* + dist/wheels-*/*.whl dist/wheels-sdist/*.tar.gz env: REF_NAME: ${{ github.ref_name }} REPOSITORY: ${{ github.repository }} @@ -344,6 +447,7 @@ jobs: uses: actions/download-artifact@v6 with: path: dist + merge-multiple: true - name: Publish the Python distribution to PyPI uses: pypa/gh-action-pypi-publish@release/v1