diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index f0821dd..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Build wheels - -on: - push: - branches: - - main - workflow_dispatch: - -jobs: - build_wheels: - name: Build wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - ubuntu-24.04 - - windows-2022 - - macos-14 - - env: - CIBW_ARCHS_LINUX: x86_64 i686 aarch64 - CIBW_ARCHS_MACOS: x86_64 universal2 - CIBW_ARCHS_WINDOWS: AMD64 x86 ARM64 - CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-*" - - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - - name: Install cibuildwheel - run: | - python -m pip install cibuildwheel==2.20.0 - - - name: Set up QEMU - if: runner.os == 'Linux' - uses: docker/setup-qemu-action@v3 - with: - platforms: all - - - name: Build wheels - run: | - python -m cibuildwheel --output-dir wheelhouse - - - uses: actions/upload-artifact@v4 - with: - name: wheels-${{ matrix.os }} - path: '${{ github.workspace }}/wheelhouse/*.whl' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a688323..de7c115 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,6 +4,8 @@ on: push: branches: - main + tags: + - '**' pull_request: concurrency: @@ -90,3 +92,72 @@ jobs: with: name: html-report path: htmlcov + + build: + name: Build wheels on ${{ matrix.os }} + if: > + startsWith(github.ref, 'refs/tags/') || + github.ref == 'refs/heads/main' || + contains(github.event.pull_request.labels.*.name, 'Build') + + strategy: + matrix: + os: + - linux + - macos + - windows + + runs-on: ${{ (matrix.os == 'linux' && 'ubuntu-24.04') || (matrix.os == 'macos' && 'macos-14') || (matrix.os == 'windows' && 'windows-2022') || 'unknown' }} + + env: + CIBW_ARCHS_LINUX: x86_64 i686 aarch64 + CIBW_ARCHS_MACOS: x86_64 universal2 + CIBW_ARCHS_WINDOWS: AMD64 x86 ARM64 + CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-*" + + steps: + - uses: actions/checkout@v4 + + - uses: astral-sh/setup-uv@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + if: matrix.os == 'linux' + with: + platforms: all + + - name: Build sdist + if: ${{ matrix.os == 'linux' }} + run: uv build --sdist + + - name: Build wheels + run: uvx --from cibuildwheel==2.20.0 cibuildwheel --output-dir dist + + - run: ${{ (matrix.os == 'windows' && 'dir') || 'ls -lh' }} dist/ + + - uses: actions/upload-artifact@v4 + with: + name: dist-${{ matrix.os }} + path: dist + + release: + needs: [coverage, build] + if: success() && startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-24.04 + environment: release + + permissions: + contents: read + id-token: write + + steps: + - uses: actions/checkout@v4 + + - name: get dist artifacts + uses: actions/download-artifact@v4 + with: + merge-multiple: true + pattern: dist-* + path: dist + + - uses: pypa/gh-action-pypi-publish@release/v1