| name: Build and upload Python wheels |
| |
| on: |
| workflow_dispatch: |
| release: |
| types: |
| - published |
| |
| env: |
| CMAKE_GENERATOR: Ninja |
| |
| jobs: |
| build_sdist: |
| name: Build source distribution |
| runs-on: ubuntu-latest |
| steps: |
| - name: Check out repo |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| with: |
| fetch-depth: 0 |
| - name: Install Python 3.12 |
| uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 |
| with: |
| python-version: "3.12" |
| - run: python -m pip install build |
| - name: Build sdist |
| run: python -m build --sdist |
| - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| with: |
| name: dist-sdist |
| path: dist/*.tar.gz |
| |
| build_wheels: |
| name: Build Google Benchmark wheels on ${{ matrix.os }} |
| runs-on: ${{ matrix.os }} |
| strategy: |
| matrix: |
| os: [ubuntu-latest, ubuntu-24.04-arm, macos-13, macos-14, windows-latest] |
| steps: |
| - name: Check out Google Benchmark |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| with: |
| fetch-depth: 0 |
| |
| - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 |
| name: Install Python 3.12 |
| with: |
| python-version: "3.12" |
| - name: Install the latest version of uv |
| uses: astral-sh/setup-uv@d9e0f98d3fc6adb07d1e3d37f3043649ddad06a1 # v6.5.0 |
| |
| - name: Build wheels on ${{ matrix.os }} using cibuildwheel |
| uses: pypa/cibuildwheel@c923d83ad9c1bc00211c5041d0c3f73294ff88f6 # v3.1.4 |
| env: |
| CIBW_BUILD: "cp310-* cp311-* cp312-*" |
| CIBW_BUILD_FRONTEND: "build[uv]" |
| CIBW_SKIP: "*-musllinux_*" |
| CIBW_ARCHS: auto64 |
| CIBW_BEFORE_ALL_LINUX: bash .github/install_bazel.sh |
| # Grab the rootless Bazel installation inside the container. |
| CIBW_ENVIRONMENT_LINUX: PATH=$PATH:$HOME/bin |
| CIBW_TEST_COMMAND: python {project}/bindings/python/google_benchmark/example.py |
| # unused by Bazel, but needed explicitly by delocate on MacOS. |
| MACOSX_DEPLOYMENT_TARGET: ${{ matrix.os == 'macos-13' && 10.14 || 11.0 }} |
| |
| - name: Upload Google Benchmark ${{ matrix.os }} wheels |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| with: |
| name: dist-${{ matrix.os }} |
| path: wheelhouse/*.whl |
| |
| pypi_upload: |
| name: Publish google-benchmark wheels to PyPI |
| needs: [build_sdist, build_wheels] |
| runs-on: ubuntu-latest |
| permissions: |
| id-token: write |
| steps: |
| - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 |
| with: |
| path: dist |
| pattern: dist-* |
| merge-multiple: true |
| - uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # release/v1 |