name: Build on: push: branches: - main tags: - '*' workflow_dispatch: permissions: contents: write id-token: write packages: write jobs: python-linux: runs-on: ${{ matrix.platform.runner }} strategy: matrix: platform: - runner: ubuntu-latest target: x86_64 - runner: ubuntu-24.04-arm target: aarch64 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: 3.x - run: docker build . -f .github/workflows/build.Dockerfile --tag ci - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} args: --release --out dist --find-interpreter sccache: 'true' manylinux: auto container: ci working-directory: ./crates/sbv2_bindings - name: Upload wheels uses: actions/upload-artifact@v4 with: name: wheels-linux-${{ matrix.platform.target }} path: ./crates/sbv2_bindings/dist python-windows: runs-on: ${{ matrix.platform.runner }} strategy: matrix: platform: - runner: windows-latest target: x64 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: 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: 'true' working-directory: ./crates/sbv2_bindings - name: Upload wheels uses: actions/upload-artifact@v4 with: name: wheels-windows-${{ matrix.platform.target }} path: ./crates/sbv2_bindings/dist python-macos: runs-on: ${{ matrix.platform.runner }} strategy: matrix: platform: - runner: macos-14 target: aarch64 steps: - uses: actions/checkout@v4 - 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: 'true' working-directory: ./crates/sbv2_bindings - name: Upload wheels uses: actions/upload-artifact@v4 with: name: wheels-macos-${{ matrix.platform.target }} path: ./crates/sbv2_bindings/dist python-sdist: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Build sdist uses: PyO3/maturin-action@v1 with: command: sdist args: --out dist working-directory: ./crates/sbv2_bindings - name: Upload sdist uses: actions/upload-artifact@v4 with: name: wheels-sdist path: ./crates/sbv2_bindings/dist python-wheel: name: Wheel Upload runs-on: ubuntu-latest needs: [python-linux, python-windows, python-macos, python-sdist] env: GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v4 - run: gh run download ${{ github.run_id }} -p wheels-* - name: release run: | gh release create commit-${GITHUB_SHA:0:8} --prerelease wheels-*/* python-release: name: Release runs-on: ubuntu-latest if: "startsWith(github.ref, 'refs/tags/')" needs: [python-linux, python-windows, python-macos, python-sdist] environment: release env: GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v4 - run: gh run download ${{ github.run_id }} -p wheels-* - name: Publish to PyPI uses: PyO3/maturin-action@v1 with: command: upload args: --non-interactive --skip-existing wheels-*/* docker: runs-on: ${{ matrix.machine.runner }} strategy: fail-fast: false matrix: machine: - platform: amd64 runner: ubuntu-latest - platform: arm64 runner: ubuntu-24.04-arm tag: [cpu, cuda] steps: - name: Prepare run: | platform=${{ matrix.machine.platform }} echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV - name: Docker meta id: meta uses: docker/metadata-action@v5 with: images: | ghcr.io/${{ github.repository }} - name: Login to GHCR uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build and push by digest id: build uses: docker/build-push-action@v6 with: labels: ${{ steps.meta.outputs.labels }} file: ./scripts/docker/${{ matrix.tag }}.Dockerfile push: true tags: | ghcr.io/${{ github.repository }}:latest-${{ matrix.tag }}-${{ matrix.machine.platform }} docker-merge: runs-on: ubuntu-latest needs: - docker steps: - name: Download digests uses: actions/download-artifact@v4 with: path: ${{ runner.temp }}/digests pattern: digests-* merge-multiple: true - name: Login to GHCR uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Merge run: | docker buildx imagetools create -t ghcr.io/${{ github.repository }}:cuda \ ghcr.io/${{ github.repository }}:latest-cuda-amd64 \ ghcr.io/${{ github.repository }}:latest-cuda-arm64 docker buildx imagetools create -t ghcr.io/${{ github.repository }}:cpu \ ghcr.io/${{ github.repository }}:latest-cpu-amd64 \ ghcr.io/${{ github.repository }}:latest-cpu-arm64