forked from pietrodn/grpcio-mac-arm-build
-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (75 loc) · 3.14 KB
/
wheels.yml
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
name: Build
on:
push:
pull_request:
schedule:
- cron: '35 5 * * *'
jobs:
check_release:
name: "Check if we should start a new build job for grpcio based on latest release"
outputs:
should_build: ${{ steps.grpcio_version.outputs.should_build }}
latest_version: ${{ steps.grpcio_version.outputs.grpcio_current_version }}
runs-on: ubuntu-latest
steps:
- id: get_release
uses: pozetroninc/github-action-get-latest-release@master
with:
repository: ${{ github.repository }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Check latest available grpcio release
id: grpcio_version
run: |
GRPCIO_LATEST_VERSION=$(pip3 index versions --no-binary grpcio grpcio | grep grpcio | sed -E 's/grpcio \(([0-9.]+)\)/\1/')
echo "Latest grpcio version on PyPI: $GRPCIO_LATEST_VERSION"
echo "grpcio_current_version=$GRPCIO_LATEST_VERSION" >> $GITHUB_OUTPUT
GRPCIO_LATEST_RELEASE="${{ steps.get_release.outputs.release }}"
if [[ $GRPCIO_LATEST_RELEASE == $GRPCIO_LATEST_VERSION ]]; then
echo "We already have a release for $GRPCIO_LATEST_RELEASE. Skipping build."
echo "should_build=0" >> $GITHUB_OUTPUT
else
echo "Latest release $GRPCIO_LATEST_RELEASE is outdated, starting build for $GRPCIO_LATEST_VERSION"
echo "should_build=1" >> $GITHUB_OUTPUT
fi
build_wheels:
name: Build grpcio wheels on ${{ matrix.os }}, for Python ${{ matrix.python_build_version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ "macOS-12" ]
python_build_version: [ "cp38", "cp39", "cp310", "cp311" ]
needs: [check_release]
if: needs.check_release.outputs.should_build == '1'
steps:
# Used to host cibuildwheel
- uses: actions/setup-python@v3
- name: Download latest grpcio stable tarball
run: |
pip download --no-binary grpcio grpcio==${{ needs.check_release.outputs.latest_version }}
tar xf *.tar.gz
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.9.0
- name: Build wheels
run: |
cd grpcio-*/
python -m cibuildwheel --output-dir ../wheelhouse
env:
CIBW_ARCHS_MACOS: "arm64"
CIBW_TEST_SKIP: "*_arm64"
CIBW_BUILD: "${{ matrix.python_build_version }}-macosx_arm64"
CIBW_BUILD_FRONTEND: pip
CIBW_ENVIRONMENT_MACOS: "GRPC_PYTHON_BUILD_WITH_CYTHON=1"
CIBW_BEFORE_BUILD: "pip install -r requirements.txt"
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
- name: Release
uses: softprops/action-gh-release@v1
with:
name: "grpcio ${{ needs.check_release.outputs.latest_version }}"
tag_name: ${{ needs.check_release.outputs.latest_version }}
files: ./wheelhouse/*.whl
body: "Apple Silicon built binaries for the grpcio ${{ needs.check_release.outputs.latest_version }} Python library."