mirror of
https://github.com/google/benchmark.git
synced 2024-12-29 14:00:16 +08:00
9a0422eb23
The reason for this is that `setuptools-scm` installs a version relative to the last release tag - if no tag is found, the default version is taken to be v0.1.0. This was the case in GitHub Actions, where only the PR branch is checked out. Also unpins build system requirements in the `pyproject.toml`. The sdist build system was changed to `build` from `python setup.py sdist` for forward compatibility - `build` is superior in every way, and the advertised solution by both cibuildwheel and PyPA itself. Bump `actions/setup-python` to v5, `pypa/gh-action-pypi-publish` to v1.8.11, and `docker/setup-qemu-action` to v3.
79 lines
2.1 KiB
YAML
79 lines
2.1 KiB
YAML
name: Build and upload Python wheels
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
release:
|
|
types:
|
|
- published
|
|
|
|
jobs:
|
|
build_sdist:
|
|
name: Build source distribution
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out repo
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Install Python 3.11
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: 3.11
|
|
- run: python -m pip install build
|
|
- name: Build sdist
|
|
run: python -m build --sdist
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: dist
|
|
path: dist/*.tar.gz
|
|
|
|
build_wheels:
|
|
name: Build Google Benchmark wheels on ${{ matrix.os }}
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
|
|
steps:
|
|
- name: Check out Google Benchmark
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up QEMU
|
|
if: runner.os == 'Linux'
|
|
uses: docker/setup-qemu-action@v3
|
|
with:
|
|
platforms: all
|
|
|
|
- name: Build wheels on ${{ matrix.os }} using cibuildwheel
|
|
uses: pypa/cibuildwheel@v2.16.2
|
|
env:
|
|
CIBW_BUILD: 'cp38-* cp39-* cp310-* cp311-* cp312-*'
|
|
CIBW_SKIP: "*-musllinux_*"
|
|
CIBW_TEST_SKIP: "*-macosx_arm64"
|
|
CIBW_ARCHS_LINUX: x86_64 aarch64
|
|
CIBW_ARCHS_MACOS: x86_64 arm64
|
|
CIBW_ARCHS_WINDOWS: AMD64
|
|
CIBW_BEFORE_ALL_LINUX: bash .github/install_bazel.sh
|
|
CIBW_TEST_COMMAND: python {project}/bindings/python/google_benchmark/example.py
|
|
|
|
- name: Upload Google Benchmark ${{ matrix.os }} wheels
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: dist
|
|
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@v3
|
|
with:
|
|
name: dist
|
|
path: dist
|
|
- uses: pypa/gh-action-pypi-publish@v1.8.11
|