forked from Vito0912/abs_flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
460 lines (387 loc) · 15.8 KB
/
build.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
name: Flutter Build
on:
workflow_dispatch:
push:
branches-ignore:
- main
paths:
- 'lib/**'
env:
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
STORE_FILE: '../keystore.jks'
jobs:
update_version:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Update version in pubspec.yaml
run: |
# Read the current version from pubspec.yaml
VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //;s/+.*//')
echo "Current Version: $VERSION"
# Split the version into major, minor, and patch components
IFS='.' read -r major minor patch <<< "$VERSION"
# Check if the patch version is 9
if [ "$patch" -eq 9 ]; then
# If yes, increment the minor version and reset the patch version to 0
new_minor=$((minor + 1))
new_version="$major.$new_minor.0"
else
# Otherwise, simply increment the patch version
new_patch=$((patch + 1))
new_version="$major.$minor.$new_patch"
fi
echo "New Version: $new_version"
# Update pubspec.yaml with the new version
sed -i "s/^version: .*/version: $new_version/" pubspec.yaml
# Update msix_version in the msix_config section
msix_version="$new_version.0"
sed -i "s/msix_version: .*/msix_version: $msix_version/" pubspec.yaml
# Indicate that the versions have been updated
echo "The version in pubspec.yaml has been updated to $new_version and msix_version to $msix_version."
- name: Commit changes
if: github.ref == 'refs/heads/main'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add pubspec.yaml
git commit -m "Update version to $new_version"
git push
build-ubuntu:
runs-on: ubuntu-latest
needs: [update_version]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y wget curl xz-utils git>=2.0 bash unzip bash zip
- name: Install Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Install jq
run: |
wget -O jq https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-amd64
chmod +x ./jq
mv jq /usr/local/bin
- name: Install Android SDK Command Line Tools
run: |
wget https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -O commandlinetools.zip
mkdir -p $HOME/android-sdk/cmdline-tools/latest
unzip commandlinetools.zip -d $HOME/android-sdk/cmdline-tools/latest
mv $HOME/android-sdk/cmdline-tools/latest/cmdline-tools/* $HOME/android-sdk/cmdline-tools/latest/
export ANDROID_HOME=$HOME/android-sdk
echo "ANDROID_HOME=$ANDROID_HOME" >> $GITHUB_ENV
export PATH=$ANDROID_HOME/cmdline-tools/latest/bin:$PATH
echo "PATH=$PATH" >> $GITHUB_ENV
- name: Accept Android SDK Licenses
run: |
yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses || true
- name: Install Android SDK Packages
run: |
yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "platform-tools" "platforms;android-33" "build-tools;33.0.2" || true
- name: Add exception
run: git config --global --add safe.directory /opt/hostedtoolcache/flutter/*
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.27.1
- name: Install Flutter dependencies
run: flutter pub get
- name: Build Flutter web
run: flutter build web --release
- name: Zip the web directory
run: |
zip -r web-release.zip build/web/
- name: Change base href for GitHub Pages
run: |
sed -i 's|<base href="/">|<base href="/abs_flutter/">|' build/web/index.html
- name: upload page artifact
uses: actions/upload-pages-artifact@v3
with:
path: build/web
- name: Setup Keystore
run: echo "${{ secrets.STORE }}" | base64 -d > android/keystore.jks
- name: Build APK
run: flutter build apk --release
- name: Build AppBundle
run: flutter build appbundle --release
- name: Move APK and AAB files
run: |
mv build/app/outputs/flutter-apk/app-release.apk app-release.apk
mv build/app/outputs/bundle/release/app-release.aab app-release.aab
- name: Upload APK, AAB, and Web Artifacts
uses: actions/upload-artifact@v4
with:
name: ubuntu-build-artifacts
path: |
app-release.apk
app-release.aab
web-release.zip
- name: Upload single APK file
uses: actions/upload-artifact@v4
with:
name: android-apk
path: app-release.apk
- name: Clean up
if: always()
run: |
sudo rm -rf build
sudo rm -rf android/keystore.jks
build-windows:
runs-on: windows-latest
needs: [update_version]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.27.1
- name: Extract version from pubspec.yaml
id: extract_version
shell: pwsh
run: |
$versionLine = Get-Content pubspec.yaml | Select-String -Pattern '^version:'
$version = $versionLine -replace 'version: ', '' -replace '\+.*', ''
echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Install Flutter dependencies
run: flutter pub get
- name: Build Flutter Windows
run: flutter build windows --release
- name: Zip the Release folder
run: |
Compress-Archive -Path "build/windows/x64/runner/Release" -DestinationPath "windows-Release-${{ env.VERSION }}.zip"
- name: Create MSIX package
run: dart run msix:create
- name: Move MSIX file
run: |
$sourcePath = "build/windows/x64/runner/Release/abs_flutter.msix"
$destinationPath = "windows-installer-release-${{ env.VERSION }}.msix"
Move-Item -Path $sourcePath -Destination $destinationPath
shell: pwsh
- name: Create MSIX package (Store)
run: dart run msix:create --store
- name: Move MSIX file
run: |
$sourcePath = "build/windows/x64/runner/Release/abs_flutter.msix"
$destinationPath = "windows-installer-release-${{ env.VERSION }}-store.msix"
Move-Item -Path $sourcePath -Destination $destinationPath
shell: pwsh
- name: Upload Windows Build and MSIX Artifacts
uses: actions/upload-artifact@v4
with:
name: windows-build-artifacts
path: |
windows-Release-${{ env.VERSION }}.zip
windows-installer-release-${{ env.VERSION }}.msix
windows-installer-release-${{ env.VERSION }}-store.msix
- name: Upload single MSIX file
uses: actions/upload-artifact@v4
with:
name: windows-msix
path: windows-installer-release-${{ env.VERSION }}.msix
- name: Upload single MSIX file
uses: actions/upload-artifact@v4
with:
name: windows-zip
path: windows-Release-${{ env.VERSION }}.zip
build-linux:
runs-on: ubuntu-latest
needs: [update_version]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.27.1
- name: Install Flutter dependencies
run: flutter pub get
- name: Install linux dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y curl git unzip xz-utils zip libglu1-mesa
sudo apt-get install -y libayatana-appindicator3-dev
sudo apt-get install -y ffmpeg libavcodec-dev libavformat-dev libavutil-dev libswresample-dev
sudo apt-get install -y libmpv-dev mpv
sudo apt-get install -y clang cmake git ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev
sudo apt-get install -y fuse libfuse2
sudo apt-get install -y libsecret-1-dev xdg-user-dirs
sudo modprobe fuse
sudo groupadd fuse || true
sudo usermod -a -G fuse $USER
- name: Build Flutter linux
run: flutter build linux --release
- name: Zip the linux build directory
run: |
cd build/linux/x64/release/bundle
zip -r linux-release.zip .
mv linux-release.zip ../../../../../
cd ../../../../../
- name: Extract version from pubspec.yaml
id: extract_version
run: |
VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //;s/+.*//')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Download AppImage builder
run: |
wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O appimagetool
chmod +x appimagetool
- name: Prepare AppDir
run: |
mkdir -p AppDir/usr/bin
mkdir -p AppDir/usr/share/applications
mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps
mkdir -p AppDir/usr/lib
cp -r build/linux/x64/release/bundle/* AppDir/usr/bin/
cp /usr/lib/x86_64-linux-gnu/libsecret-1.so* AppDir/usr/lib/ || true
cp assets/images/logo/logo_blue_big_abs.png AppDir/usr/share/icons/hicolor/256x256/apps/io.github.vito0912.abs_flutter.png
cp assets/images/logo/logo_blue_big_abs.png AppDir/io.github.vito0912.abs_flutter.png
cat > AppDir/io.github.vito0912.abs_flutter.desktop << EOL
[Desktop Entry]
Name=Buchable
Comment=Enjoy hearing self-hosted audiobooks.
Exec=buchable
Type=Application
Icon=io.github.vito0912.abs_flutter.png
Terminal=false
Keywords=Audiobook,Player,Audiobookshelf,Listen;
Categories=Audio;AudioVideo;Player;
MimeType=audio/*;video/*;
X-GNOME-UsesNotifications=true
StartupWMClass=buchable
EOL
cp AppDir/io.github.vito0912.abs_flutter.desktop AppDir/usr/share/applications/
cat > AppDir/AppRun << EOL
#!/bin/sh
SELF=\$(readlink -f "\$0")
HERE=\${SELF%/*}
export PATH="\${HERE}/usr/bin:\${PATH}"
export LD_LIBRARY_PATH="\${HERE}/usr/lib:\${LD_LIBRARY_PATH}"
export XDG_DATA_DIRS="\${HERE}/usr/share:\${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
export XDG_CONFIG_DIRS="\${HERE}/etc/xdg:\${XDG_CONFIG_DIRS:-/etc/xdg}"
exec "\${HERE}/usr/bin/abs_flutter" "\$@"
EOL
chmod +x AppDir/AppRun
- name: Build AppImage
run: |
# Extract appimagetool first to avoid FUSE requirement
./appimagetool --appimage-extract
ARCH=x86_64 ./squashfs-root/AppRun AppDir buchable-${{ env.VERSION }}-x86_64.AppImage
- name: Upload Linux build artifacts
uses: actions/upload-artifact@v4
with:
name: linux-build-artifacts
path: |
linux-release.zip
buchable-${{ env.VERSION }}-x86_64.AppImage
create-release:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch'
needs: [build-ubuntu, build-windows, build-linux]
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download Ubuntu Artifacts
uses: actions/download-artifact@v4
with:
name: ubuntu-build-artifacts
path: ./ubuntu-artifacts
- name: Download Windows Artifacts
uses: actions/download-artifact@v4
with:
name: windows-build-artifacts
path: ./windows-artifacts
- name: Download Linux Artifacts
uses: actions/download-artifact@v4
with:
name: linux-build-artifacts
path: ./linux-artifacts
- name: Extract version from pubspec.yaml
id: extract_version
run: |
VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //;s/+.*//')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Rename app-release.apk
run: |
mv ubuntu-artifacts/app-release.apk ubuntu-artifacts/android-release-${{ env.VERSION }}.apk
mv ubuntu-artifacts/app-release.aab ubuntu-artifacts/android-release-${{ env.VERSION }}.aab
mv ubuntu-artifacts/web-release.zip ubuntu-artifacts/web-release-${{ env.VERSION }}.zip
mv linux-artifacts/linux-release.zip linux-artifacts/linux-release.zip
mv linux-artifacts/buchable-${{ env.VERSION }}-x86_64.AppImage linux-artifacts/buchable-${{ env.VERSION }}-x86_64.AppImage || true
- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.VERSION }}
name: Release v${{ env.VERSION }}
draft: false
generate_release_notes: true
prerelease: true
files: |
ubuntu-artifacts/android-release-${{ env.VERSION }}.apk
ubuntu-artifacts/android-release-${{ env.VERSION }}.aab
ubuntu-artifacts/web-release-${{ env.VERSION }}.zip
windows-artifacts/windows-Release-${{ env.VERSION }}.zip
windows-artifacts/windows-installer-release-${{ env.VERSION }}.msix
windows-artifacts/windows-installer-release-${{ env.VERSION }}-store.msix
linux-artifacts/linux-release.zip
linux-artifacts/buchable-${{ env.VERSION }}-x86_64.AppImage
publish-release:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch'
needs: [create-release]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download Ubuntu Artifacts
uses: actions/download-artifact@v4
with:
name: ubuntu-build-artifacts
path: ./ubuntu-build-artifacts
- name: Move AAB file
run: |
mv ubuntu-build-artifacts/app-release.aab app-release.aab
- name: Extract version from pubspec.yaml
id: extract_version
run: |
VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //;s/+.*//')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Publish to Play Store
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
packageName: de.vito.absapp.abs_flutter
releaseFiles: app-release.aab
track: beta
status: completed
releaseName: v${{ env.VERSION }}
inAppUpdatePriority: 2
whatsNewDirectory: android/whatsnew
continue-on-error: true
deploy:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch'
needs: build-ubuntu
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
pages: write
id-token: write
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4