-
Notifications
You must be signed in to change notification settings - Fork 35
392 lines (360 loc) · 14.6 KB
/
release.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
name: lce-release
on:
release:
types: [published]
tags:
- v*
workflow_dispatch:
inputs:
version:
description: "Version of the form 1.0.0(.devYYYYMMDD)"
required: true
env:
IMAGE_NAME: dev
jobs:
benchmark-binaries:
name: Build Benchmark Binaries for AArch64 and Android
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.9
- uses: actions/cache@v4
id: cache
with:
path: /tmp/lce_android
key: ${{ runner.os }}-${{ hashFiles('**/third_party/install_android.sh') }}
- name: Install pip dependencies
run: pip install numpy six --no-cache-dir
- name: Set Java version
run: echo "JAVA_HOME=${JAVA_HOME_8_X64}" >> $GITHUB_ENV
- name: Download and install Android NDK/SDK
if: steps.cache.outputs.cache-hit != 'true'
run: ./third_party/install_android.sh
- name: Configure Bazel
run: LCE_SET_ANDROID_WORKSPACE=1 ANDROID_SDK_HOME="/tmp/lce_android" ANDROID_API_LEVEL=30 ANDROID_NDK_HOME="/tmp/lce_android/ndk/25.2.9519653" ANDROID_NDK_API_LEVEL=30 ANDROID_BUILD_TOOLS_VERSION=31.0.0 ./configure.py
shell: bash
- run: mkdir benchmark-binaries
- name: Build Benchmark utility for AArch64
run: |
bazelisk build //larq_compute_engine/tflite/benchmark:lce_benchmark_model --config=aarch64 -c opt --copt=-O3
cp bazel-bin/larq_compute_engine/tflite/benchmark/lce_benchmark_model benchmark-binaries/lce_benchmark_model_aarch64
- name: Build Benchmark utility for AArch32
run: |
bazelisk build //larq_compute_engine/tflite/benchmark:lce_benchmark_model --config=rpi3 -c opt --copt=-O3
cp bazel-bin/larq_compute_engine/tflite/benchmark/lce_benchmark_model benchmark-binaries/lce_benchmark_model_aarch32
- name: Build Benchmark utility for Android
run: |
bazelisk build //larq_compute_engine/tflite/benchmark:lce_benchmark_model --config=android_arm64 -c opt --copt=-O3
cp bazel-bin/larq_compute_engine/tflite/benchmark/lce_benchmark_model benchmark-binaries/lce_benchmark_model_android_arm64
- uses: actions/upload-artifact@v4
with:
name: Benchmark-Binaries
path: benchmark-binaries
- name: Upload Release Asset AArch64
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: benchmark-binaries/lce_benchmark_model_aarch64
asset_name: lce_benchmark_model_aarch64
asset_content_type: application/octet-stream
- name: Upload Release Asset AArch32
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: benchmark-binaries/lce_benchmark_model_aarch32
asset_name: lce_benchmark_model_aarch32
asset_content_type: application/octet-stream
- name: Upload Release Asset Android
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: benchmark-binaries/lce_benchmark_model_android_arm64
asset_name: lce_benchmark_model_android_arm64
asset_content_type: application/octet-stream
android-aar:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: 3.9
- uses: actions/cache@v4
id: cache
with:
path: /tmp/lce_android
key: ${{ runner.os }}-${{ hashFiles('**/third_party/install_android.sh') }}
- name: Install pip dependencies
run: pip install numpy six --no-cache-dir
- name: Set Java version
run: echo "JAVA_HOME=${JAVA_HOME_8_X64}" >> $GITHUB_ENV
- name: Download and install Android NDK/SDK
if: steps.cache.outputs.cache-hit != 'true'
run: ./third_party/install_android.sh
- name: Configure Bazel
run: LCE_SET_ANDROID_WORKSPACE=1 ANDROID_SDK_HOME="/tmp/lce_android" ANDROID_API_LEVEL=30 ANDROID_NDK_HOME="/tmp/lce_android/ndk/25.2.9519653" ANDROID_NDK_API_LEVEL=30 ANDROID_BUILD_TOOLS_VERSION=31.0.0 ./configure.py
shell: bash
- name: Build LCE AAR
run: BUILDER=bazelisk ./larq_compute_engine/tflite/java/build_lce_aar.sh
- uses: actions/upload-artifact@v4
with:
name: Android-AAR
path: lce-lite-*.aar
- name: Get Name of Artifact
if: github.event_name == 'release'
run: |
ASSET_NAME=$(ls lce-lite-*.aar | head -n 1)
echo "ASSET_NAME=${ASSET_NAME}" >> $GITHUB_ENV
- name: Upload Release Asset
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ env.ASSET_NAME }}
asset_name: ${{ env.ASSET_NAME }}
asset_content_type: application/octet-stream
macos-release-wheel:
name: Build release wheels for macOS
runs-on: macos-latest
strategy:
matrix:
python-version: [3.9, "3.10", 3.11]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: google-github-actions/auth@v2
continue-on-error: true
with:
credentials_json: ${{ secrets.gcs_bazel_cache }}
- name: Build macOS wheels
run: |
python --version
python -m pip install delocate wheel setuptools numpy six --no-cache-dir
./configure.py
export MACOSX_DEPLOYMENT_TARGET=10.14
if [[ -n $GOOGLE_APPLICATION_CREDENTIALS ]]; then
echo -e 'build --remote_cache=https://storage.googleapis.com/plumerai-bazel-cache/lce-release-macos-python${{ matrix.python-version }}' >> .bazelrc.user
echo -e 'build --google_default_credentials' >> .bazelrc.user
fi
bazelisk build :build_pip_pkg --copt=-fvisibility=hidden --copt=-mavx --linkopt=-dead_strip
bazel-bin/build_pip_pkg artifacts --plat-name macosx_10_14_x86_64
for f in artifacts/*.whl; do
delocate-wheel -w wheelhouse $f
done
env:
LCE_RELEASE_VERSION: ${{ github.event.inputs.version }}
TF_PYTHON_VERSION: ${{ matrix.python-version }}
shell: bash
- uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-wheels
path: wheelhouse
macos-arm-release-wheel:
name: Build release arm wheels for macOS
runs-on: macos-11
strategy:
matrix:
python-version: [3.9, "3.10", 3.11]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: google-github-actions/auth@v2
continue-on-error: true
with:
credentials_json: ${{ secrets.gcs_bazel_cache }}
- name: Build macOS wheels
run: |
python --version
python -m pip install delocate wheel setuptools numpy six --no-cache-dir
./configure.py
export MACOSX_DEPLOYMENT_TARGET=11.0
if [[ -n $GOOGLE_APPLICATION_CREDENTIALS ]]; then
echo -e 'build --remote_cache=https://storage.googleapis.com/plumerai-bazel-cache/lce-release-macos-arm-python${{ matrix.python-version }}' >> .bazelrc.user
echo -e 'build --google_default_credentials' >> .bazelrc.user
fi
bazelisk build :build_pip_pkg --copt=-fvisibility=hidden --linkopt=-dead_strip --config=macos_arm64
bazel-bin/build_pip_pkg artifacts --plat-name macosx_11_0_arm64
for f in artifacts/*.whl; do
delocate-wheel -w wheelhouse $f
done
env:
LCE_RELEASE_VERSION: ${{ github.event.inputs.version }}
TF_PYTHON_VERSION: ${{ matrix.python-version }}
shell: bash
- uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-arm-wheels
path: wheelhouse
manylinux-release-wheel:
name: Build release wheels for manylinux2014
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9, "3.10", 3.11]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: google-github-actions/auth@v2
continue-on-error: true
with:
credentials_json: ${{ secrets.gcs_bazel_cache }}
- name: Build manylinux2014 wheels
run: |
if [[ -n $GOOGLE_APPLICATION_CREDENTIALS ]]; then
echo -e 'build --remote_cache=https://storage.googleapis.com/plumerai-bazel-cache/lce-release-manylinux-python${{ matrix.python-version }}' >> .bazelrc.user
echo -e 'build --google_default_credentials' >> .bazelrc.user
fi
docker run -e LCE_RELEASE_VERSION=${{ github.event.inputs.version }} \
-e GOOGLE_APPLICATION_CREDENTIALS=/tmp/gcloud-credentials.json \
-v $GOOGLE_APPLICATION_CREDENTIALS:/tmp/gcloud-credentials.json:ro \
-v ${PWD}:/compute-engine -w /compute-engine \
tensorflow/build:2.13-python${{ matrix.python-version }} \
.github/tools/release_linux.sh
sudo apt-get -y -qq install patchelf --no-install-recommends
python -m pip install auditwheel --no-cache-dir
for f in artifacts/*.whl; do
auditwheel repair --plat manylinux2014_x86_64 $f
done
ls -al wheelhouse/
env:
TF_PYTHON_VERSION: ${{ matrix.python-version }}
- uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-wheels
path: wheelhouse
windows-release-wheel:
name: Build release wheels for Windows
runs-on: windows-2019
strategy:
matrix:
python-version: [3.9, "3.10", 3.11]
fail-fast: false
steps:
- name: Configure Pagefile
uses: al-cheb/[email protected]
with:
minimum-size: 8GB
- name: Pagefile size
run: |
(Get-CimInstance Win32_PageFileUsage).AllocatedBaseSize
shell: pwsh
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: google-github-actions/auth@v2
continue-on-error: true
with:
credentials_json: ${{ secrets.gcs_bazel_cache }}
- name: Build Windows wheels
run: |
$Env:BAZEL_VC = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC"
set PreferredToolArchitecture=x64
# The default is "/arch:AVX", which we don't want.
$Env:CC_OPT_FLAGS = "/O2"
python --version
python -m pip install wheel setuptools numpy six --no-cache-dir
"" | python configure.py
bazelisk --output_base=C:\build_output build :build_pip_pkg --enable_runfiles --local_ram_resources=4096 --remote_cache=https://storage.googleapis.com/plumerai-bazel-cache/lce-release-windows-python${{ matrix.python-version }} --google_default_credentials
bazel-bin/build_pip_pkg wheelhouse
env:
LCE_RELEASE_VERSION: ${{ github.event.inputs.version }}
TF_PYTHON_VERSION: ${{ matrix.python-version }}
shell: pwsh
- uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-wheels
path: wheelhouse
upload-wheels:
name: Publish wheels to PyPi
if: always() && github.event_name == 'release'
needs:
[
manylinux-release-wheel,
macos-release-wheel,
macos-arm-release-wheel,
windows-release-wheel,
]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: Linux-wheels
path: Linux-wheels
if: ${{ needs.manylinux-release-wheel.result == 'success' }}
- uses: actions/download-artifact@v4
with:
name: macOS-wheels
path: macOS-wheels
if: ${{ needs.macos-release-wheel.result == 'success' }}
- uses: actions/download-artifact@v4
with:
name: macOS-arm-wheels
path: macOS-arm-wheels
if: ${{ needs.macos-arm-release-wheel.result == 'success' }}
- uses: actions/download-artifact@v4
with:
name: Windows-wheels
path: Windows-wheels
if: ${{ needs.windows-release-wheel.result == 'success' }}
- run: |
set -x
mkdir -p dist
cp Linux-wheels/*.whl dist/ || true
cp macOS-wheels/*.whl dist/ || true
cp macOS-arm-wheels/*.whl dist/ || true
cp Windows-wheels/*.whl dist/ || true
ls -la dist/
sha256sum dist/*.whl
- uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_token }}
push-docker-image:
name: Push Docker image to GitHub Package Registry
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
- name: Push image
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION