aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/wheels.yml
blob: 1f73bff4b2c73a91e5f00a11462be86209ad9047 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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@v3

      - name: Install Python 3.11
        uses: actions/setup-python@v4
        with:
          python-version: 3.11

      - name: Build and check sdist
        run: |
          python setup.py sdist
      - name: Upload 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-2019]

    steps:
      - name: Check out Google Benchmark
        uses: actions/checkout@v3

      - name: Set up QEMU
        if: runner.os == 'Linux'
        uses: docker/setup-qemu-action@v2
        with:
          platforms: all

      - name: Build wheels on ${{ matrix.os }} using cibuildwheel
        uses: pypa/cibuildwheel@v2.14.1
        env:
          CIBW_BUILD: 'cp38-* cp39-* cp310-* cp311-*'
          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
    steps:
    - uses: actions/download-artifact@v3
      with:
        name: dist
        path: dist

    - uses: pypa/gh-action-pypi-publish@v1.6.4
      with:
        user: __token__
        password: ${{ secrets.PYPI_PASSWORD }}