forked from Taiko2k/Tauon
-
-
Notifications
You must be signed in to change notification settings - Fork 0
507 lines (428 loc) · 19.2 KB
/
build_and_release.yaml
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
name: Build and release
on:
push:
pull_request:
jobs:
build-linux:
runs-on: ubuntu-24.04
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install deps
run: |
sudo apt-get update
sudo apt-get install -y \
gettext \
gobject-introspection \
gir1.2-rsvg-2.0 \
kde-config-gtk-style \
libcanberra-gtk3-module \
libgirepository1.0-dev \
python3-gi-cairo \
libayatana-appindicator3-dev \
libcairo2-dev \
libpipewire-0.3-dev \
libdbus-1-dev \
libjxl-dev \
libflac-dev \
libgme-dev \
libmpg123-dev \
libopenmpt-dev \
libopusfile-dev \
libsamplerate0-dev \
libvorbis-dev \
libwavpack-dev \
p7zip
# JPEG-XL hack since 24.04 is too old
sudo apt-get install -y \
libgif7 \
wget
wget http://mirrors.kernel.org/ubuntu/pool/universe/j/jpeg-xl/libjxl-dev_0.10.3-4ubuntu1_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/j/jpeg-xl/libjxl0.10_0.10.3-4ubuntu1_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/h/highway/libhwy-dev_1.2.0-3ubuntu2_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/h/highway/libhwy1t64_1.2.0-3ubuntu2_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/main/l/lcms2/liblcms2-dev_2.14-2build1_amd64.deb
sudo dpkg -i *.deb
# libsdl2-image-dev \
- name: Install Python dependencies and setup venv
run: |
python -m pip install --upgrade pip
python -m venv .venv
source .venv/bin/activate
pip install \
-r requirements.txt \
build \
pyinstaller
- name: Build the project using python-build
run: |
source .venv/bin/activate
python -m compile_translations
python -m build --wheel
- name: Install the project into a venv
run: |
source .venv/bin/activate
pip install --prefix ".venv" dist/*.whl
- name: "[DEBUG] List all files"
run: find .
- name: Build Linux App with PyInstaller
run: |
source .venv/bin/activate
pyinstaller --log-level=DEBUG linux.spec
- name: Create 7Z
run: |
APP_NAME="TauonMusicBox"
cd "dist/${APP_NAME}"
ARCHIVE_PATH="../../${APP_NAME}.7z"
7z a -r "${ARCHIVE_PATH}" "."
- name: Upload 7Z artifact
uses: actions/upload-artifact@v4
with:
name: TauonMusicBox-linux
path: TauonMusicBox.7z
build-macos:
runs-on: macos-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
submodules: true
# - name: Set up Python
# uses: actions/setup-python@v5
# with:
# python-version: '3.13'
- name: brew update and upgrade
run: brew update && brew upgrade
- name: Install brew dependencies
run: |
brew install \
gobject-introspection \
gtk+3 \
pango \
pillow \
sdl3 \
sdl3_image \
jpeg-xl \
ffmpeg \
librsvg \
opusfile \
libopenmpt \
wavpack \
game-music-emu
# This generates 30MB of logs, enable it only when actively debugging something
# - name: "[DEBUG] List all Cellar files"
# run: find /opt/homebrew/Cellar
- name: Install Python dependencies and setup venv
run: |
export CXXFLAGS="-I/opt/homebrew/include"
export LDFLAGS="-L/opt/homebrew/lib"
$(brew --prefix python)/libexec/bin/python -m pip install --break-system-packages --upgrade pip
$(brew --prefix python)/libexec/bin/pip install --break-system-packages \
-r requirements.txt \
build \
pyinstaller
# $(brew --prefix python)/libexec/bin/pip install --break-system-packages https://github.com/pyinstaller/pyinstaller/archive/develop.zip
# $(brew --prefix python)/libexec/bin/python -m venv --system-site-packages .venv
# source .venv/bin/activate
# CFLAGS: "-I/opt/homebrew/include"
- name: Build the project using python-build
run: |
$(brew --prefix python)/libexec/bin/python -m compile_translations
$(brew --prefix python)/libexec/bin/python -m build --wheel
# source .venv/bin/activate
- name: Install the project into a venv
run: |
$(brew --prefix python)/libexec/bin/pip install --prefix ".venv" dist/*.whl
# $(brew --prefix python)/libexec/bin/pip install --break-system-packages dist/*.whl
# source .venv/bin/activate
- name: "[DEBUG] List all files"
run: find .
- name: Build macOS app with PyInstaller
run: |
pyinstaller --log-level=DEBUG mac.spec
# source .venv/bin/activate
env:
DYLD_LIBRARY_PATH: "/opt/homebrew/lib"
- name: "[DEBUG] List all files in .app"
run: find "dist/TauonMusicBox.app"
- name: Create DMG
run: |
mkdir -p dist/dmg
APP_NAME="TauonMusicBox"
APP_PATH="dist/${APP_NAME}.app"
DMG_PATH="dist/dmg/${APP_NAME}.dmg"
# Create a .dmg package
hdiutil create -volname "$APP_NAME" -srcfolder "$APP_PATH" -ov -format UDZO "$DMG_PATH"
- name: Upload DMG artifact
uses: actions/upload-artifact@v4
with:
name: TauonMusicBox-dmg
path: dist/dmg/TauonMusicBox.dmg
# - name: Run Tauon for testing
# run: |
# hdiutil attach dist/dmg/TauonMusicBox.dmg
# /Volumes/TauonMusicBox/TauonMusicBox.app/Contents/MacOS/Tauon\ Music\ Box
build-windows:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
# TODO(Martin): p7zip should be 7zip but MINGW64 hasn't updated at the time of writing, try switching it later
- name: Read Package List
id: read_packages
run: |
$packages = Get-Content extra/msyspac.txt -Raw | Out-String
$packages = $packages -replace "`r`n", " " -replace "`n", " "
$packages = $packages.Trim() + " p7zip"
echo "packages=$packages" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8
- name: Set up MSYS2 MinGW-W64
uses: msys2/setup-msys2@v2
with:
msystem: mingw64
update: true
install: ${{ env.packages }}
# ca-certificates
# mingw-w64-x86_64-python-zeroconf
# mingw-w64-x86_64-zlib
- name: Update CA trust and hack opusfile
shell: msys2 {0}
run: |
update-ca-trust
# https://github.com/xiph/opusfile/pull/47
sed -i 's,<opus_multistream.h>,<opus/opus_multistream.h>,' /mingw64/include/opus/opusfile.h
- name: Install Python dependencies and setup venv
shell: msys2 {0}
run: |
python -m pip install --break-system-packages --upgrade pip
python -m venv .venv
export CFLAGS="-I/mingw64/include"
export PIP_FIND_LINKS=https://github.com/ddelange/python-magic/releases/expanded_assets/0.4.28.post8
.venv/bin/python -m pip install \
-r requirements.txt \
build \
pyinstaller
# export PIP_FIND_LINKS=https://github.com/ddelange/python-magic/releases/expanded_assets/0.4.28.post8
- name: Build the project using python-build
shell: msys2 {0}
run: |
source .venv/bin/activate
python -m compile_translations
python -m build --wheel
- name: Install the project into a venv
shell: msys2 {0}
run: |
source .venv/bin/activate
pip install --prefix ".venv" dist/*.whl
# https://github.com/Taiko2k/Tauon/pull/931#issuecomment-1464880133
- name: Download optionals from latest release files and notofonts' GitHub
shell: msys2 {0}
run: |
curl -L -o librespot.exe https://github.com/Taiko2k/Tauon/releases/download/v7.8.3/librespot.exe # v0.6.0 - https://github.com/librespot-org/librespot/releases
curl -L -o TaskbarLib.tlb https://github.com/Taiko2k/Tauon/releases/download/v7.8.3/TaskbarLib.tlb
curl -L -o TauonSMTC.dll https://github.com/Taiko2k/Tauon/releases/download/v7.8.3/TauonSMTC.dll
mkdir fonts
curl -L -o fonts/NotoSans-ExtraCondensed.ttf https://github.com/notofonts/notofonts.github.io/raw/refs/heads/main/fonts/NotoSans/full/ttf/NotoSans-ExtraCondensed.ttf # 800KB
curl -L -o fonts/NotoSans-ExtraCondensedBold.ttf https://github.com/notofonts/notofonts.github.io/raw/refs/heads/main/fonts/NotoSans/full/ttf/NotoSans-ExtraCondensedBold.ttf # 800KB
curl -L -o fonts/NotoSans-Bold.ttf https://github.com/notofonts/notofonts.github.io/raw/refs/heads/main/fonts/NotoSans/full/ttf/NotoSans-Bold.ttf # 800KB
curl -L -o fonts/NotoSans-Medium.ttf https://github.com/notofonts/notofonts.github.io/raw/refs/heads/main/fonts/NotoSans/full/ttf/NotoSans-Medium.ttf # 800KB
curl -L -o fonts/NotoSans-Regular.ttf https://github.com/notofonts/notofonts.github.io/raw/refs/heads/main/fonts/NotoSans/full/ttf/NotoSans-Regular.ttf # 800KB
curl -L -o fonts/NotoSansCJKjp-Bold.otf https://github.com/notofonts/noto-cjk/raw/refs/heads/main/Sans/OTF/Japanese/NotoSansCJKjp-Bold.otf # 16MB
curl -L -o fonts/NotoSansCJKjp-Medium.otf https://github.com/notofonts/noto-cjk/raw/refs/heads/main/Sans/OTF/Japanese/NotoSansCJKjp-Medium.otf # 16MB
curl -L -o fonts/NotoSansCJKjp-Regular.otf https://github.com/notofonts/noto-cjk/raw/refs/heads/main/Sans/OTF/Japanese/NotoSansCJKjp-Regular.otf # 16MB
- name: "[DEBUG] List all files"
shell: msys2 {0}
run: find .
- name: Build Windows App with PyInstaller
shell: msys2 {0}
run: |
source .venv/bin/activate
pyinstaller --log-level=DEBUG windows.spec
- name: Create 7Z
shell: msys2 {0}
run: |
APP_NAME="TauonMusicBox"
cd "dist/${APP_NAME}"
ARCHIVE_PATH="../../${APP_NAME}.7z"
7z a -r "${ARCHIVE_PATH}" "."
# - name: "[DEBUG] List all files after pyinstaller"
# shell: msys2 {0}
# run: find .
- name: Upload 7Z artifact
uses: actions/upload-artifact@v4
with:
name: TauonMusicBox-windows
path: TauonMusicBox.7z
- name: Replace Tauon version in .ISS
run: |
sed -i 's|{{ tauon_version }}|8.0.0|g' extra/setup.iss
- name: Compile .ISS to .EXE Installer
uses: Minionguyjpro/Inno-Setup-Action@v1.2.5
with:
path: extra/setup.iss
options: /O+
# - name: "[DEBUG] List all files after Inno"
# shell: msys2 {0}
# run: find .
- name: Upload EXE installer
uses: actions/upload-artifact@v4
with:
name: TauonMusicBox-windows-installer
path: extra/Output/tauonsetup-8.0.0.exe
get-info:
runs-on: ubuntu-24.04
outputs:
date: ${{ steps.vars.outputs.date }}
shorthash: ${{ steps.vars.outputs.shorthash }}
fullhash: ${{ steps.vars.outputs.fullhash }}
steps:
- uses: actions/checkout@v4
- name: Get date and git hash
id: vars
run: |
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
echo "shorthash=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "fullhash=$(git rev-parse HEAD)" >> $GITHUB_ENV
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
echo "shorthash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "fullhash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
pre-release:
if: github.ref == 'refs/heads/master' && github.repository == 'Taiko2k/Tauon' && github.event_name == 'push'
needs: [get-info, build-linux, build-windows, build-macos]
runs-on: ubuntu-24.04
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ~/artifacts
- name: Compress individual directories (without parent directory)
run: |
cd ~/artifacts
for dir in */; do
if [ -d "$dir" ]; then
dir_name=${dir%/}
echo "Creating zip for $dir_name"
(cd "$dir_name" && zip -r "../${dir_name}.zip" .)
fi
done
- name: Get latest release information
id: get_latest_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
api_url="https://api.github.com/repos/${{ github.repository }}"
latest_release_info=$(curl -H "Authorization: token $GITHUB_TOKEN" "$api_url/releases/latest")
echo "last_release_tag=$(echo "$latest_release_info" | jq -r '.tag_name')" >> $GITHUB_ENV
- name: Checkout the repository
uses: actions/checkout@v4
- name: Process template release_body.md
run: |
sed -i 's|RELEASE_TAG|Pre-release-Tauon-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}|g' ${{ github.workspace }}/.github/release_body.md
- name: Create Pre-Release on GitHub
id: create_release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: "Pre-release-Tauon-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}"
tag: "Pre-release-Tauon-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}"
draft: false
prerelease: true
# body: "Full Changelog: [${{ env.last_release_tag }}...${{ needs.get-info.outputs.shorthash }}](https://github.com/Taiko2k/Tauon/compare/${{ env.last_release_tag }}...${{ needs.get-info.outputs.fullhash }})"
bodyFile: ${{ github.workspace }}/.github/release_body.md
artifacts: ~/artifacts/*.zip
- name: Publish to Release Repository
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
ARTIFACTS_DIR=~/artifacts
REPO_WINDOWS="Taiko2k/Tauon"
REPO_LINUX="Taiko2k/Tauon"
REPO_MAC="Taiko2k/Tauon"
for file in "$ARTIFACTS_DIR"/*.zip; do
filename=$(basename "$file")
REPO=""
# Determine repository based on file name
if [[ "$filename" == *"windows"* ]]; then
REPO=$REPO_WINDOWS
elif [[ "$filename" == *"linux"* ]]; then
REPO=$REPO_LINUX
elif [[ "$filename" == *"macos"* ]]; then
REPO=$REPO_MAC
fi
# If REPO is empty, skip file
if [[ -z "$REPO" ]]; then
echo "No matching repository for $filename"
continue
fi
# Check if release already exists and get ID
release_id=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$REPO/releases/tags/Pre-release-Tauon-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}" | jq -r '.id')
if [[ "$release_id" == "null" ]]; then
echo "Creating release in $REPO for $filename"
release_id=$(curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
-d '{
"tag_name": "Pre-release-Tauon-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}",
"name": "Pre-release-Tauon-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}",
"draft": false,
"prerelease": true,
"body": "Commit: [${{ needs.get-info.outputs.fullhash }}](https://github.com/Taiko2k/Tauon/commit/${{ needs.get-info.outputs.fullhash }})"
}' "https://api.github.com/repos/$REPO/releases" | jq -r '.id')
else
echo "Release already exists in $REPO with ID $release_id"
fi
# Artifact upload
echo "Uploading $filename to release $release_id in $REPO"
upload_url="https://uploads.github.com/repos/$REPO/releases/$release_id/assets?name=$filename"
curl -X POST -H "Authorization: token $GITHUB_TOKEN" -H "Content-Type: application/octet-stream" --data-binary @"$file" "$upload_url"
done
- name: Get current pre-release information
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
api_url="https://api.github.com/repos/${{ github.repository }}/releases"
# Get all releases (sorted by date)
releases=$(curl -H "Authorization: token $GITHUB_TOKEN" "$api_url")
# Capture the most recent pre-release (assuming the first one is the latest)
current_release=$(echo "$releases" | jq -c '.[] | select(.prerelease == true) | .published_at' | sort -r | head -n 1)
# Remove extra quotes from captured date
current_release=$(echo $current_release | tr -d '"')
# Export the current published_at to be available for the next step
echo "CURRENT_PUBLISHED_AT=$current_release" >> $GITHUB_ENV
- name: Delete old pre-releases and tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
api_url="https://api.github.com/repos/${{ github.repository }}/releases"
# Get current pre-releases
releases=$(curl -H "Authorization: token $GITHUB_TOKEN" "$api_url")
# Remove extra quotes from captured date
CURRENT_PUBLISHED_AT=$(echo $CURRENT_PUBLISHED_AT | tr -d '"')
# Convert CURRENT_PUBLISHED_AT para timestamp Unix
current_published_ts=$(date -d "$CURRENT_PUBLISHED_AT" +%s)
# Identify pre-releases
echo "$releases" | jq -c '.[] | select(.prerelease == true)' | while read -r release; do
release_date=$(echo "$release" | jq -r '.published_at')
release_id=$(echo "$release" | jq -r '.id')
release_tag=$(echo "$release" | jq -r '.tag_name')
# Remove extra quotes from captured date
release_date=$(echo $release_date | tr -d '"')
# Convert release_date para timestamp Unix
release_date_ts=$(date -d "$release_date" +%s)
# Compare timestamps and delete old pre-releases
if [[ "$release_date_ts" -lt "$current_published_ts" ]]; then
echo "Deleting old pre-release: $release_id from $release_date with tag: $release_tag"
# Delete the pre-release
curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" "$api_url/$release_id"
# Delete the tag
curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/${{ github.repository }}/git/refs/tags/$release_tag"
else
echo "Skipping pre-release: $release_id (newer or same date)"
fi
done