forked from jellyflix-app/jellyflix
-
Notifications
You must be signed in to change notification settings - Fork 0
611 lines (506 loc) · 19.1 KB
/
deploy.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
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
name: Deploy
on:
push:
branches:
- stable
- preview
paths-ignore:
- "README.md"
- "LICENSE"
- "CONTRIBUTING.md"
- "CODE_OF_CONDUCT.md"
jobs:
version:
name: Create version number
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch all history for all tags and branches
run: |
git config remote.origin.url https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git fetch --prune --depth=10000
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v1
with:
versionSpec: "5.x"
- name: Use GitVersion
id: gitversion
uses: gittools/actions/gitversion/execute@v1
- name: Create version.txt with nuGetVersion
run: echo ${{ steps.gitversion.outputs.nuGetVersion }} > version.txt
- name: Upload version.txt
uses: actions/upload-artifact@v4
with:
name: gitversion
path: version.txt
build_web:
name: Create Web Build
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Setup java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: "12.x"
cache: gradle
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- name: Get dependencies
run: flutter pub get
- name: Start Web Release Build
run: flutter build web --release
- name: Upload Web Build Files
uses: actions/upload-artifact@v4
with:
name: web-release
path: ./build/web
deploy_web:
name: Deploy Web Build
needs: build_web
runs-on: ubuntu-latest
steps:
- name: Download Web Release
uses: actions/download-artifact@v4
with:
name: web-release
- name: Deploy to gh-pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./
cname: jellyflix.kiejon.com
build_android:
name: Build Android
needs: [version]
runs-on: ubuntu-latest
steps:
- name: Clone Repo
uses: actions/checkout@v4
- name: Get version.txt
uses: actions/download-artifact@v4
with:
name: gitversion
- name: Create new file without newline char from version.txt
run: tr -d '\n' < version.txt > version1.txt
- name: Read version
id: version
uses: juliangruber/read-file-action@v1
with:
path: version1.txt
- name: Update version in YAML
run: sed -i 's/00.00.00+0/${{ steps.version.outputs.content }}+${{ github.run_number }}/g' pubspec.yaml
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '12.x'
cache: gradle
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- name: Run Pub get
run: flutter pub get
- name: Download Android keystore
id: android_keystore
uses: timheuer/base64-to-file@v1
with:
fileName: ${{ secrets.ANDROID_KEY_ALIAS }}
encodedString: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
- name: Create key.properties
run: |
echo "storeFile=${{ steps.android_keystore.outputs.filePath }}" > android/key.properties
echo "storePassword=${{ secrets.ANDROID_KEYSTORE_PASSWORD }}" >> android/key.properties
echo "keyPassword=${{ secrets.ANDROID_KEY_PASSWORD }}" >> android/key.properties
echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" >> android/key.properties
- name: Build apk
run: flutter build apk --release --dart-define=ENCRYPTION_KEY=${{ secrets.ENCRYPTION_KEY }}
- name: Build Android App Bundle
run: flutter build appbundle --release --dart-define=ENCRYPTION_KEY=${{ secrets.ENCRYPTION_KEY }}
- name: Rename APK
run: mv build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/jellyflix.apk
- name: Upload apk
uses: actions/upload-artifact@v4
with:
name: jellyflix-apk
path: build/app/outputs/flutter-apk/jellyflix.apk
- name: Upload app bundle
uses: actions/upload-artifact@v4
with:
name: jellyflix-appbundle
path: build/app/outputs/bundle/release/app-release.aab
build_ios:
needs: [version]
name: Build iOS
runs-on: macos-14
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.6.10'
bundler-cache: true
working-directory: 'ios'
- name: Get version.txt
uses: actions/download-artifact@v4
with:
name: gitversion
- name: Create new file without newline char from version.txt
run: tr -d '\n' < version.txt > version1.txt
- name: Read version
id: version
uses: juliangruber/read-file-action@v1
with:
path: version1.txt
- name: Update version in YAML
run: sed -i '' 's/00.00.00+0/${{ steps.version.outputs.content }}+${{ github.run_number }}/g' pubspec.yaml
- name: Create release notes
uses: johnyherangi/create-release-notes@v1
if: ${{ github.ref == 'refs/heads/stable' }}
id: create-release-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- name: Install packages
run: flutter pub get
- name: Install Cocoapods
working-directory: ios
run: pod install
- name: Install Fastlane
working-directory: ios
run: bundle install
- name: Setup SSH Keys and known_hosts for Fastlane Match
env:
PRIVATE_KEY: ${{ secrets.MATCH_SSH_PRIVATE_KEY }}
run: |
mkdir -p ~/.ssh && touch ~/.ssh/known_hosts
echo "$PRIVATE_KEY" > ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts
chmod 600 ~/.ssh/known_hosts ~/.ssh/id_rsa
eval $(ssh-agent) && ssh-add ~/.ssh/id_rsa
- name: Save base64 encoded p8 cert
working-directory: ios
run: echo ${{ secrets.APPSTORE_CONNECT_API_KEY }} | base64 --decode > AuthKey_${{ secrets.APPSTORE_CONNECT_KEY_ID }}.p8
- name: Add Credentials / Keys, Build and Upload to TestFlight
working-directory: ios
env:
TEAM_ID: ${{ secrets.TEAM_ID }}
ITC_TEAM_ID: ${{ secrets.ITC_TEAM_ID }}
MATCH_GIT_URL: ${{ secrets.MATCH_GIT_URL }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
APP_STORE_CONNECT_KEY_ID: ${{ secrets.APPSTORE_CONNECT_KEY_ID }}
APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.APPSTORE_CONNECT_ISSUER_ID }}
APP_STORE_CONNECT_FILE_PATH: "./AuthKey_${{ secrets.APPSTORE_CONNECT_KEY_ID }}.p8"
RELEASE_NOTES: ${{ steps.create-release-notes.outputs.release-notes }}
run: |
sed -i "" "s/TEAM_ID/$TEAM_ID/g" ./Runner/ExportOptions.plist
sed -i "" "s/SENSITIVE_REPLACE_ME/$TEAM_ID/g" ./Runner.xcodeproj/project.pbxproj
bundle exec fastlane setup
bundle exec fastlane beta
# Collect the file and upload as artifact
- name: collect ipa artifacts
uses: actions/upload-artifact@v2
with:
name: jellyflix-ipa
# Path to the release files
path: ios/*.ipa
build_macos:
name: Build macOS
needs: [version]
runs-on: macos-14
steps:
- name: Clone Repo
uses: actions/checkout@v4
# Install the Apple certificate and provisioning profile
- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.DEVELOPERID_CERT_BASE64 }}
P12_PASSWORD: ${{ secrets.DEVELOPERID_CERT_PASSWORD }}
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.DEVELOPERID_MACPROVISION_BASE64 }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/build_pp.provisionprofile
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode --output $CERTIFICATE_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode --output $PP_PATH
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: Get version.txt
uses: actions/download-artifact@v4
with:
name: gitversion
- name: Create new file without newline char from version.txt
run: tr -d '\n' < version.txt > version1.txt
- name: Read version
id: version
uses: juliangruber/read-file-action@v1
with:
path: version1.txt
- name: Update version in YAML
run: sed -i '' 's/00.00.00+0/${{ steps.version.outputs.content }}+${{ github.run_number }}/g' pubspec.yaml
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- name: Run Pub get
run: flutter pub get
- name: replace sensitive data
working-directory: macos
env:
TEAM_ID: ${{ secrets.TEAM_ID }}
run: |
sed -i "" "s/SENSITIVE_REPLACE_ME/$TEAM_ID/g" ./Runner.xcodeproj/project.pbxproj
- name: Build macOS
run: flutter build macos --dart-define=ENCRYPTION_KEY=${{ secrets.ENCRYPTION_KEY }}
- name: Sign app
run: |
codesign --options=runtime --force --deep --sign ${{ secrets.DEVELOPERID_CERT_FINGERPRINT }} build/macos/Build/Products/Release/jellyflix.app
codesign --verify --verbose build/macos/Build/Products/Release/jellyflix.app
- name: Create a dmg
working-directory: build/macos/Build/Products/Release
run: |
echo "Install create-dmg"
brew install create-dmg
create-dmg \
--volname "Jellyflix" \
--window-pos 200 120 \
--window-size 800 529 \
--icon-size 130 \
--text-size 14 \
--icon "Jellyflix.app" 260 250 \
--hide-extension "Jellyflix.app" \
--app-drop-link 540 250 \
--hdiutil-quiet \
"Jellyflix.dmg" \
"Jellyflix.app"
- name: Sign .dmg
run: codesign --options=runtime --force --deep -s ${{ secrets.DEVELOPERID_CERT_FINGERPRINT }} build/macos/Build/Products/Release/jellyflix.dmg -v
# only important for selfhosted runners
- name: Clean up keychain and provisioning profile
if: ${{ always() }}
run: |
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
rm ~/Library/MobileDevice/Provisioning\ Profiles/build_pp.provisionprofile
- name: Save base64 encoded p8 cert
run: echo ${{ secrets.APPSTORE_CONNECT_API_KEY }} | base64 --decode > AuthKey_${{ secrets.APPSTORE_CONNECT_KEY_ID }}.p8
- name: Notarize
run: |
xcrun notarytool submit build/macos/Build/Products/Release/jellyflix.dmg -k AuthKey_${{ secrets.APPSTORE_CONNECT_KEY_ID }}.p8 -d ${{ secrets.APPSTORE_CONNECT_KEY_ID }} -i ${{ secrets.APPSTORE_CONNECT_ISSUER_ID }} --wait
- name: Staple
run: xcrun stapler staple build/macos/Build/Products/Release/jellyflix.dmg
- name: Verify notarization and staple
run: |
spctl --assess -vvv --type install build/macos/Build/Products/Release/jellyflix.dmg
xcrun stapler validate build/macos/Build/Products/Release/jellyflix.dmg
- name: Upload macOS
uses: actions/upload-artifact@v4
with:
name: jellyflix-macos
path: build/macos/Build/Products/Release/jellyflix.dmg
build_linux:
name: Build Linux
needs: [version]
runs-on: ubuntu-latest
steps:
- name: Clone Repo
uses: actions/checkout@v4
- name: Get version.txt
uses: actions/download-artifact@v4
with:
name: gitversion
- name: Create new file without newline char from version.txt
run: tr -d '\n' < version.txt > version1.txt
- name: Read version
id: version
uses: juliangruber/read-file-action@v1
with:
path: version1.txt
- name: Update version in YAML
run: sed -i 's/00.00.00+0/${{ steps.version.outputs.content }}+${{ github.run_number }}/g' pubspec.yaml
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '12.x'
cache: gradle
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- name: Setup build tools
run: |
sudo apt-get update -y
sudo apt-get install -y ninja-build libgtk-3-dev clang libmpv-dev mpv libsecret-1-dev libjsoncpp-dev
flutter doctor
- name: Run Pub get
run: flutter pub get
- name: Build Linux
run: flutter build linux --release --dart-define=ENCRYPTION_KEY=${{ secrets.ENCRYPTION_KEY }}
- name: Install zip
uses: montudor/action-zip@v1
- name: Zip Linux
run: zip -qq -r jellyflix-linux.zip .
working-directory: build/linux/x64/release/bundle
- name: Upload Linux
uses: actions/upload-artifact@v4
with:
name: jellyflix-linux
path: build/linux/x64/release/bundle/jellyflix-linux.zip
build_windows:
name: Build Windows
needs: [version]
runs-on: windows-latest
steps:
- name: Clone Repo
uses: actions/checkout@v4
- name: Git:Enable long paths
run: git config --system core.longpaths true
- name: Get version.txt
uses: actions/download-artifact@v4
with:
name: gitversion
- name: Create new file without newline char from version.txt
run: (Get-Content version.txt) -join '' | Set-Content version1.txt
shell: pwsh
- name: Read version
id: version
uses: juliangruber/read-file-action@v1
with:
path: version1.txt
- name: Update version in YAML
run: (Get-Content pubspec.yaml) -replace '00.00.00+0', "${{ steps.version.outputs.content }}+${{ github.run_number }}" | Set-Content pubspec.yaml
shell: pwsh
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '12.x'
cache: gradle
# fixes #278 https://github.com/subosito/flutter-action/issues/278
- name: Export pub environment variable on Windows
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
echo "PUB_CACHE=$LOCALAPPDATA\\Pub\\Cache" >> $GITHUB_ENV
fi
shell: bash
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- name: Run Pub get
run: flutter pub get
- name: Build Windows
run: flutter build windows --release --dart-define=ENCRYPTION_KEY=${{ secrets.ENCRYPTION_KEY }}
- name: Zip Windows
run: Compress-Archive -Path ./build/windows/x64/runner/Release/* -Destination jellyflix-windows.zip
- name: Upload Windows
uses: actions/upload-artifact@v4
with:
name: jellyflix-windows
path: jellyflix-windows.zip
create_release:
name: Create Release
needs: [build_android, build_linux, build_windows, build_macos]
runs-on: ubuntu-latest
steps:
- name: Clone Repo
uses: actions/checkout@v4
- name: Get version.txt
uses: actions/download-artifact@v4
with:
name: gitversion
- name: Create new file without newline char from version.txt
run: tr -d '\n' < version.txt > version1.txt
- name: Read version
id: version
uses: juliangruber/read-file-action@v1
with:
path: version1.txt
- name: Download Artifacts APK
uses: actions/download-artifact@v4
with:
name: jellyflix-apk
path: jellyflix-apk
- name: Download Artifacts Linux
uses: actions/download-artifact@v4
with:
name: jellyflix-linux
path: jellyflix-linux
- name: Download Artifacts Windows
uses: actions/download-artifact@v4
with:
name: jellyflix-windows
path: jellyflix-windows
- name: Download Artifacts Mac
uses: actions/download-artifact@v4
with:
name: jellyflix-macos
path: jellyflix-macos
- name: Create release notes
uses: johnyherangi/create-release-notes@v1
if: ${{ github.ref == 'refs/heads/stable' }}
id: create-release-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
with:
artifacts: "jellyflix-apk/*.apk,jellyflix-linux/*,jellyflix-windows/*,jellyflix-macos/*"
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.version.outputs.content }}
commit: ${{ github.sha }}
body: ${{ steps.create-release-notes.outputs.release-notes }}
prerelease: ${{ github.ref == 'refs/heads/preview' }}
release-play-store:
name: Release app to play store
needs: [build_android]
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Get appbundle from artifacts
uses: actions/download-artifact@v4
with:
name: jellyflix-appbundle
- name: Release app to open testing track
if: ${{ github.ref == 'refs/heads/preview' }}
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }}
packageName: ${{ secrets.ANDROID_PACKAGE_NAME }}
releaseFiles: app-release.aab
track: beta
status: draft
- name: Release app to production track
if: ${{ github.ref == 'refs/heads/stable' }}
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }}
packageName: ${{ secrets.ANDROID_PACKAGE_NAME }}
releaseFiles: app-release.aab
track: production
status: draft