generated from aarnphm/bazix
-
Notifications
You must be signed in to change notification settings - Fork 64
158 lines (158 loc) · 5.38 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
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: wheels
on:
workflow_dispatch:
push:
tags:
- 'v*'
pull_request:
branches:
- main
concurrency:
group: wheels-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
LINES: 200
COLUMNS: 200
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrun
defaults:
run:
shell: bash --noprofile --norc -exo pipefail {0}
jobs:
build-sdist:
name: Build source distribution
runs-on: ubuntu-latest
timeout-minutes: 120
if: github.repository_owner == 'aarnphm' # Don't run on fork repository
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch all tags and branches
submodules: true
- name: Setup CI
uses: ./.github/actions/setup-repo
with:
python-version: '3.8'
- name: Build source distributions
run: |
# TODO: when bazel support releasing sdist, we can remove this.
pipx run build --sdist
- name: Test built sdist
run: |
python -m venv venv
source venv/bin/activate
pip install dist/*.tar.gz && python -c "import whispercpp as w;print(dir(w.api)); print(dir(w.audio));"
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
build-arm-musl-wheels:
name: Build wheels for ${{ matrix.python[1] }}-${{ startsWith(matrix.platform[0], 'macosx') && 'macosx' || matrix.platform[0] }}
runs-on: ${{ matrix.platform[1] }}
if: ${{ failure() }} # Don't run on fork repository
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
python:
- ['cp38', '3.8']
- ['cp39', '3.9']
- ['cp310', '3.10']
- ['cp311', '3.11']
platform:
- [manylinux_aarch64, ubuntu-latest]
- [musllinux_x86_64, ubuntu-latest]
- ['macosx_*', macos-latest]
exclude:
# TODO: disable manylinux_aarch64 for now
- platform: [manylinux_aarch64, ubuntu-latest]
- platform: [musllinux_x86_64, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch all tags and branches
- name: Setup CI
uses: ./.github/actions/setup-repo
with:
python-version: ${{ matrix.python[1] }}
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Build wheels
uses: pypa/cibuildwheel@v2.16.1
env:
CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.platform[0] }}
CIBW_ARCHS_MACOS: x86_64 arm64
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.python[0] }}-${{ startsWith(matrix.platform[0], 'macosx') && 'macosx' || matrix.platform[0] }}
path: ./wheelhouse/*.whl
release-wheels-sdist:
needs: [build-sdist]
runs-on: ubuntu-latest
if: github.repository_owner == 'aarnphm'
steps:
- uses: actions/download-artifact@v3
- name: Sanity check and setup dist folder
run: |
ls -R
mkdir -p dist
cp -r artifact/* dist/
# MacOS wheels
cp -r cp310-macosx/*.whl dist/
cp -r cp311-macosx/*.whl dist/
cp -r cp38-macosx/*.whl dist/
cp -r cp39-macosx/*.whl dist/
- uses: pypa/gh-action-pypi-publish@v1.8.10
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
bazel-build-and-release-wheels:
name: Build wheels for python${{ matrix.python-version }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 120
if: github.repository_owner == 'aarnphm' # Don't run on fork repository
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
python-version: ['3.8', '3.9', '3.10', '3.11']
exclude:
- os: 'windows-latest'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch all tags and branches
- name: Setup CI
uses: ./.github/actions/setup-repo
with:
python-version: ${{ matrix.python-version }}
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Building wheels
run: bazel build whispercpp_wheel
- name: Test built wheel
run: |
python -m venv venv
source venv/bin/activate
pip install $(bazel info bazel-bin)/*.whl && python -c "import whispercpp as w;print(dir(w.api)); print(dir(w.audio));"
- name: Retrieving versions
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
id: get-info
run: |
VERSION=${{ github.ref_name }}
echo "version=${VERSION:1}" >>$GITHUB_OUTPUT
- name: Publish built wheels with bazel
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
bazel run --define=ci=true --stamp --embed_label=${{ steps.get-info.outputs.version }} -- //:whispercpp_wheel.publish --repository pypi --verbose