-
Notifications
You must be signed in to change notification settings - Fork 152
567 lines (534 loc) · 20.2 KB
/
test-build-binaries.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
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
name: Build Binaries
on:
push:
paths-ignore:
- 'frontend/**'
- 'docs/**'
- 'tests/**'
- '.github/ISSUE_TEMPLATE/**'
- '.vscode/**'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DEFAULT_PYTHON: 3.12
jobs:
build-ledfx-windows:
name: Build LedFx (Windows)
runs-on: windows-latest
defaults:
run:
shell: bash -x {0}
steps:
- name: Setup CI sound system
uses: LABSN/sound-ci-helpers@v1
- name: Check out code from GitHub
uses: actions/checkout@v4
- name: Setup Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v5
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Get full Python version
id: full-python-version
run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT
- name: Install poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y
- name: Update Path for Windows
run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH
- name: Enable long paths for git on Windows
# Enable handling long path names (+260 char) on the Windows platform
# https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#maximum-path-length-limitation
run: git config --system core.longpaths true
- name: Configure poetry
run: poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v4
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ runner.arch }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: |
# `timeout` is not available on macOS, so we define a custom function.
[ "$(command -v timeout)" ] || function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
# Using `timeout` is a safeguard against the Poetry command hanging for some reason.
timeout 10s poetry run pip --version || rm -rf .venv
- name: Check lock file
run: poetry check --lock
- name: Install LedFx
run: |
poetry install --with dev --extras hue
- name: Get LedFx Version and Upload to Artifacts for later use
id: ledfx-version
# Note - we remove the newline from the version string so that it can be used in the artifact name id: ledfx-version
run: |
echo ledfx-version=$(python -c "import ledfx; print(ledfx.__version__, end='')") >> $GITHUB_OUTPUT
python -c "import ledfx; print(ledfx.__version__, end='')" | tr -d '\n' > ledfx_version.txt
- name: Upload LedFx Version
uses: actions/upload-artifact@v4
with:
name: ledfx_version.txt
path: ${{ github.workspace }}/ledfx_version.txt
- name: Build Binary
run: |
poetry run pyinstaller windows-binary.spec
- name: Remove packaged portaudio binary
run: |
rm dist/LedFx/_internal/_sounddevice_data/portaudio-binaries/libportaudio64bit.dll
- name: Move WASAPI loopback portaudio
run: |
mv loopback/libportaudio64bit.dll dist/LedFx/_internal/_sounddevice_data/portaudio-binaries/libportaudio64bit.dll
- name: Upload LedFx Binary
uses: actions/upload-artifact@v4
if: always()
with:
name: LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-windows-x64
path: ${{ github.workspace }}/dist/*
build-ledfx-osx:
name: Build LedFx (OS X)
runs-on: macos-13
steps:
- name: Check out code from GitHub
uses: actions/checkout@v4
- name: Install build dependencies
run: |
brew install portaudio
- name: Setup Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v5
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Get full Python version
id: full-python-version
run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT
- name: Install poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y
- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Configure poetry
run: poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v4
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ runner.arch }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: |
# `timeout` is not available on macOS, so we define a custom function.
[ "$(command -v timeout)" ] || function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
# Using `timeout` is a safeguard against the Poetry command hanging for some reason.
timeout 10s poetry run pip --version || rm -rf .venv
- name: Check lock file
run: poetry check --lock
- name: Install LedFx
run: |
poetry install --with dev --extras hue
- name: Get LedFx Version
id: ledfx-version
run: |
echo ledfx-version=$(python -c "import ledfx; print(ledfx.__version__)") >> $GITHUB_OUTPUT
- name: Build Binary
run: |
poetry run pyinstaller osx-binary.spec
- name: Make binary executable
run: |
chmod +x dist/LedFx/Contents/MacOS/LedFx
- name: Create .app from dist
run: |
mv dist/LedFx/ dist/LedFx.app
- name: Remove extended attributes
run: |
xattr -cr ./dist/LedFx.app
- name: Create LedFx tarball
run: |
tar -cvf LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-osx-intel.tar ./dist/LedFx.app
- name: Upload LedFx Binary
uses: actions/upload-artifact@v4
if: always()
with:
name: LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-osx-intel
path: ${{ github.workspace }}/dist/*
build-ledfx-osx-m1:
name: Build LedFx (OS X) (Apple Silicon)
runs-on: flyci-macos-14-m2
steps:
- name: Check out code from GitHub
uses: actions/checkout@v4
- name: Install build dependencies
run: |
brew install portaudio mbedtls@2
- name: Setup Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v5
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Get full Python version
id: full-python-version
run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT
- name: Install poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y
- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Configure poetry
run: poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v4
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ runner.arch }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: |
# `timeout` is not available on macOS, so we define a custom function.
[ "$(command -v timeout)" ] || function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
# Using `timeout` is a safeguard against the Poetry command hanging for some reason.
timeout 10s poetry run pip --version || rm -rf .venv
- name: Check lock file
run: poetry check --lock
- name: Install LedFx
run: |
export PATH="/opt/homebrew/opt/mbedtls@2/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/mbedtls@2/lib"
export CPPFLAGS="-I/opt/homebrew/opt/mbedtls@2/include"
poetry install --with dev --extras hue
- name: Get LedFx Version
id: ledfx-version
run: |
echo ledfx-version=$(python -c "import ledfx; print(ledfx.__version__)") >> $GITHUB_OUTPUT
- name: Build Binary
run: |
poetry run pyinstaller osx-binary.spec
- name: Make binary executable
run: |
chmod +x ./dist/LedFx/Contents/MacOS/LedFx
- name: Create .app from dist
run: |
mv ./dist/LedFx ./dist/LedFx.app
- name: Remove extended attributes
run: |
xattr -cr ./dist/LedFx.app
- name: Create LedFx tarball
run: |
tar -cvf LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-osx-arm64.tar ./dist/LedFx.app
- name: Upload LedFx Binary
uses: actions/upload-artifact@v4
if: always()
with:
name: LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-osx-arm64
path: ${{ github.workspace }}/dist/*
run-ledfx-windows:
name: Test LedFx (Windows)
runs-on: windows-latest
needs: [build-ledfx-windows]
defaults:
run:
shell: bash -x {0}
steps:
- name: Setup CI sound system
uses: LABSN/sound-ci-helpers@v1
- name: Download LedFx Version
uses: actions/download-artifact@v4
with:
name: ledfx_version.txt
- name: Get LedFx Version
id: ledfx-version
run: |
echo ledfx-version=$(cat ledfx_version.txt) >> $GITHUB_OUTPUT
- name: Download LedFx Binary
uses: actions/download-artifact@v4
with:
name: LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-windows-x64
- name: Run LedFx
run: |
LedFx/LedFx.exe -vv --ci-smoke-test --offline
run-ledfx-osx:
name: Test LedFx (OS X)
runs-on: macos-13
needs: [build-ledfx-windows, build-ledfx-osx]
steps:
- name: Download LedFx Version
uses: actions/download-artifact@v4
with:
name: ledfx_version.txt
- name: Get LedFx Version
id: ledfx-version
run: |
echo ledfx-version=$(cat ledfx_version.txt) >> $GITHUB_OUTPUT
- name: Download LedFx Binary
uses: actions/download-artifact@v4
with:
name: LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-osx-intel
- name: Run LedFx
run: |
xattr -cr ./LedFx.app
chmod +x ./LedFx.app/Contents/MacOS/LedFx
./LedFx.app/Contents/MacOS/LedFx -vv --ci-smoke-test --offline
run-ledfx-osx-m1:
name: Test LedFx (OS X) (Apple Silicon)
runs-on: flyci-macos-14-m2
needs: [build-ledfx-windows, build-ledfx-osx-m1]
steps:
- name: Download LedFx Version
uses: actions/download-artifact@v4
with:
name: ledfx_version.txt
- name: Get LedFx Version
id: ledfx-version
run: |
echo ledfx-version=$(cat ledfx_version.txt) >> $GITHUB_OUTPUT
- name: Download LedFx Binary
uses: actions/download-artifact@v4
with:
name: LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-osx-arm64
- name: Run LedFx
if: always()
run: |
xattr -cr ./LedFx.app
chmod +x ./LedFx.app/Contents/MacOS/LedFx
./LedFx.app/Contents/MacOS/LedFx -vv --ci-smoke-test --offline
create-release:
name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/')
environment: production
runs-on: macos-13
needs: [run-ledfx-windows, run-ledfx-osx, run-ledfx-osx-m1, install-from-wheel, install-from-sdist]
steps:
- name: Check out code from GitHub
uses: actions/checkout@v4
- name: Download LedFx Version
uses: actions/download-artifact@v4
with:
name: ledfx_version.txt
path: dist/
- name: Get LedFx Version
id: ledfx-version
run: |
echo ledfx-version=$(cat dist/ledfx_version.txt) >> $GITHUB_OUTPUT
rm -rf dist/ledfx_version.txt
- name: Download OSX (x64) Binary
uses: actions/download-artifact@v4
with:
name: LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-osx-intel
path: dist/
- name: Package OS X (x64) archive
run: |
xattr -cr dist/LedFx.app
chmod +x dist/LedFx.app/Contents/MacOS/LedFx
mv dist/LedFx.app dist/LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}.app
cd dist
tar c LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}.app | gzip --best > ../LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-osx-intel.tar.gz
cd ..
rm -rf dist/*
- name: Download Windows (x64) Binary
uses: actions/download-artifact@v4
with:
name: LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-windows-x64
path: dist/
- name: Create zip for Windows (x64)
run: |
mv dist/LedFx dist/LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}
cd dist
zip -r ../LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-win-x64.zip LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}
cd ..
rm -rf dist/*
- name: Download OS X (arm64) Binary
uses: actions/download-artifact@v4
with:
name: LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-osx-arm64
path: dist/
- name: Package OS X (arm64) archive
run: |
xattr -cr dist/LedFx.app
chmod +x dist/LedFx.app/Contents/MacOS/LedFx
mv dist/LedFx.app dist/LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}.app
cd dist
tar c LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}.app | gzip --best > ../LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-osx-arm64.tar.gz
cd ..
rm -rf dist/*
- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-win-x64.zip
LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-osx-intel.tar.gz
LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-osx-arm64.tar.gz
name: LedFx ${{ steps.ledfx-version.outputs.ledfx-version }}
generate_release_notes: true
build-test-wheel-and-sdist:
name: Build LedFx (PyPi)
runs-on: ubuntu-latest
needs: [build-ledfx-windows]
steps:
- name: Check out code from GitHub
uses: actions/checkout@v4
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Download LedFx Version
uses: actions/download-artifact@v4
with:
name: ledfx_version.txt
- name: Get LedFx Version
id: ledfx-version
run: |
echo ledfx-version=$(cat ledfx_version.txt) >> $GITHUB_OUTPUT
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
- name: Create and populate ledfx.env
run: |
echo "GITHUB_SHA = \"${{ github.sha }}\"" >> ledfx.env
if [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then
echo "IS_RELEASE = true" >> ledfx.env
else
echo "IS_RELEASE = false" >> ledfx.env
fi
- name: Build a binary wheel and sdist
run: |
poetry build
- name: Package the wheel
uses: actions/upload-artifact@v4
with:
name: LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-wheel
path: dist/ledfx-*.whl
- name: Package the sdist
uses: actions/upload-artifact@v4
with:
name: LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-sdist
path: dist/ledfx-*.tar.gz
install-from-wheel:
name: Test LedFx (PyPi wheel)
runs-on: ubuntu-latest
needs: [build-test-wheel-and-sdist]
steps:
- name: Download LedFx Version
uses: actions/download-artifact@v4
with:
name: ledfx_version.txt
- name: Get LedFx Version
id: ledfx-version
run: |
echo ledfx-version=$(cat ledfx_version.txt) >> $GITHUB_OUTPUT
- name: Get the wheel
uses: actions/download-artifact@v4
with:
name: LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-wheel
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Install portaudio
run: |
sudo apt-get update && sudo apt-get install -y portaudio19-dev
- name: Install the wheel
run: |
pip install ledfx-*.whl
- name: Run LedFx
run: |
ledfx -vv --ci-smoke-test --offline
install-from-sdist:
name: Test LedFx (PyPi sdist)
runs-on: ubuntu-latest
needs: [build-test-wheel-and-sdist]
steps:
- name: Download LedFx Version
uses: actions/download-artifact@v4
with:
name: ledfx_version.txt
- name: Get LedFx Version
id: ledfx-version
run: |
echo ledfx-version=$(cat ledfx_version.txt) >> $GITHUB_OUTPUT
- name: Get the sdist
uses: actions/download-artifact@v4
with:
name: LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-sdist
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Install portaudio
run: |
sudo apt-get update && sudo apt-get install -y portaudio19-dev
- name: Install the sdist
run: |
pip install ledfx-*.tar.gz
- name: Run LedFx
run: |
ledfx --ci-smoke-test -vv --offline
publish:
name: Publish LedFx to PyPi
needs: [install-from-wheel, install-from-sdist, create-release]
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Download LedFx Version
uses: actions/download-artifact@v4
with:
name: ledfx_version.txt
- name: Get LedFx Version
id: ledfx-version
run: |
echo ledfx-version=$(cat ledfx_version.txt) >> $GITHUB_OUTPUT
- name: Get the wheel
uses: actions/download-artifact@v4
with:
name: LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-wheel
path: dist/
- name: Get the sdist
uses: actions/download-artifact@v4
with:
name: LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-sdist
path: dist/
- name: Publish to Test PyPI
if: github.event_name == 'workflow_dispatch'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TEST_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
notify-sentry:
name: Notify Sentry of Release
needs: [create-release]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download LedFx Version
uses: actions/download-artifact@v4
with:
name: ledfx_version.txt
path: dist/
- name: Get LedFx Version
id: ledfx-version
run: |
echo ledfx-version=$(cat dist/ledfx_version.txt) >> $GITHUB_OUTPUT
rm -rf dist/ledfx_version.txt
- name: Create Sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN_V2 }}
SENTRY_ORG: ledfx-org
SENTRY_PROJECT: ledfx-v2-rel
with:
environment: production
version: ledfx@${{ steps.ledfx-version.outputs.ledfx-version }}