| name: Build and upload Python wheels | |
| on: | |
| workflow_dispatch: | |
| release: | |
| types: | |
| - published | |
| env: | |
| CMAKE_GENERATOR: Ninja | |
| permissions: | |
| contents: read | |
| jobs: | |
| build_sdist: | |
| name: Build source distribution | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repo | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Install Python 3.12 | |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| with: | |
| python-version: "3.12" | |
| - run: python -m pip install build | |
| - name: Build sdist | |
| run: python -m build --sdist | |
| - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.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-15-intel, macos-latest, windows-latest] | |
| steps: | |
| - name: Check out Google Benchmark | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| name: Install Python 3.12 | |
| with: | |
| python-version: "3.12" | |
| - name: Install the latest version of uv | |
| uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0 | |
| with: | |
| enable-cache: false | |
| - name: Build wheels on ${{ matrix.os }} using cibuildwheel | |
| uses: pypa/cibuildwheel@b3395e271a35f73dad77f21802abe9b986dfe299 # v4.3.1 | |
| env: | |
| CIBW_ENABLE: "cpython-freethreading" | |
| CIBW_BUILD: "cp310-* cp314t-* cp315t-*" | |
| CIBW_BUILD_FRONTEND: "build[uv]" | |
| CIBW_SKIP: "cp313t-* *-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-15-intel' && 10.14 || 11.0 }} | |
| - name: Upload Google Benchmark ${{ matrix.os }} wheels | |
| uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.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@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 | |
| with: | |
| path: dist | |
| pattern: dist-* | |
| merge-multiple: true | |
| - uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1 |