|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + |
| 11 | +jobs: |
| 12 | + build_wheels: |
| 13 | + name: Build wheels on ${{ matrix.os }} |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 18 | + |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + |
| 22 | + # Host Rust installation (for Windows/macOS) |
| 23 | + - name: Install Rust |
| 24 | + if: runner.os != 'Linux' |
| 25 | + run: | |
| 26 | + rustup update stable |
| 27 | +
|
| 28 | + - name: Build wheels |
| 29 | + uses: pypa/cibuildwheel@v2.16.5 |
| 30 | + env: |
| 31 | + # Only build for Python 3.10+ as per pyproject.toml |
| 32 | + CIBW_BUILD: "cp310-* cp311-* cp312-* cp313-*" |
| 33 | + |
| 34 | + # Target platforms |
| 35 | + CIBW_ARCHS_LINUX: x86_64 |
| 36 | + CIBW_ARCHS_MACOS: x86_64 arm64 |
| 37 | + CIBW_ARCHS_WINDOWS: AMD64 |
| 38 | + |
| 39 | + # Linux: Install Rust in the manylinux/musllinux container |
| 40 | + CIBW_BEFORE_ALL_LINUX: "curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable --profile minimal" |
| 41 | + CIBW_ENVIRONMENT_LINUX: 'PATH="$PATH:$HOME/.cargo/bin"' |
| 42 | + |
| 43 | + # Build backend verification |
| 44 | + CIBW_BUILD_FRONTEND: build |
| 45 | + |
| 46 | + - uses: actions/upload-artifact@v4 |
| 47 | + with: |
| 48 | + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} |
| 49 | + path: ./wheelhouse/*.whl |
| 50 | + |
| 51 | + build_sdist: |
| 52 | + name: Build source distribution |
| 53 | + runs-on: ubuntu-latest |
| 54 | + steps: |
| 55 | + - uses: actions/checkout@v4 |
| 56 | + |
| 57 | + - name: Build sdist |
| 58 | + run: pipx run build --sdist |
| 59 | + |
| 60 | + - uses: actions/upload-artifact@v4 |
| 61 | + with: |
| 62 | + name: cibw-sdist |
| 63 | + path: dist/*.tar.gz |
| 64 | + |
| 65 | + publish_to_pypi: |
| 66 | + needs: [build_wheels, build_sdist] |
| 67 | + runs-on: ubuntu-latest |
| 68 | + environment: |
| 69 | + name: pypi |
| 70 | + url: https://pypi.org/p/binary-semantic-cache |
| 71 | + permissions: |
| 72 | + id-token: write # IMPORTANT: Mandatory for trusted publishing |
| 73 | + steps: |
| 74 | + - uses: actions/download-artifact@v4 |
| 75 | + with: |
| 76 | + pattern: cibw-* |
| 77 | + path: dist |
| 78 | + merge-multiple: true |
| 79 | + |
| 80 | + - name: Publish to PyPI |
| 81 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 82 | + |
0 commit comments