-
Notifications
You must be signed in to change notification settings - Fork 0
504 lines (420 loc) · 15.8 KB
/
Copy pathbuild_release.yml
File metadata and controls
504 lines (420 loc) · 15.8 KB
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
name: Build Release
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
jobs:
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4.2.2
- uses: subosito/flutter-action@v2
with:
channel: "stable"
- name: Download arm64 FFmpeg
uses: dawidd6/action-download-artifact@v3
with:
workflow: build_ffmpeg.yml
name: ffmpeg-macos
path: macos/Runner/Resources/bin/
- name: Download arm64 Whisper
uses: dawidd6/action-download-artifact@v3
with:
workflow: build_whisper.yml
name: whisper-macos-arm64
path: macos/Runner/Resources/whisper/
- name: Download arm64 llama-server
uses: dawidd6/action-download-artifact@v3
with:
workflow: build_llamacpp.yml
name: llama-macos-arm64
path: macos/Runner/Resources/llama/
if_no_artifact_found: fail
- name: Build macOS (arm64 only)
run: |
flutter pub get
flutter build macos --release
- name: Create DMG
run: |
brew install create-dmg
create-dmg \
--volname "SubStitcher" \
--window-pos 200 120 \
--window-size 600 300 \
--icon-size 100 \
--app-drop-link 425 120 \
"SubStitcher-macOS-arm64.dmg" \
"build/macos/Build/Products/Release/SubStitcher.app"
- name: Upload macOS artifact
uses: actions/upload-artifact@v4.6.2
with:
name: macos-build
path: SubStitcher-macOS-arm64.dmg
build-linux-appimage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- uses: subosito/flutter-action@v2
with:
channel: "stable"
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libmpv-dev mpv
- name: Download Linux FFmpeg
uses: dawidd6/action-download-artifact@v3
with:
workflow: build_ffmpeg.yml
name: ffmpeg-linux
path: temp-bin/
- name: Download Linux Whisper
uses: dawidd6/action-download-artifact@v3
with:
workflow: build_whisper.yml
name: whisper-linux
path: temp-whisper/
- name: Download Linux llama-server
uses: dawidd6/action-download-artifact@v3
with:
workflow: build_llamacpp.yml
name: llama-linux-x64
path: temp-llama/
- name: Download Linux DeepFilter
uses: dawidd6/action-download-artifact@v3
with:
workflow: build_deepfilter.yml
name: deepfilter-linux-x64
path: temp-deepfilter/
if_no_artifact_found: fail
- name: Build Linux
run: |
flutter pub get
flutter build linux --release
mkdir -p build/linux/x64/release/bundle/bin
mkdir -p build/linux/x64/release/bundle/whisper
mkdir -p build/linux/x64/release/bundle/llama
mkdir -p build/linux/x64/release/bundle/deepfilter
cp temp-bin/* build/linux/x64/release/bundle/bin/
cp temp-whisper/* build/linux/x64/release/bundle/whisper/
cp temp-llama/* build/linux/x64/release/bundle/llama/
cp temp-deepfilter/* build/linux/x64/release/bundle/deepfilter/
chmod +x build/linux/x64/release/bundle/bin/*
chmod +x build/linux/x64/release/bundle/whisper/*
chmod +x build/linux/x64/release/bundle/llama/*
chmod +x build/linux/x64/release/bundle/deepfilter/deep-filter
- name: Create AppImage
run: |
chmod +x scripts/build_appimage.sh
./scripts/build_appimage.sh
- name: Upload Linux AppImage artifact
uses: actions/upload-artifact@v4.6.2
with:
name: linux-appimage-build
path: substitcher-*.AppImage
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4.2.2
- uses: subosito/flutter-action@v2
with:
channel: "stable"
- name: Download Windows FFmpeg
uses: dawidd6/action-download-artifact@v3
with:
workflow: build_ffmpeg.yml
name: ffmpeg-windows
path: temp-bin/
- name: Download Windows Whisper
uses: dawidd6/action-download-artifact@v3
with:
workflow: build_whisper.yml
name: whisper-windows
path: temp-whisper/
- name: Download Windows llama-server
uses: dawidd6/action-download-artifact@v3
with:
workflow: build_llamacpp.yml
name: llama-windows-x64
path: temp-llama/
- name: Download Windows DeepFilter
uses: dawidd6/action-download-artifact@v3
with:
workflow: build_deepfilter.yml
name: deepfilter-windows-x64
path: temp-deepfilter/
if_no_artifact_found: fail
- name: Build Windows
run: |
flutter pub get
flutter build windows --release
- name: Copy binaries to build output
shell: powershell
run: |
New-Item -ItemType Directory -Force -Path build\windows\x64\runner\Release\bin
New-Item -ItemType Directory -Force -Path build\windows\x64\runner\Release\whisper
New-Item -ItemType Directory -Force -Path build\windows\x64\runner\Release\llama
New-Item -ItemType Directory -Force -Path build\windows\x64\runner\Release\deepfilter
Copy-Item temp-bin\* build\windows\x64\runner\Release\bin\
Copy-Item temp-whisper\* build\windows\x64\runner\Release\whisper\
Copy-Item temp-llama\* build\windows\x64\runner\Release\llama\
Copy-Item temp-deepfilter\* build\windows\x64\runner\Release\deepfilter\
- name: Create ZIP
run: |
Compress-Archive -Path build\windows\x64\runner\Release\* -DestinationPath SubStitcher-Windows-x64.zip
- name: Upload Windows ZIP
uses: actions/upload-artifact@v4.6.2
with:
name: windows-build
path: SubStitcher-Windows-x64.zip
build-linux-flatpak:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- uses: subosito/flutter-action@v2
with:
channel: "stable"
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libmpv-dev mpv
- name: Install Flatpak dependencies
run: |
sudo apt-get install -y flatpak flatpak-builder
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
- name: Install Flatpak SDK
timeout-minutes: 15
run: |
if ! flatpak list | grep -q "org.freedesktop.Platform.*24.08"; then
sudo flatpak install -y flathub org.freedesktop.Platform//24.08
fi
if ! flatpak list | grep -q "org.freedesktop.Sdk.*24.08"; then
sudo flatpak install -y flathub org.freedesktop.Sdk//24.08
fi
- name: Download Linux FFmpeg
uses: dawidd6/action-download-artifact@v3
with:
workflow: build_ffmpeg.yml
name: ffmpeg-linux
path: temp-bin/
- name: Download Linux Whisper
uses: dawidd6/action-download-artifact@v3
with:
workflow: build_whisper.yml
name: whisper-linux
path: temp-whisper/
- name: Download Linux llama-server
uses: dawidd6/action-download-artifact@v3
with:
workflow: build_llamacpp.yml
name: llama-linux-x64
path: temp-llama/
- name: Download Linux DeepFilter
uses: dawidd6/action-download-artifact@v3
with:
workflow: build_deepfilter.yml
name: deepfilter-linux-x64
path: temp-deepfilter/
- name: Build Linux
run: |
flutter pub get
flutter build linux --release
mkdir -p build/linux/x64/release/bundle/bin
mkdir -p build/linux/x64/release/bundle/whisper
mkdir -p build/linux/x64/release/bundle/llama
mkdir -p build/linux/x64/release/bundle/deepfilter
cp temp-bin/* build/linux/x64/release/bundle/bin/
cp temp-whisper/* build/linux/x64/release/bundle/whisper/
cp temp-llama/* build/linux/x64/release/bundle/llama/
cp temp-deepfilter/* build/linux/x64/release/bundle/deepfilter/
chmod +x build/linux/x64/release/bundle/bin/*
chmod +x build/linux/x64/release/bundle/whisper/*
chmod +x build/linux/x64/release/bundle/llama/*
chmod +x build/linux/x64/release/bundle/deepfilter/deep-filter
- name: Build Flatpak
run: |
chmod +x scripts/build_flatpak.sh
./scripts/build_flatpak.sh
- name: Upload Linux Flatpak artifact
uses: actions/upload-artifact@v4.6.2
with:
name: linux-flatpak-build
path: substitcher-x64.flatpak
build-android:
runs-on: ubuntu-latest
timeout-minutes: 30
env:
PUB_CACHE: ${{ github.workspace }}/.pub-cache
FLUTTER_DISABLE_FILE_WATCHER: true
steps:
- uses: actions/checkout@v4.2.2
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
cache: gradle
- name: Install Android SDK with CMake
uses: android-actions/setup-android@v3
with:
packages: "platform-tools platforms;android-34 build-tools;34.0.0 cmake;3.22.1"
accept-android-sdk-licenses: true
- uses: subosito/flutter-action@v2
with:
channel: "stable"
cache: true
- name: Download Android FFmpeg
uses: dawidd6/action-download-artifact@v3
with:
workflow: build_ffmpeg.yml
name: ffmpeg-android
path: temp-android-bin/
- name: Copy Android native libraries
run: |
mkdir -p android/app/src/main/jniLibs/arm64-v8a
cp temp-android-bin/arm64-v8a/ffmpeg android/app/src/main/jniLibs/arm64-v8a/libffmpeg.so
cp temp-android-bin/arm64-v8a/ffprobe android/app/src/main/jniLibs/arm64-v8a/libffprobe.so
- name: Get dependencies
run: flutter pub get
- name: Build Android APK
run: flutter build apk --release --target-platform android-arm64
- name: Rename APK
run: |
mv build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/substitcher-android-arm64.apk
- name: Upload Android APK
uses: actions/upload-artifact@v4.6.2
with:
name: android-build
path: build/app/outputs/flutter-apk/substitcher-android-arm64.apk
create-release:
needs:
[
build-macos,
build-windows,
build-linux-appimage,
build-linux-flatpak,
build-android,
]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: |
macos-build/SubStitcher-macOS-arm64.dmg
linux-appimage-build/substitcher-*.AppImage
linux-flatpak-build/substitcher-x64.flatpak
windows-build/SubStitcher-Windows-x64.zip
android-build/substitcher-android-arm64.apk
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update-aur:
name: Update AUR Package
needs: [create-release]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- name: Extract version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Download AppImage artifact
uses: actions/download-artifact@v4
with:
name: linux-appimage-build
path: artifacts
- name: Calculate SHA256
id: sha
run: |
cd artifacts
SHA256=$(sha256sum substitcher-x64.AppImage | cut -d' ' -f1)
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
- name: Update AUR package
env:
AUR_SSH_KEY: ${{ secrets.AUR_SSH_KEY }}
run: |
VERSION="${{ steps.version.outputs.version }}"
SHA256="${{ steps.sha.outputs.sha256 }}"
mkdir -p ~/.ssh
echo "$AUR_SSH_KEY" > ~/.ssh/aur
chmod 600 ~/.ssh/aur
ssh-keyscan -H aur.archlinux.org >> ~/.ssh/known_hosts
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
GIT_SSH_COMMAND="ssh -i ~/.ssh/aur" git clone ssh://aur@aur.archlinux.org/substitcher-bin.git aur-repo
cd aur-repo
sed -i "s/^pkgver=.*/pkgver=${VERSION}/" PKGBUILD
sed -i "s/^sha256sums=.*/sha256sums=('${SHA256}')/" PKGBUILD
docker run --rm -v $(pwd):/pkg archlinux bash -c "
pacman -Sy --noconfirm pacman-contrib sudo fakeroot &&
useradd -m builder &&
chown -R builder:builder /pkg &&
su builder -c 'cd /pkg && makepkg --printsrcinfo > .SRCINFO'
"
sudo chown -R $(whoami):$(whoami) .
git add PKGBUILD .SRCINFO
git commit -m "Update to version ${VERSION}"
GIT_SSH_COMMAND="ssh -i ~/.ssh/aur" git push
update-homebrew:
name: Update Homebrew Tap
needs: [create-release]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- name: Extract version from pubspec.yaml
id: version
run: |
VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //')
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Download DMG artifact
uses: actions/download-artifact@v4
with:
name: macos-build
path: artifacts
- name: Calculate SHA256
id: sha
run: |
cd artifacts
SHA256=$(shasum -a 256 SubStitcher-macOS-arm64.dmg | cut -d' ' -f1)
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
- name: Update Homebrew cask
env:
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
VERSION="${{ steps.version.outputs.version }}"
SHA256="${{ steps.sha.outputs.sha256 }}"
git clone https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/mrfragger/homebrew-substitcher.git
cd homebrew-substitcher
mkdir -p Casks
cat > Casks/substitcher.rb << 'EOF'
cask "substitcher" do
version "VERSION_PLACEHOLDER"
sha256 "SHA_PLACEHOLDER"
url "https://github.com/mrfragger/substitcher/releases/download/vVERSION_PLACEHOLDER/SubStitcher-macOS-arm64.dmg"
name "SubStitcher"
desc "Audiobook encoder and player with subtitle support"
homepage "https://github.com/mrfragger/substitcher"
app "SubStitcher.app"
zap trash: [
"~/Library/Preferences/com.substitcher.app.plist",
"~/Library/Application Support/substitcher",
]
end
EOF
sed -i "s/VERSION_PLACEHOLDER/${VERSION}/g" Casks/substitcher.rb
sed -i "s/SHA_PLACEHOLDER/${SHA256}/g" Casks/substitcher.rb
rm -f Formula/substitcher.rb
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Casks/substitcher.rb
git add Formula/ || true
git diff --staged --quiet || git commit -m "substitcher ${VERSION}"
git push