-
Notifications
You must be signed in to change notification settings - Fork 10
371 lines (334 loc) · 12.9 KB
/
release-beta.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
name: xmos-ai-tools-release-beta
on:
pull_request_target:
types:
- closed
branches:
- develop
env:
BAZEL_CACHE_URL: https://storage.googleapis.com/bazel_remote_cache_0/gh_actions
TOOLS_VERSION: 15.2.1
TOOLS_LINK: https://www.xmos.ai/download/Tools-15---Linux-64(15_2_1).tgz
jobs:
build-release-archive:
name: Build release archive
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
ref: ${{ env.TAG_VERSION }}
- name: Build setup
shell: bash
run: |
sudo apt-get -y -qq install libncurses5
cd $GITHUB_WORKSPACE/third_party/lib_tflite_micro
make patch
wget -nv "${{ env.TOOLS_LINK }}?key=${{ secrets.TOOLS_KEY }}" -O tools.tgz
tar xf tools.tgz
cd XMOS/XTC/${{ env.TOOLS_VERSION }}
source ./SetEnv
cd $GITHUB_WORKSPACE/third_party/lib_tflite_micro
mkdir -p build
cd build
cmake .. --toolchain=../lib_tflite_micro/submodules/xmos_cmake_toolchain/xs3a.cmake
make create_zip -j4
- uses: actions/upload-artifact@v4
with:
name: xcore-archive
path: third_party/lib_tflite_micro/build/*.zip
macos-release-wheel:
if: github.event.pull_request.merged == true
name: Build release wheels for macOS
needs: [build-release-archive]
runs-on: macos-13
strategy:
matrix:
python-version: [3.9]
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- 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.BAZEL_REMOTE_CACHE_JSON_KEY }}
- uses: actions/download-artifact@v4
with:
name: xcore-archive
path: python/xmos_ai_tools/runtime
- name: Prepare release archive
shell: bash
run: |
cd $GITHUB_WORKSPACE/python/xmos_ai_tools/runtime
unzip release_archive.zip
rm release_archive.zip
- name: Build macOS wheels
shell: bash
run: |
python --version
python -m pip install wheel setuptools setuptools-scm numpy six --no-cache-dir
cd $GITHUB_WORKSPACE/third_party/lib_tflite_micro
make patch
cd $GITHUB_WORKSPACE
./build.sh -T xinterpreter-nozip -b
cd $GITHUB_WORKSPACE/xformer
if [[ -n $GOOGLE_APPLICATION_CREDENTIALS ]]; then
echo "using Google Cloud Storage cache"
echo -e 'build --remote_cache=${{ env.BAZEL_CACHE_URL }}/${{ runner.os }}-${{ runner.arch }}-python${{ matrix.python-version }}' >> .bazelrc.user
echo -e 'build --google_default_credentials' >> .bazelrc.user
fi
bazelisk build //:xcore-opt --copt=-fvisibility=hidden --copt=-mavx --copt=-mmacosx-version-min=10.13 --linkopt=-mmacosx-version-min=10.13 --linkopt=-dead_strip --distinct_host_configuration=false --//:disable_version_check
cd $GITHUB_WORKSPACE/python
python setup.py bdist_wheel --plat macosx_10_14_x86_64
- uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-wheels
path: python/dist
macos-arm-release-wheel:
if: github.event.pull_request.merged == true
name: Build release wheels for macOS arm64
needs: [build-release-archive]
runs-on: macos-14
strategy:
matrix:
python-version: [3.9]
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- 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.BAZEL_REMOTE_CACHE_JSON_KEY }}
- uses: actions/download-artifact@v4
with:
name: xcore-archive
path: python/xmos_ai_tools/runtime
- name: Prepare release archive
shell: bash
run: |
cd $GITHUB_WORKSPACE/python/xmos_ai_tools/runtime
unzip release_archive.zip
rm release_archive.zip
- name: Build macOS arm wheels
env:
CMAKE_ENABLE_DARWIN_TARGET_ARM64: 1
shell: bash
run: |
python --version
python -m pip install wheel setuptools setuptools-scm numpy six --no-cache-dir
cd $GITHUB_WORKSPACE/third_party/lib_tflite_micro
make patch
cd $GITHUB_WORKSPACE
./build.sh -T xinterpreter-nozip -b
cd $GITHUB_WORKSPACE/xformer
if [[ -n $GOOGLE_APPLICATION_CREDENTIALS ]]; then
echo "using Google Cloud Storage cache"
echo -e 'build --remote_cache=${{ env.BAZEL_CACHE_URL }}/${{ runner.os }}-arm64-python${{ matrix.python-version }}' >> .bazelrc.user
echo -e 'build --google_default_credentials' >> .bazelrc.user
fi
bazelisk build //:xcore-opt --cpu=darwin_arm64 --copt=-fvisibility=hidden --copt=-mmacosx-version-min=11.0 --linkopt=-mmacosx-version-min=11.0 --linkopt=-dead_strip --//:disable_version_check
cd $GITHUB_WORKSPACE/python
python setup.py bdist_wheel --plat-name macosx_11_0_arm64
- uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-arm-wheels
path: python/dist
manylinux-release-wheel:
if: github.event.pull_request.merged == true
name: Build release wheels for manylinux2014
needs: [build-release-archive]
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.9]
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: false
swap-storage: false
- 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.BAZEL_REMOTE_CACHE_JSON_KEY }}
- uses: actions/download-artifact@v4
with:
name: xcore-archive
path: python/xmos_ai_tools/runtime
- name: Prepare release archive
shell: bash
run: |
cd $GITHUB_WORKSPACE/python/xmos_ai_tools/runtime
unzip release_archive.zip
rm release_archive.zip
- name: Build manylinux2014 wheels
# auditwheel requires patchelf and repairs the created wheel file to
# be compatible for manylinux.
run: |
pushd $GITHUB_WORKSPACE/xformer
if [[ -n $GOOGLE_APPLICATION_CREDENTIALS ]]; then
echo "using Google Cloud Storage cache"
echo -e 'build --remote_cache=${{ env.BAZEL_CACHE_URL }}/${{ runner.os }}-${{ runner.arch }}-python${{ matrix.python-version }}' >> .bazelrc.user
echo -e 'build --google_default_credentials' >> .bazelrc.user
fi
popd
if [[ -n $GOOGLE_APPLICATION_CREDENTIALS ]]; then
docker run -e SETUPTOOLS_SCM_PRETEND_VERSION=${{ env.PRETEND_VERSION }} \
-e GOOGLE_APPLICATION_CREDENTIALS=/tmp/gcloud-credentials.json \
-v $GOOGLE_APPLICATION_CREDENTIALS:/tmp/gcloud-credentials.json:ro \
-v ${PWD}:/ai_tools -w /ai_tools \
tensorflow/build:2.15-python${{ matrix.python-version }} \
.github/scripts/build_linux_wheel.sh
else
docker run -e SETUPTOOLS_SCM_PRETEND_VERSION=${{ env.PRETEND_VERSION }} \
-v ${PWD}:/ai_tools -w /ai_tools \
tensorflow/build:2.15-python${{ matrix.python-version }} \
.github/scripts/build_linux_wheel.sh
fi
sudo apt-get -y -qq install patchelf --no-install-recommends
python -m pip install auditwheel==5.2.0 --no-cache-dir
cd python
for f in dist/*.whl; do
auditwheel repair --plat manylinux2014_x86_64 $f
done
- uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-wheels
# auditwheel creates the output wheel in the wheelhouse folder
path: python/wheelhouse
windows-release-wheel:
if: github.event.pull_request.merged == true
name: Build release wheels for windows
needs: [build-release-archive]
runs-on: windows-2019
strategy:
matrix:
python-version: [3.9]
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- 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.BAZEL_REMOTE_CACHE_JSON_KEY }}
- name: Configure pagefile
uses: al-cheb/[email protected]
with:
minimum-size: 10GB
maximum-size: 20GB
- name: Set up pagefile
shell: pwsh
run: |
(Get-CimInstance Win32_PageFileUsage).AllocatedBaseSize
- uses: actions/download-artifact@v4
with:
name: xcore-archive
path: python/xmos_ai_tools/runtime
- name: Prepare release archive
shell: cmd
run: |
cd %GITHUB_WORKSPACE%/python/xmos_ai_tools/runtime
7z x release_archive.zip
del release_archive.zip
- name: Build xcore-opt and xtflm-interpreter
shell: cmd
run: |
python --version
python -m pip install wheel setuptools setuptools-scm numpy six --no-cache-dir
python -c "import sys; print(sys.executable)"
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
cd %GITHUB_WORKSPACE%/third_party/lib_tflite_micro
make patch
cd %GITHUB_WORKSPACE%/python/xmos_ai_tools/xinterpreters
mkdir -p build
cd build
cmake ..
cmake --build . -t install --parallel 2 --config Release
cd %GITHUB_WORKSPACE%/xformer
set BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC
bazelisk --output_user_root c:\_bzl build //:xcore-opt --local_ram_resources=5120 --action_env PYTHON_BIN_PATH="C:/hostedtoolcache/windows/Python/3.9.13/x64/python.exe" --remote_cache=${{ env.BAZEL_CACHE_URL }}/${{ runner.os }}-${{ runner.arch }}-python${{ matrix.python-version }} --google_default_credentials --//:disable_version_check
- name: Build windows wheels
shell: cmd
run: |
cd python
python setup.py bdist_wheel
- uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-wheels
path: python/dist
publish-wheels:
if: github.event.pull_request.merged == true
name: Publish wheels to PyPi
needs: [macos-release-wheel, macos-arm-release-wheel, manylinux-release-wheel, windows-release-wheel]
runs-on: ubuntu-20.04
steps:
- 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: Linux-wheels
path: Linux-wheels
if: ${{ needs.manylinux-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 macOS-wheels/*.whl dist/ || true
cp macOS-arm-wheels/*.whl dist/ || true
cp Linux-wheels/*.whl dist/ || true
cp Windows-wheels/*.whl dist/ || true
ls -la dist/
sha256sum dist/*.whl
- name: Publish packages to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}