aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/wheels.yml
blob: 83c5bbf81e5ef6f4c868e3f71866244d998f7134 (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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.12
        uses: actions/setup-python@v5
        with:
          python-version: 3.12
      - run: python -m pip install build
      - name: Build sdist
        run: python -m build --sdist
      - uses: actions/upload-artifact@v4
        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, macos-13, macos-14, 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 3.8 wheels on ${{ matrix.os }} using cibuildwheel
        uses: pypa/cibuildwheel@v2.20
        env:
          CIBW_BUILD: "cp38-*"
          CIBW_SKIP: "*-musllinux_*"
          CIBW_TEST_SKIP: "cp38-macosx_*:arm64"
          CIBW_ARCHS_LINUX: auto64 aarch64
          CIBW_ARCHS_WINDOWS: 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

      - name: Build 3.9 wheels on ${{ matrix.os }} using cibuildwheel
        uses: pypa/cibuildwheel@v2.20
        env:
          CIBW_BUILD: "cp39-*"
          CIBW_SKIP: "*-musllinux_*"
          CIBW_TEST_SKIP: "cp38-macosx_*:arm64"
          CIBW_ARCHS_LINUX: auto64 aarch64
          CIBW_ARCHS_WINDOWS: 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

      - name: Build 3.10 wheels on ${{ matrix.os }} using cibuildwheel
        uses: pypa/cibuildwheel@v2.20
        env:
          CIBW_BUILD: "cp310-*"
          CIBW_SKIP: "*-musllinux_*"
          CIBW_TEST_SKIP: "cp38-macosx_*:arm64"
          CIBW_ARCHS_LINUX: auto64 aarch64
          CIBW_ARCHS_WINDOWS: 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

      - name: Build 3.11 wheels on ${{ matrix.os }} using cibuildwheel
        uses: pypa/cibuildwheel@v2.20
        env:
          CIBW_BUILD: "cp311-*"
          CIBW_SKIP: "*-musllinux_*"
          CIBW_TEST_SKIP: "cp38-macosx_*:arm64"
          CIBW_ARCHS_LINUX: auto64 aarch64
          CIBW_ARCHS_WINDOWS: 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

      - name: Build 3.12 wheels on ${{ matrix.os }} using cibuildwheel
        uses: pypa/cibuildwheel@v2.20
        env:
          CIBW_BUILD: "cp312-*"
          CIBW_SKIP: "*-musllinux_*"
          CIBW_TEST_SKIP: "cp38-macosx_*:arm64"
          CIBW_ARCHS_LINUX: auto64 aarch64
          CIBW_ARCHS_WINDOWS: 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

      - name: Upload Google Benchmark ${{ matrix.os }} wheels
        uses: actions/upload-artifact@v4
        with:
          name: dist-${{ matrix.os }}
          path: wheelhouse/*.whl

  merge_wheels:
    name: Merge all built wheels into one artifact
    runs-on: ubuntu-latest
    needs: build_wheels
    steps:
      - name: Merge wheels
        uses: actions/upload-artifact/merge@v4
        with:
          name: dist
          pattern: dist-*
          delete-merged: true

  pypi_upload:
    name: Publish google-benchmark wheels to PyPI
    needs: [merge_wheels]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v4
        with:
          path: dist
      - uses: pypa/gh-action-pypi-publish@release/v1
        with:
          user: __token__
          password: ${{ secrets.PYPI_PASSWORD }}