-
-
Notifications
You must be signed in to change notification settings - Fork 75
865 lines (851 loc) · 37.2 KB
/
main.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
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
name: Test, Build, and Deploy with GameCI
on:
push:
branches:
- develop
paths:
- 'Assets/**'
- 'Packages/**'
- 'ProjectSettings/**'
pull_request:
types:
- opened
branches:
- main
paths:
- 'Assets/**'
- 'Packages/**'
- 'ProjectSettings/**'
release:
types:
- published
workflow_dispatch:
inputs:
workflow_mode:
description: '[release] [Android, iOS, StandaloneLinux64, WebGL, StandaloneWindows64, WSAPlayer, StandaloneOSX, Steam]'
required: false
default: ''
jobs:
tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Create LFS file list
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
- name: Restore LFS cache
uses: actions/cache@v3
id: lfs-cache
with:
path: .git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
- name: Git LFS Pull
run: |
git lfs pull
git add .
git reset --hard
- name: Cache Library
uses: actions/cache@v3
with:
path: Library
key: Library-test-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
restore-keys: Library-test-
- name: Run Unit Tests
uses: game-ci/unity-test-runner@main
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
testMode: playmode
githubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Update Release Notes
if: github.event.action == 'published'
env:
RELEASE_NOTES: ${{ github.event.release.body }}
run: |
echo "$RELEASE_NOTES" > fastlane/metadata/android/en-US/changelogs/default.txt
echo "$RELEASE_NOTES" > fastlane/metadata/en-US/release_notes.txt
- name: Auto-Commit Release Notes
if: github.event.action == 'published'
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: main
file_pattern: fastlane/metadata
commit_message: Update Release Notes (MINOR)
lint:
name: Quality Check
runs-on: ubuntu-latest
container: unityci/editor:ubuntu-2022.3.8f1-linux-il2cpp-2
steps:
- name: Checkout Repository
uses: actions/checkout@v1
with:
lfs: true
- name: Cache Library
uses: actions/cache@v3
with:
path: Library
key: Library-lint-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
restore-keys: Library-lint-
- name: Activate Unity
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
run: unity-editor -nographics -logFile /dev/stdout -quit -username "$UNITY_EMAIL" -password "$UNITY_PASSWORD" -serial "$UNITY_SERIAL"
- name: Generate Solution
run: unity-editor -nographics -logFile /dev/stdout -customBuildName Card-Game-Simulator -projectPath . -executeMethod Packages.Rider.Editor.RiderScriptEditor.SyncSolution -quit
- name: Return License
if: always()
run: unity-editor -logFile /dev/stdout -quit -returnlicense
- name: SonarQube Analysis
env:
FrameworkPathOverride: /opt/unity/Editor/Data/MonoBleedingEdge/
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sed -i 's/<ReferenceOutputAssembly>false<\/ReferenceOutputAssembly>/<ReferenceOutputAssembly>true<\/ReferenceOutputAssembly>/g' *.csproj
sed -i 's/\([A-Za-z0-9.-]\+csproj\)/Card-Game-Simulator\/&/g' Card-Game-Simulator.sln
mv Card-Game-Simulator.sln ..
cd ..
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
chmod +x ./dotnet-install.sh
./dotnet-install.sh --version latest
apt-get update
apt-get install -y openjdk-17-jre-headless
apt-get install -y dotnet-sdk-6.0
dotnet tool install dotnet-sonarscanner --tool-path .
./dotnet-sonarscanner begin \
/o:"finol-digital" \
/k:"finol-digital_Card-Game-Simulator" \
/d:sonar.login="$SONAR_TOKEN" \
/d:sonar.host.url=https://sonarcloud.io \
/d:sonar.exclusions=Assets/Plugins/**
dotnet build Card-Game-Simulator.sln
./dotnet-sonarscanner end /d:sonar.login="$SONAR_TOKEN"
cd Card-Game-Simulator
- name: SonarQube Quality Gate Check
uses: SonarSource/[email protected]
with:
scanMetadataReportFile: ../.sonarqube/out/.sonar/report-task.txt
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
buildWithLinux:
name: Build for ${{ matrix.targetPlatform }}
runs-on: ubuntu-latest
needs: [tests, lint]
strategy:
fail-fast: false
matrix:
targetPlatform:
- Android
- iOS
- StandaloneLinux64
- WebGL
outputs:
buildVersion: ${{ steps.build.outputs.buildVersion }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Create LFS file list
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
- name: Restore LFS cache
uses: actions/cache@v3
id: lfs-cache
with:
path: .git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
- name: Git LFS Pull
run: |
git lfs pull
git add .
git reset --hard
- name: Cache Library
uses: actions/cache@v3
with:
path: Library
key: Library-build-${{ matrix.targetPlatform }}-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
restore-keys: Library-build-${{ matrix.targetPlatform }}-
- name: Free Disk Space for Android
if: matrix.targetPlatform == 'Android'
uses: jlumbroso/[email protected]
with:
large-packages: false
- name: Build Unity Project
id: build
uses: game-ci/unity-builder@fix/android-tools
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
targetPlatform: ${{ matrix.targetPlatform }}
buildMethod: Cgs.Editor.BuildCgs.BuildOptions
androidExportType: androidAppBundle
androidKeystoreName: finoldigital.keystore
androidKeystoreBase64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
androidKeystorePass: ${{ secrets.ANDROID_KEYSTORE_PASS }}
androidKeyaliasName: cgs
androidKeyaliasPass: ${{ secrets.ANDROID_KEYALIAS_PASS }}
androidTargetSdkVersion: AndroidApiLevel33
- name: Upload Build
uses: actions/upload-artifact@v3
if: github.event.action == 'published' || contains(github.event.inputs.workflow_mode, matrix.targetPlatform) || (contains(github.event.inputs.workflow_mode, 'Steam') && matrix.targetPlatform == 'StandaloneLinux64')
with:
name: cgs-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
- name: Zip Build
uses: montudor/action-zip@v1
if: github.event.action == 'published' && matrix.targetPlatform == 'StandaloneLinux64'
with:
args: zip -qq -r build/cgs-${{ matrix.targetPlatform }}.zip build/${{ matrix.targetPlatform }}
- name: Upload Zip to GitHub Release
uses: svenstaro/upload-release-action@v2
if: github.event.action == 'published' && matrix.targetPlatform == 'StandaloneLinux64'
with:
repo_token: ${{ secrets.CGS_PAT }}
asset_name: cgs-${{ matrix.targetPlatform }}.zip
file: build/cgs-${{ matrix.targetPlatform }}.zip
tag: ${{ github.ref }}
overwrite: true
body: ${{ github.event.release.body }}
buildWithMac:
name: Build for StandaloneOSX
runs-on: macos-latest
needs: [tests, lint]
if: github.event.action == 'published' || contains(github.event.inputs.workflow_mode, 'release') || contains(github.event.inputs.workflow_mode, 'Steam') || contains(github.event.inputs.workflow_mode, 'Standalone')
outputs:
buildVersion: ${{ steps.build.outputs.buildVersion }}
timeout-minutes: 90
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Create LFS file list
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
- name: Restore LFS cache
uses: actions/cache@v3
id: lfs-cache
with:
path: .git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
- name: Git LFS Pull
run: |
git lfs pull
git add .
git reset --hard
- name: Cache Library
uses: actions/cache@v3
with:
path: Library
key: Library-buildMac-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
restore-keys: Library-buildMac-
- name: Build Unity Project
id: build
uses: game-ci/unity-builder@main
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
targetPlatform: StandaloneOSX
buildMethod: Cgs.Editor.BuildCgs.BuildOptions
cacheUnityInstallationOnMac: true
- name: Fix File Permissions and Code-Sign
env:
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
APPLE_TEAM_NAME: ${{ secrets.APPLE_TEAM_NAME }}
APPLE_DISTRIBUTION_CERTIFICATE: ${{ secrets.APPLE_DISTRIBUTION_CERTIFICATE }}
APPLE_DISTRIBUTION_PASSWORD: ${{ secrets.APPLE_DISTRIBUTION_PASSWORD }}
MAC_INSTALLER_CERTIFICATE: ${{ secrets.MAC_INSTALLER_CERTIFICATE }}
MAC_INSTALLER_PASSWORD: ${{ secrets.MAC_INSTALLER_PASSWORD }}
MAC_APP_BUNDLE_PATHS: Contents/PlugIns/StandaloneFileBrowser.bundle
MAC_BUILD_PATH: ${{ format('{0}/build/StandaloneOSX', github.workspace) }}
PROJECT_NAME: Card Game Simulator
run: |
bundle install
bundle exec fastlane mac fixversion
find $MAC_BUILD_PATH -type f -name "**.sh" -exec chmod +x {} \;
chmod +x fastlane/sign-mac-build.sh
./fastlane/sign-mac-build.sh
- name: Upload Build
if: github.event.action == 'published' || contains(github.event.inputs.workflow_mode, 'StandaloneOSX') || contains(github.event.inputs.workflow_mode, 'Steam')
uses: actions/upload-artifact@v3
with:
name: cgs-StandaloneOSX
path: build/StandaloneOSX
- name: Upload App
uses: actions/upload-artifact@v3
if: github.event.action == 'published' || contains(github.event.inputs.workflow_mode, 'StandaloneOSX') || contains(github.event.inputs.workflow_mode, 'Steam')
with:
name: Card Game Simulator.app
path: build/StandaloneOSX/Card Game Simulator.app
- name: Zip App
uses: vimtor/action-zip@v1
if: github.event.action == 'published'
with:
files: build/StandaloneOSX/
dest: build/cgs-StandaloneOSX.zip
- name: Upload Zip to GitHub Release
uses: svenstaro/upload-release-action@v2
if: github.event.action == 'published'
with:
repo_token: ${{ secrets.CGS_PAT }}
asset_name: cgs-StandaloneOSX.zip
file: build/cgs-StandaloneOSX.zip
tag: ${{ github.ref }}
overwrite: true
body: ${{ github.event.release.body }}
deployToAppStore:
name: Deploy to the App Store
runs-on: macos-latest
needs: buildWithLinux
if: github.event.action == 'published' || (contains(github.event.inputs.workflow_mode, 'release') && contains(github.event.inputs.workflow_mode, 'iOS'))
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Download iOS Artifact
uses: actions/download-artifact@v3
with:
name: cgs-iOS
path: build/iOS
- name: Update Release Notes
if: github.event.action == 'published'
env:
RELEASE_NOTES: ${{ github.event.release.body }}
run: echo "$RELEASE_NOTES" > fastlane/metadata/en-US/release_notes.txt
- name: Fix File Permissions and Run Fastlane
env:
APPLE_CONNECT_EMAIL: ${{ secrets.APPLE_CONNECT_EMAIL }}
APPLE_DEVELOPER_EMAIL: ${{ secrets.APPLE_DEVELOPER_EMAIL }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
APPLE_TEAM_NAME: ${{ secrets.APPLE_TEAM_NAME }}
MATCH_REPOSITORY: ${{ secrets.MATCH_REPOSITORY }}
MATCH_DEPLOY_KEY: ${{ secrets.MATCH_DEPLOY_KEY }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
MATCH_PERSONAL_ACCESS_TOKEN: ${{ secrets.CGS_PAT }}
APPSTORE_ISSUER_ID: ${{ secrets.APPSTORE_ISSUER_ID }}
APPSTORE_KEY_ID: ${{ secrets.APPSTORE_KEY_ID }}
APPSTORE_P8: ${{ secrets.APPSTORE_P8 }}
USYM_UPLOAD_AUTH_TOKEN: ${{ secrets.USYM_UPLOAD_AUTH_TOKEN }}
IOS_BUILD_PATH: ${{ format('{0}/build/iOS', github.workspace) }}
IOS_BUNDLE_ID: com.finoldigital.CardGameSim
PROJECT_NAME: Card Game Simulator
run: |
eval "$(ssh-agent -s)"
ssh-add - <<< "${MATCH_DEPLOY_KEY}"
find $IOS_BUILD_PATH -type f -name "**.sh" -exec chmod +x {} \;
find $IOS_BUILD_PATH -type f -iname "usymtool" -exec chmod +x {} \;
bundle install
bundle exec fastlane ios release
deployToGooglePlay:
name: Deploy to the Google Play Store
runs-on: ubuntu-latest
needs: buildWithLinux
if: github.event.action == 'published' || (contains(github.event.inputs.workflow_mode, 'release') && contains(github.event.inputs.workflow_mode, 'Android'))
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Download Android Artifact
uses: actions/download-artifact@v3
with:
name: cgs-Android
path: build/Android
- name: Update Release Notes
if: github.event.action == 'published'
env:
RELEASE_NOTES: ${{ github.event.release.body }}
run: echo "$RELEASE_NOTES" > fastlane/metadata/android/en-US/changelogs/default.txt
- name: Add Authentication
env:
GOOGLE_PLAY_KEY_FILE: ${{ secrets.GOOGLE_PLAY_KEY_FILE }}
GOOGLE_PLAY_KEY_FILE_PATH: ${{ format('{0}/fastlane/api-finoldigital.json', github.workspace) }}
run: echo "$GOOGLE_PLAY_KEY_FILE" > $GOOGLE_PLAY_KEY_FILE_PATH
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0
bundler-cache: true
- name: Upload to Google Play
env:
GOOGLE_PLAY_KEY_FILE_PATH: ${{ format('{0}/fastlane/api-finoldigital.json', github.workspace) }}
ANDROID_BUILD_FILE_PATH: ${{ format('{0}/build/Android/Android.aab', github.workspace) }}
ANDROID_PACKAGE_NAME: com.finoldigital.cardgamesim
uses: maierj/[email protected]
with:
lane: 'android playprod'
deployToFirebase:
name: Deploy to the Web via Firebase
runs-on: ubuntu-latest
needs: buildWithLinux
if: github.event.action == 'published' || (contains(github.event.inputs.workflow_mode, 'release') && contains(github.event.inputs.workflow_mode, 'WebGL'))
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
path: Card-Game-Simulator
- name: Download WebGL Artifact
uses: actions/download-artifact@v3
with:
name: cgs-WebGL
path: Card-Game-Simulator/build/WebGL
- name: Checkout Firebase project
uses: actions/checkout@v3
with:
repository: finol-digital/cgs-backend
token: ${{ secrets.CGS_PAT }}
path: cgs-backend
- name: Copy the WebGL build artifacts to the Firebase public directory
env:
UNITY_BUILD_WEBGL_PATH: ${{ format('{0}/Card-Game-Simulator/build/WebGL', github.workspace) }}
FIREBASE_PUBLIC_BUILD_PATH: ${{ format('{0}/cgs-backend/public/Build', github.workspace) }}
run: find $UNITY_BUILD_WEBGL_PATH -type f -name "**WebGL.*" -exec cp {} $FIREBASE_PUBLIC_BUILD_PATH \;
- name: Update Release Notes
if: github.event.action == 'published'
env:
RELEASE_NOTES: ${{ github.event.release.body }}
run: echo "$RELEASE_NOTES" > Card-Game-Simulator/fastlane/metadata/en-US/release_notes.txt
- name: Raise PR to backend
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.CGS_PAT }}
path: cgs-backend
branch: ${{ needs.buildWithLinux.outputs.buildVersion }}
title: ${{ needs.buildWithLinux.outputs.buildVersion }}
body-path: Card-Game-Simulator/fastlane/metadata/en-US/release_notes.txt
deployToMacAppStore:
name: Deploy to the Mac App Store
runs-on: macos-latest
needs: buildWithMac
if: github.event.action == 'published' || (contains(github.event.inputs.workflow_mode, 'release') && contains(github.event.inputs.workflow_mode, 'StandaloneOSX'))
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Download StandaloneOSX Artifact
uses: actions/download-artifact@v3
with:
name: cgs-StandaloneOSX
path: build/StandaloneOSX
- name: Update Release Notes
if: github.event.action == 'published'
env:
RELEASE_NOTES: ${{ github.event.release.body }}
run: echo "$RELEASE_NOTES" > fastlane/metadata/en-US/release_notes.txt
- name: Run Fastlane
env:
APPLE_CONNECT_EMAIL: ${{ secrets.APPLE_CONNECT_EMAIL }}
APPLE_DEVELOPER_EMAIL: ${{ secrets.APPLE_DEVELOPER_EMAIL }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
APPSTORE_ISSUER_ID: ${{ secrets.APPSTORE_ISSUER_ID }}
APPSTORE_KEY_ID: ${{ secrets.APPSTORE_KEY_ID }}
APPSTORE_P8: ${{ secrets. APPSTORE_P8 }}
MAC_BUILD_PATH: ${{ format('{0}/build/StandaloneOSX', github.workspace) }}
MAC_BUNDLE_ID: com.finoldigital.CardGameSimulator
PROJECT_NAME: Card Game Simulator
run: |
bundle install
bundle exec fastlane mac macupload
buildWithWindows:
name: Build for ${{ matrix.targetPlatform }}
runs-on: windows-2019
needs: [buildWithLinux, buildWithMac]
outputs:
buildVersion: ${{ steps.build-1.outputs.buildVersion }}
strategy:
fail-fast: false
matrix:
targetPlatform:
- StandaloneWindows
- StandaloneWindows64
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Create LFS file list
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
- name: Restore LFS cache
uses: actions/cache@v3
id: lfs-cache
with:
path: .git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
- name: Git LFS Pull
run: |
git lfs pull
git add .
git reset --hard
- name: Cache Library
uses: actions/cache@v3
with:
path: Library
key: Library-buildWindows-${{ matrix.targetPlatform }}-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
restore-keys: |
Library-buildWindows-${{ matrix.targetPlatform }}-
Library-buildWindows-
- name: Build Unity Project
id: build-0
continue-on-error: true
timeout-minutes: 45
uses: game-ci/unity-builder@main
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL_PERSONAL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD_PERSONAL }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL_PERSONAL }}
with:
targetPlatform: ${{ matrix.targetPlatform }}
buildMethod: Cgs.Editor.BuildCgs.BuildOptions
- name: Sleep for Retry
if: ${{ steps.build-0.outcome == 'failure' }}
run: Start-Sleep -s 120
- name: Build Retry
id: build-1
continue-on-error: true
timeout-minutes: 45
if: steps.build-0.outcome == 'failure'
uses: game-ci/unity-builder@main
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL_PERSONAL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD_PERSONAL }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL_PERSONAL }}
with:
targetPlatform: ${{ matrix.targetPlatform }}
buildMethod: Cgs.Editor.BuildCgs.BuildOptions
- name: Sleep for Retry 2
if: ${{ steps.build-0.outcome == 'failure' && steps.build-1.outcome == 'failure' }}
run: Start-Sleep -s 240
- name: Build Retry 2
id: build-2
timeout-minutes: 45
if: ${{ steps.build-0.outcome == 'failure' && steps.build-1.outcome == 'failure' }}
uses: game-ci/unity-builder@main
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL_PERSONAL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD_PERSONAL }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL_PERSONAL }}
with:
targetPlatform: ${{ matrix.targetPlatform }}
buildMethod: Cgs.Editor.BuildCgs.BuildOptions
- name: Upload Build
uses: actions/upload-artifact@v3
if: github.event.action == 'published' || contains(github.event.inputs.workflow_mode, matrix.targetPlatform) || (contains(github.event.inputs.workflow_mode, 'Steam') && contains(matrix.targetPlatform, 'StandaloneWindows'))
with:
name: cgs-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
- name: Zip Build
uses: vimtor/action-zip@v1
if: github.event.action == 'published' && matrix.targetPlatform != 'WSAPlayer'
with:
files: build/${{ matrix.targetPlatform }}/
dest: build/cgs-${{ matrix.targetPlatform }}.zip
- name: Upload Zip to GitHub Release
uses: svenstaro/upload-release-action@v2
if: github.event.action == 'published' && matrix.targetPlatform != 'WSAPlayer'
with:
repo_token: ${{ secrets.CGS_PAT }}
asset_name: cgs-${{ matrix.targetPlatform }}.zip
file: build/cgs-${{ matrix.targetPlatform }}.zip
tag: ${{ github.ref }}
overwrite: true
body: ${{ github.event.release.body }}
deployToMicrosoftStore:
name: Deploy to the Microsoft Store
runs-on: windows-2019
needs: buildWithWindows
if: github.event.action == 'published' || (contains(github.event.inputs.workflow_mode, 'release') && contains(github.event.inputs.workflow_mode, 'WSAPlayer'))
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Create LFS file list
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
- name: Restore LFS cache
uses: actions/cache@v3
id: lfs-cache
with:
path: .git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
- name: Git LFS Pull
run: |
git lfs pull
git add .
git reset --hard
- name: Build Unity Project
id: build-0
continue-on-error: true
timeout-minutes: 45
uses: game-ci/unity-builder@main
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL_PERSONAL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD_PERSONAL }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL_PERSONAL }}
with:
targetPlatform: WSAPlayer
buildMethod: Cgs.Editor.BuildCgs.BuildOptions
- name: Sleep for Retry
if: ${{ steps.build-0.outcome == 'failure' }}
run: Start-Sleep -s 120
- name: Build Retry
id: build-1
continue-on-error: true
timeout-minutes: 45
if: steps.build-0.outcome == 'failure'
uses: game-ci/unity-builder@main
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL_PERSONAL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD_PERSONAL }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL_PERSONAL }}
with:
targetPlatform: WSAPlayer
buildMethod: Cgs.Editor.BuildCgs.BuildOptions
- name: Sleep for Retry 2
if: ${{ steps.build-0.outcome == 'failure' && steps.build-1.outcome == 'failure' }}
run: Start-Sleep -s 240
- name: Build Retry 2
id: build-2
timeout-minutes: 45
if: ${{ steps.build-0.outcome == 'failure' && steps.build-1.outcome == 'failure' }}
uses: game-ci/unity-builder@main
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL_PERSONAL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD_PERSONAL }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL_PERSONAL }}
with:
targetPlatform: WSAPlayer
buildMethod: Cgs.Editor.BuildCgs.BuildOptions
- name: Upload Build
uses: actions/upload-artifact@v3
with:
name: cgs-WSAPlayer
path: build/WSAPlayer
- name: Checkout Card-Game-Simulator
run: |
mkdir C:/Card-Game-Simulator.git
git clone https://github.com/finol-digital/Card-Game-Simulator.git C:/Card-Game-Simulator.git --depth=1
mkdir C:/Card-Game-Simulator.git/build
mv build/WSAPlayer C:/Card-Game-Simulator.git/build
ls C:/Card-Game-Simulator.git/build
ls C:/Card-Game-Simulator.git/build/WSAPlayer
ls C:/Card-Game-Simulator.git/build/WSAPlayer/WSAPlayer
- name: Update Release Notes
working-directory: C:/Card-Game-Simulator.git
if: github.event.action == 'published'
shell: bash
env:
RELEASE_NOTES: ${{ github.event.release.body }}
run: echo "$RELEASE_NOTES" > fastlane/metadata/en-US/release_notes.txt
- name: Get Release Notes
working-directory: C:/Card-Game-Simulator.git
id: changelog
shell: bash
run: |
export RELEASE_NOTES="$(cat fastlane/metadata/en-US/release_notes.txt)"
echo "$RELEASE_NOTES"
echo 'RELEASE_NOTES<<EOF' >> $GITHUB_OUTPUT
echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Apply Release Notes
uses: davidmfinol/replace-action@master
with:
files: "C:/Card-Game-Simulator.git/storebroker/en-us/PDP.xml"
replacements: "OUTPUT_RELEASE_NOTES=${{ steps.changelog.outputs.RELEASE_NOTES }}"
- name: Setup Unity UWP
uses: kuler90/setup-unity@v1
with:
unity-modules: universal-windows-platform
project-path: C:/Card-Game-Simulator.git
- name: Setup Developer Command Prompt for Microsoft Visual C++
uses: ilammy/msvc-dev-cmd@v1
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1
- name: Remove spaces from project name
uses: davidmfinol/replace-action@master
with:
files: "C:/Card-Game-Simulator.git/build/WSAPlayer/WSAPlayer/Card Game Simulator.sln"
replacements: "\"Card Game Simulator\"=\"CardGameSimulator\""
- name: Remove spaces from project name 2
uses: davidmfinol/replace-action@master
with:
files: "C:/Card-Game-Simulator.git/build/WSAPlayer/WSAPlayer/Card Game Simulator/Card Game Simulator.vcxproj"
replacements: "</PropertyGroup>=<ProjectName>CardGameSimulator</ProjectName></PropertyGroup>"
- name: Add Package.StoreAssociation.xml to .vcxproj
uses: mingjun97/file-regex-replace@v1
with:
regex: '<ProjectName>CardGameSimulator</ProjectName></PropertyGroup>'
replacement: '<ProjectName>CardGameSimulator</ProjectName></PropertyGroup><ItemGroup><None Include="Package.StoreAssociation.xml" /></ItemGroup>'
path: 'C:/Card-Game-Simulator.git/build/WSAPlayer/WSAPlayer/Card Game Simulator'
- name: Add Package.StoreAssociation.xml to .vcxproj.filters
uses: mingjun97/file-regex-replace@v1
with:
regex: '</ItemGroup>'
replacement: '</ItemGroup><ItemGroup><None Include="Package.StoreAssociation.xml" /></ItemGroup>'
path: 'C:/Card-Game-Simulator.git/build/WSAPlayer/WSAPlayer/Card Game Simulator'
include: 'Card Game Simulator\.vcxproj\.filters'
- name: Copy the Package.StoreAssociation.xml and CardGameSimulator.vcxproj.user
working-directory: C:/Card-Game-Simulator.git
shell: pwsh
env:
UwpProjectDirectory: build\WSAPlayer\WSAPlayer\Card Game Simulator
run: |
Copy-Item "C:\Card-Game-Simulator.git\storebroker\Package.StoreAssociation.xml" -Destination ".\$env:UwpProjectDirectory\"
Copy-Item "C:\Card-Game-Simulator.git\storebroker\CardGameSimulator.vcxproj.user" -Destination ".\$env:UwpProjectDirectory\"
- name: Update the Package.appxmanifest
if: false
working-directory: C:/Card-Game-Simulator.git
shell: pwsh
env:
UwpProjectDirectory: build\WSAPlayer\WSAPlayer\Card Game Simulator
run: |
[xml]$manifest = get-content ".\$env:UwpProjectDirectory\Package.appxmanifest"
$manifest.Package.Identity.Name = "FinolDigitalLLC.CardGameSimulator"
$manifest.Package.Identity.Publisher = "CN=BBF9912B-079E-4CCE-A441-0D6EA6798115"
$manifest.save(".\$env:UwpProjectDirectory\Package.appxmanifest")
echo ".\$env:UwpProjectDirectory\Package.appxmanifest"
cat ".\$env:UwpProjectDirectory\Package.appxmanifest"
- name: Upload Build2
uses: actions/upload-artifact@v3
with:
name: cgs-WSAPlayer2
path: ${{ format('{0}\build\WSAPlayer', 'C:\Card-Game-Simulator.git') }}
- name: Decode the Pfx
working-directory: C:/Card-Game-Simulator.git
shell: pwsh
env:
UwpProjectDirectory: build\WSAPlayer\WSAPlayer\Card Game Simulator
SigningCertificate: Card Game Simulator_StoreKey.pfx
run: |
$pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.MICROSOFT_STORE_PFX_FILE }}")
$currentDirectory = Get-Location
$certificatePath = Join-Path -Path $currentDirectory -ChildPath $env:UwpProjectDirectory -AdditionalChildPath $env:SigningCertificate
[IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte)
- name: Build the .appxupload
# Remove None Include for il2cppFileRoot.txt and LineNumberMappings.json
if: false
# See: https://forum.unity.com/threads/uwp-errors-in-visual-studio.1461980/
working-directory: C:/Card-Game-Simulator.git
shell: pwsh
env:
SolutionPath: build\WSAPlayer\WSAPlayer\Card Game Simulator.sln
SigningCertificate: Card Game Simulator_StoreKey.pfx
run: msbuild $env:SolutionPath /p:Configuration="Master" /p:Platform="x64" /p:UapAppxPackageBuildMode="StoreUpload" /p:AppxBundle="Always" /p:AppxBundlePlatforms="x86|x64|arm|arm64" /p:PackageCertificateKeyFile=$env:SigningCertificate
- name: Remove the .pfx
working-directory: C:/Card-Game-Simulator.git
shell: pwsh
env:
UwpProjectDirectory: build\WSAPlayer\WSAPlayer\Card Game Simulator
SigningCertificate: Card Game Simulator_StoreKey.pfx
run: Remove-Item -path $env:UwpProjectDirectory\$env:SigningCertificate
- name: Upload .appxupload
# Remove None Include for il2cppFileRoot.txt and LineNumberMappings.json
if: false
# See: https://forum.unity.com/threads/uwp-errors-in-visual-studio.1461980/
uses: actions/upload-artifact@v3
with:
name: ${{ format('CardGameSimulator_{0}.0_x86_x64_arm_arm64_bundle_Master.appxupload', steps.build.outputs.buildVersion) }}
path: ${{ format('{0}\build\WSAPlayer\WSAPlayer\AppPackages\CardGameSimulator\CardGameSimulator_{1}.0_x86_x64_arm_arm64_bundle_Master.appxupload', 'C:\Card-Game-Simulator.git', steps.build.outputs.buildVersion) }}
- name: Upload to the Microsoft Store
# Remove None Include for il2cppFileRoot.txt and LineNumberMappings.json
if: false
# See: https://forum.unity.com/threads/uwp-errors-in-visual-studio.1461980/
working-directory: C:/Card-Game-Simulator.git
shell: pwsh
#if: false
env:
MICROSOFT_TENANT_ID: ${{ secrets.MICROSOFT_TENANT_ID }}
MICROSOFT_CLIENT_ID: ${{ secrets.MICROSOFT_CLIENT_ID }}
MICROSOFT_KEY: ${{ secrets.MICROSOFT_KEY }}
MICROSOFT_APP_ID: 9N96N5S4W3J0
STOREBROKER_CONFIG_PATH: ${{ format('{0}\storebroker\SBConfig.json', 'C:\Card-Game-Simulator.git') }}
PDP_ROOT_PATH: ${{ format('{0}\storebroker\', 'C:\Card-Game-Simulator.git') }}
IMAGES_ROOT_PATH: ${{ format('{0}\docs\assets\img\', 'C:\Card-Game-Simulator.git') }}
APPX_PATH: ${{ format('{0}\build\WSAPlayer\WSAPlayer\AppPackages\CardGameSimulator\CardGameSimulator_{1}.0_x86_x64_arm_arm64_bundle_Master.appxupload', 'C:\Card-Game-Simulator.git', steps.build.outputs.buildVersion) }}
OUT_PATH: ${{ format('{0}\build\WSAPlayer\WSAPlayer\', 'C:\Card-Game-Simulator.git') }}
SUBMISSION_DATA_PATH: ${{ format('{0}\build\WSAPlayer\WSAPlayer\upload.json', 'C:\Card-Game-Simulator.git') }}
PACKAGE_PATH: ${{ format('{0}\build\WSAPlayer\WSAPlayer\upload.zip', 'C:\Card-Game-Simulator.git') }}
run: |
Install-Module -Name StoreBroker -AcceptLicense -Force
$pass = ConvertTo-SecureString $env:MICROSOFT_KEY -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($env:MICROSOFT_CLIENT_ID, $pass)
Set-StoreBrokerAuthentication -TenantId $env:MICROSOFT_TENANT_ID -Credential $cred
New-SubmissionPackage -ConfigPath $env:STOREBROKER_CONFIG_PATH -PDPRootPath $env:PDP_ROOT_PATH -ImagesRootPath $env:IMAGES_ROOT_PATH -AppxPath $env:APPX_PATH -OutPath $env:OUT_PATH -OutName 'upload' -Verbose
Update-ApplicationSubmission -AppId $env:MICROSOFT_APP_ID -SubmissionDataPath $env:SUBMISSION_DATA_PATH -PackagePath $env:PACKAGE_PATH -ReplacePackages -UpdateListings -AutoCommit -Force
deployToSteam:
name: Deploy to the Steam Marketplace
runs-on: ubuntu-latest
needs: buildWithWindows
if: github.event.action == 'published' || (contains(github.event.inputs.workflow_mode, 'release') && contains(github.event.inputs.workflow_mode, 'Steam'))
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Download StandaloneWindows Artifact
uses: actions/download-artifact@v3
with:
name: cgs-StandaloneWindows
path: build/StandaloneWindows
- name: Download StandaloneLinux64 Artifact
uses: actions/download-artifact@v3
with:
name: cgs-StandaloneLinux64
path: build/StandaloneLinux64
- name: Download StandaloneWindows64 Artifact
uses: actions/download-artifact@v3
with:
name: cgs-StandaloneWindows64
path: build/StandaloneWindows64
- name: Download App
uses: actions/download-artifact@v3
with:
name: Card Game Simulator.app
path: build/StandaloneOSX/Card Game Simulator.app
- name: Deploy to Steam
uses: game-ci/steam-deploy@main
with:
username: ${{ secrets.STEAM_USERNAME }}
configVdf: ${{ secrets.STEAM_CONFIG_VDF }}
appId: 1742850
buildDescription: v${{ needs.buildWithWindows.outputs.buildVersion }}
rootPath: build
depot1Path: StandaloneWindows
depot2Path: StandaloneLinux64
depot3Path: StandaloneWindows64
depot4Path: StandaloneOSX
releaseBranch: prerelease
announceReleaseToSocialMedia:
name: Announce Release to Social Media
runs-on: ubuntu-latest
needs: [buildWithWindows, deployToAppStore, deployToGooglePlay, deployToFirebase, deployToMacAppStore, deployToMicrosoftStore, deployToSteam]
if: github.event.action == 'published'
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Update Release Notes
if: github.event.action == 'published'
env:
RELEASE_NOTES: ${{ github.event.release.body }}
run: echo "$RELEASE_NOTES" > fastlane/metadata/en-US/release_notes.txt
- name: Prepare Announcement
id: prepare
shell: bash
env:
VERSION: v${{ needs.buildWithWindows.outputs.buildVersion }}
RELEASE_NOTES: ${{ github.event.release.body }}
run: |
RELEASE_NOTES="$(cat fastlane/metadata/en-US/release_notes.txt)"
export ANNOUNCEMENT="Released CGS $VERSION! $RELEASE_NOTES"
echo "$ANNOUNCEMENT"
echo 'ANNOUNCEMENT<<EOF' >> $GITHUB_OUTPUT
echo "$ANNOUNCEMENT" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Discord Announcement
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/[email protected]
with:
args: ${{ steps.prepare.outputs.ANNOUNCEMENT }}