aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/build.yml
blob: fc223a0772fab130164307e2a1b91c82a8dfa452 (plain)
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
name: Build

on:
  workflow_call:
    inputs:
      build_type:
        description: Type of build (Debug, Release, RelWithDebInfo, MinSizeRel)
        type: string
        default: Debug
      is_qt_cached:
        description: Enable Qt caching or not
        type: string
        default: true
    secrets:
      SPARKLE_ED25519_KEY:
        description: Private key for signing Sparkle updates
        required: false
      WINDOWS_CODESIGN_CERT:
        description: Certificate for signing Windows builds
        required: false
      WINDOWS_CODESIGN_PASSWORD:
        description: Password for signing Windows builds
        required: false
      CACHIX_AUTH_TOKEN:
        description: Private token for authenticating against Cachix cache
        required: false
      GPG_PRIVATE_KEY:
        description: Private key for AppImage signing
        required: false
      GPG_PRIVATE_KEY_ID:
        description: ID for the GPG_PRIVATE_KEY, to select the signing key
        required: false

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        include:

          - os: ubuntu-20.04
            qt_ver: 5

          - os: ubuntu-20.04
            qt_ver: 6
            qt_host: linux
            qt_arch: ''
            qt_version: '6.2.4'
            qt_modules: 'qt5compat qtimageformats'
            qt_tools: ''

          - os: windows-2022
            name: "Windows-MinGW-w64"
            msystem: clang64
            vcvars_arch: 'amd64_x86'

          - os: windows-2022
            name: "Windows-MSVC-Legacy"
            msystem: ''
            architecture: 'win32'
            vcvars_arch: 'amd64_x86'
            qt_ver: 5
            qt_host: windows
            qt_arch: 'win32_msvc2019'
            qt_version: '5.15.2'
            qt_modules: ''
            qt_tools: 'tools_openssl_x86'

          - os: windows-2022
            name: "Windows-MSVC"
            msystem: ''
            architecture: 'x64'
            vcvars_arch: 'amd64'
            qt_ver: 6
            qt_host: windows
            qt_arch: ''
            qt_version: '6.5.2'
            qt_modules: 'qt5compat qtimageformats'
            qt_tools: ''

          - os: windows-2022
            name: "Windows-MSVC-arm64"
            msystem: ''
            architecture: 'arm64'
            vcvars_arch: 'amd64_arm64'
            qt_ver: 6
            qt_host: windows
            qt_arch: 'win64_msvc2019_arm64'
            qt_version: '6.5.2'
            qt_modules: 'qt5compat qtimageformats'
            qt_tools: ''

          - os: macos-12
            name: macOS
            macosx_deployment_target: 11.0
            qt_ver: 6
            qt_host: mac
            qt_arch: ''
            qt_version: '6.5.2'
            qt_modules: 'qt5compat qtimageformats'
            qt_tools: ''

          - os: macos-12
            name: macOS-Legacy
            macosx_deployment_target: 10.13
            qt_ver: 5
            qt_host: mac
            qt_version: '5.15.2'
            qt_modules: ''
            qt_tools: ''

    runs-on: ${{ matrix.os }}

    env:
      MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }}
      INSTALL_DIR: "install"
      INSTALL_PORTABLE_DIR: "install-portable"
      INSTALL_APPIMAGE_DIR: "install-appdir"
      BUILD_DIR: "build"
      CCACHE_VAR: ""
      HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1

    steps:
      ##
      # PREPARE
      ##
      - name: Checkout
        uses: actions/checkout@v3
        with:
          submodules: 'true'

      - name: 'Setup MSYS2'
        if: runner.os == 'Windows' && matrix.msystem != ''
        uses: msys2/setup-msys2@v2
        with:
          msystem: ${{ matrix.msystem }}
          update: true
          install: >-
            git
            mingw-w64-x86_64-binutils
          pacboy: >-
            toolchain:p
            cmake:p
            extra-cmake-modules:p
            ninja:p
            qt6-base:p
            qt6-svg:p
            qt6-imageformats:p
            quazip-qt6:p
            ccache:p
            qt6-5compat:p
            cmark:p

      - name: Force newer ccache
        if: runner.os == 'Windows' && matrix.msystem == '' && inputs.build_type == 'Debug'
        run: |
          choco install ccache --version 4.7.1

      - name: Setup ccache
        if: (runner.os != 'Windows' || matrix.msystem == '') && inputs.build_type == 'Debug'
        uses: hendrikmuhs/ccache-action@v1.2.9
        with:
          key: ${{ matrix.os }}-qt${{ matrix.qt_ver }}-${{ matrix.architecture }}

      - name: Retrieve ccache cache (Windows MinGW-w64)
        if: runner.os == 'Windows' && matrix.msystem != '' && inputs.build_type == 'Debug'
        uses: actions/cache@v3.3.1
        with:
          path: '${{ github.workspace }}\.ccache'
          key: ${{ matrix.os }}-mingw-w64-ccache-${{ github.run_id }}
          restore-keys: |
              ${{ matrix.os }}-mingw-w64-ccache

      - name: Setup ccache (Windows MinGW-w64)
        if: runner.os == 'Windows' && matrix.msystem != '' && inputs.build_type == 'Debug'
        shell: msys2 {0}
        run: |
          ccache --set-config=cache_dir='${{ github.workspace }}\.ccache'
          ccache --set-config=max_size='500M'
          ccache --set-config=compression=true
          ccache -p  # Show config
          ccache -z  # Zero stats

      - name: Use ccache on Debug builds only
        if: inputs.build_type == 'Debug'
        shell: bash
        run: |
          echo "CCACHE_VAR=ccache" >> $GITHUB_ENV

      - name: Set short version
        shell: bash
        run: |
          ver_short=`git rev-parse --short HEAD`
          echo "VERSION=$ver_short" >> $GITHUB_ENV

      - name: Install Dependencies (Linux)
        if: runner.os == 'Linux'
        run: |
          sudo apt-get -y update
          sudo apt-get -y install ninja-build extra-cmake-modules scdoc appstream

      - name: Install Dependencies (macOS)
        if: runner.os == 'macOS'
        run: |
          brew update
          brew install ninja extra-cmake-modules

      - name: Install Qt (Linux)
        if: runner.os == 'Linux' && matrix.qt_ver != 6
        run: |
          sudo apt-get -y install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libqt5core5a libqt5network5 libqt5gui5

      - name: Install host Qt (Windows MSVC arm64)
        if: runner.os == 'Windows' && matrix.architecture == 'arm64'
        uses: jurplel/install-qt-action@v3
        with:
           aqtversion: '==3.1.*'
           py7zrversion: '>=0.20.2'
           version: ${{ matrix.qt_version }}
           host: 'windows'
           target: 'desktop'
           arch: ''
           modules: ${{ matrix.qt_modules }}
           tools: ${{ matrix.qt_tools }}
           cache: ${{ inputs.is_qt_cached }}
           cache-key-prefix: host-qt-arm64-windows
           dir: ${{ github.workspace }}\HostQt
           set-env: false

      - name: Install Qt (macOS, Linux, Qt 6 & Windows MSVC)
        if: runner.os == 'Linux' && matrix.qt_ver == 6 || runner.os == 'macOS' || (runner.os == 'Windows' && matrix.msystem == '')
        uses: jurplel/install-qt-action@v3
        with:
           aqtversion: '==3.1.*'
           py7zrversion: '>=0.20.2'
           version: ${{ matrix.qt_version }}
           host: ${{ matrix.qt_host }}
           target: 'desktop'
           arch: ${{ matrix.qt_arch }}
           modules: ${{ matrix.qt_modules }}
           tools: ${{ matrix.qt_tools }}
           cache: ${{ inputs.is_qt_cached }}

      - name: Install MSVC (Windows MSVC)
        if: runner.os == 'Windows'  # We want this for MinGW builds as well, as we need SignTool
        uses: ilammy/msvc-dev-cmd@v1
        with:
          vsversion: 2022
          arch: ${{ matrix.vcvars_arch }}

      - name: Prepare AppImage (Linux)
        if: runner.os == 'Linux' && matrix.qt_ver != 5
        run: |
          wget "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
          wget "https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-x86_64.AppImage"
          wget "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage"

          wget "https://github.com/AppImageCommunity/AppImageUpdate/releases/download/continuous/AppImageUpdate-x86_64.AppImage"

          ${{ github.workspace }}/.github/scripts/prepare_JREs.sh
          sudo apt install libopengl0

      - name: Add QT_HOST_PATH var (Windows MSVC arm64)
        if: runner.os == 'Windows' && matrix.architecture == 'arm64'
        run: |
          echo "QT_HOST_PATH=${{ github.workspace }}\HostQt\Qt\${{ matrix.qt_version }}\msvc2019_64" >> $env:GITHUB_ENV

      ##
      # CONFIGURE
      ##

      - name: Configure CMake (macOS)
        if: runner.os == 'macOS' && matrix.qt_ver == 6
        run: |
          cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_BUILD_PLATFORM=official -DCMAKE_C_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DCMAKE_CXX_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DLauncher_QT_VERSION_MAJOR=${{ matrix.qt_ver }} -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -G Ninja

      - name: Configure CMake (macOS-Legacy)
        if: runner.os == 'macOS' && matrix.qt_ver == 5
        run: |
          cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_BUILD_PLATFORM=official -DCMAKE_C_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DCMAKE_CXX_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DLauncher_QT_VERSION_MAJOR=${{ matrix.qt_ver }} -DMACOSX_SPARKLE_UPDATE_PUBLIC_KEY="" -DMACOSX_SPARKLE_UPDATE_FEED_URL="" -G Ninja

      - name: Configure CMake (Windows MinGW-w64)
        if: runner.os == 'Windows' && matrix.msystem != ''
        shell: msys2 {0}
        run: |
          cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_BUILD_PLATFORM=official -DCMAKE_C_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DCMAKE_CXX_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DLauncher_QT_VERSION_MAJOR=6 -DCMAKE_OBJDUMP=/mingw64/bin/objdump.exe -G Ninja

      - name: Configure CMake (Windows MSVC)
        if: runner.os == 'Windows' && matrix.msystem == ''
        run: |
          cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_BUILD_PLATFORM=official -DLauncher_QT_VERSION_MAJOR=${{ matrix.qt_ver }} -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreadedDLL" -A${{ matrix.architecture}} -DLauncher_FORCE_BUNDLED_LIBS=ON
          # https://github.com/ccache/ccache/wiki/MS-Visual-Studio (I coudn't figure out the compiler prefix)
          if ("${{ env.CCACHE_VAR }}")
          {
            Copy-Item C:/ProgramData/chocolatey/lib/ccache/tools/ccache-4.7.1-windows-x86_64/ccache.exe -Destination C:/ProgramData/chocolatey/lib/ccache/tools/ccache-4.7.1-windows-x86_64/cl.exe
            echo "CLToolExe=cl.exe" >> $env:GITHUB_ENV
            echo "CLToolPath=C:/ProgramData/chocolatey/lib/ccache/tools/ccache-4.7.1-windows-x86_64/" >> $env:GITHUB_ENV
            echo "TrackFileAccess=false" >> $env:GITHUB_ENV
          }
          # Needed for ccache, but also speeds up compile
          echo "UseMultiToolTask=true" >> $env:GITHUB_ENV

      - name: Configure CMake (Linux)
        if: runner.os == 'Linux'
        run: |
          cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_BUILD_PLATFORM=official -DCMAKE_C_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DCMAKE_CXX_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DLauncher_QT_VERSION_MAJOR=${{ matrix.qt_ver }} -G Ninja

      ##
      # BUILD
      ##

      - name: Build
        if: runner.os != 'Windows'
        run: |
          cmake --build ${{ env.BUILD_DIR }}

      - name: Build (Windows MinGW-w64)
        if: runner.os == 'Windows' && matrix.msystem != ''
        shell: msys2 {0}
        run: |
          cmake --build ${{ env.BUILD_DIR }}

      - name: Build (Windows MSVC)
        if: runner.os == 'Windows' && matrix.msystem == ''
        run: |
          cmake --build ${{ env.BUILD_DIR }} --config ${{ inputs.build_type }}

      ##
      # TEST
      ##

      - name: Test
        if: runner.os != 'Windows'
        run: |
          ctest -E "^example64|example$" --test-dir build --output-on-failure

      - name: Test (Windows MinGW-w64)
        if: runner.os == 'Windows' && matrix.msystem != ''
        shell: msys2 {0}
        run: |
          ctest -E "^example64|example$" --test-dir build --output-on-failure

      - name: Test (Windows MSVC)
        if: runner.os == 'Windows' && matrix.msystem == '' && matrix.architecture != 'arm64'
        run: |
          ctest -E "^example64|example$" --test-dir build --output-on-failure -C ${{ inputs.build_type }} 

      ##
      # PACKAGE BUILDS
      ##

      - name: Package (macOS)
        if: runner.os == 'macOS'
        run: |
          cmake --install ${{ env.BUILD_DIR }}

          cd ${{ env.INSTALL_DIR }}
          chmod +x "PrismLauncher.app/Contents/MacOS/prismlauncher"
          sudo codesign --sign - --deep --force --entitlements "../program_info/App.entitlements" --options runtime "PrismLauncher.app/Contents/MacOS/prismlauncher"
          mv "PrismLauncher.app" "Prism Launcher.app"
          tar -czf ../PrismLauncher.tar.gz *

      - name: Make Sparkle signature (macOS)
        if: matrix.name == 'macOS'
        run: |
          if [ '${{ secrets.SPARKLE_ED25519_KEY }}' != '' ]; then
            brew install openssl@3
            echo '${{ secrets.SPARKLE_ED25519_KEY }}' > ed25519-priv.pem
            signature=$(/usr/local/opt/openssl@3/bin/openssl pkeyutl -sign -rawin -in ${{ github.workspace }}/PrismLauncher.tar.gz -inkey ed25519-priv.pem | openssl base64 | tr -d \\n)
            rm ed25519-priv.pem
            cat >> $GITHUB_STEP_SUMMARY << EOF
          ### Artifact Information :information_source:
          - :memo: Sparkle Signature (ed25519): \`$signature\`
          EOF
          else
            cat >> $GITHUB_STEP_SUMMARY << EOF
          ### Artifact Information :information_source:
          - :warning: Sparkle Signature (ed25519): No private key available (likely a pull request or fork)
          EOF
          fi

      - name: Package (Windows MinGW-w64)
        if: runner.os == 'Windows' && matrix.msystem != ''
        shell: msys2 {0}
        run: |
          cmake --install ${{ env.BUILD_DIR }}
          touch ${{ env.INSTALL_DIR }}/manifest.txt
          for l in $(find ${{ env.INSTALL_DIR }} -type f); do l=$(cygpath -u $l); l=${l#$(pwd)/}; l=${l#${{ env.INSTALL_DIR }}/}; l=${l#./}; echo $l; done >> ${{ env.INSTALL_DIR }}/manifest.txt 

      - name: Package (Windows MSVC)
        if: runner.os == 'Windows' && matrix.msystem == ''
        run: |
          cmake --install ${{ env.BUILD_DIR }} --config ${{ inputs.build_type }}

          cd ${{ env.INSTALL_DIR }}
          if ("${{ matrix.qt_ver }}" -eq "5")
          {
            Copy-Item ${{ runner.workspace }}/Qt/Tools/OpenSSL/Win_x86/bin/libcrypto-1_1.dll -Destination libcrypto-1_1.dll
            Copy-Item ${{ runner.workspace }}/Qt/Tools/OpenSSL/Win_x86/bin/libssl-1_1.dll -Destination libssl-1_1.dll
          }
          cd ${{ github.workspace }}

          Get-ChildItem ${{ env.INSTALL_DIR }} -Recurse | ForEach FullName | Resolve-Path -Relative | %{ $_.TrimStart('.\') } | %{ $_.TrimStart('${{ env.INSTALL_DIR }}') } | %{ $_.TrimStart('\') } | Out-File -FilePath ${{ env.INSTALL_DIR }}/manifest.txt


      - name: Fetch codesign certificate (Windows)
        if: runner.os == 'Windows'
        shell: bash  # yes, we are not using MSYS2 or PowerShell here
        run: |
          echo '${{ secrets.WINDOWS_CODESIGN_CERT }}' | base64 --decode > codesign.pfx

      - name: Sign executable (Windows)
        if: runner.os == 'Windows'
        run: |
          if (Get-Content ./codesign.pfx){
            cd ${{ env.INSTALL_DIR }}
            # We ship the exact same executable for portable and non-portable editions, so signing just once is fine
            SignTool sign /fd sha256 /td sha256 /f ../codesign.pfx /p '${{ secrets.WINDOWS_CODESIGN_PASSWORD }}' /tr http://timestamp.digicert.com prismlauncher.exe prismlauncher_filelink.exe
          } else {
            ":warning: Skipped code signing for Windows, as certificate was not present." >> $env:GITHUB_STEP_SUMMARY
          }

      - name: Package (Windows MinGW-w64, portable)
        if: runner.os == 'Windows' && matrix.msystem != ''
        shell: msys2 {0}
        run: |
          cp -r ${{ env.INSTALL_DIR }} ${{ env.INSTALL_PORTABLE_DIR }}  # cmake install on Windows is slow, let's just copy instead
          cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_PORTABLE_DIR }} --component portable
          for l in $(find ${{ env.INSTALL_PORTABLE_DIR }} -type f); do l=$(cygpath -u $l); l=${l#$(pwd)/}; l=${l#${{ env.INSTALL_PORTABLE_DIR }}/}; l=${l#./}; echo $l; done >> ${{ env.INSTALL_PORTABLE_DIR }}/manifest.txt

      - name: Package (Windows MSVC, portable)
        if: runner.os == 'Windows' && matrix.msystem == ''
        run: |
          cp -r ${{ env.INSTALL_DIR }} ${{ env.INSTALL_PORTABLE_DIR }}  # cmake install on Windows is slow, let's just copy instead
          cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_PORTABLE_DIR }} --component portable

          Get-ChildItem ${{ env.INSTALL_PORTABLE_DIR }} -Recurse | ForEach FullName | Resolve-Path -Relative | %{ $_.TrimStart('.\') } | %{ $_.TrimStart('${{ env.INSTALL_PORTABLE_DIR }}') } | %{ $_.TrimStart('\') } | Out-File -FilePath ${{ env.INSTALL_DIR }}/manifest.txt

      - name: Package (Windows, installer)
        if: runner.os == 'Windows'
        run: |
          cd ${{ env.INSTALL_DIR }}
          makensis -NOCD "${{ github.workspace }}/${{ env.BUILD_DIR }}/program_info/win_install.nsi"

      - name: Sign installer (Windows)
        if: runner.os == 'Windows'
        run: |
          if (Get-Content ./codesign.pfx){
            SignTool sign /fd sha256 /td sha256 /f codesign.pfx /p '${{ secrets.WINDOWS_CODESIGN_PASSWORD }}' /tr http://timestamp.digicert.com PrismLauncher-Setup.exe
          } else {
            ":warning: Skipped code signing for Windows, as certificate was not present." >> $env:GITHUB_STEP_SUMMARY
          }

      - name: Package (Linux)
        if: runner.os == 'Linux'
        run: |
          cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_DIR }}
          for l in $(find ${{ env.INSTALL_DIR }} -type f); do l=${l#$(pwd)/}; l=${l#${{ env.INSTALL_DIR }}/}; l=${l#./}; echo $l; done > ${{ env.INSTALL_DIR }}/manifest.txt

          cd ${{ env.INSTALL_DIR }}
          tar --owner root --group root -czf ../PrismLauncher.tar.gz *

      - name: Package (Linux, portable)
        if: runner.os == 'Linux'
        run: |
          cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_PORTABLE_DIR }}
          cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_PORTABLE_DIR }} --component portable
          for l in $(find ${{ env.INSTALL_PORTABLE_DIR }} -type f); do l=${l#$(pwd)/}; l=${l#${{ env.INSTALL_PORTABLE_DIR }}/}; l=${l#./}; echo $l; done > ${{ env.INSTALL_PORTABLE_DIR }}/manifest.txt


          cd ${{ env.INSTALL_PORTABLE_DIR }}
          tar -czf ../PrismLauncher-portable.tar.gz *

      - name: Package AppImage (Linux)
        if: runner.os == 'Linux' && matrix.qt_ver != 5
        shell: bash
        env:
          GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
        run: |
          cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_APPIMAGE_DIR }}/usr

          mv ${{ env.INSTALL_APPIMAGE_DIR }}/usr/share/metainfo/org.prismlauncher.PrismLauncher.metainfo.xml ${{ env.INSTALL_APPIMAGE_DIR }}/usr/share/metainfo/org.prismlauncher.PrismLauncher.appdata.xml
          export "NO_APPSTREAM=1" # we have to skip appstream checking because appstream on ubuntu 20.04 is outdated

          export OUTPUT="PrismLauncher-Linux-x86_64.AppImage"

          chmod +x linuxdeploy-*.AppImage

          mkdir -p ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-{8,17}-openjdk
          mkdir -p ${{ env.INSTALL_APPIMAGE_DIR }}/usr/plugins/iconengines

          cp -r ${{ github.workspace }}/JREs/jre8/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-8-openjdk

          cp -r ${{ github.workspace }}/JREs/jre17/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-17-openjdk

          cp -r ${{ runner.workspace }}/Qt/${{ matrix.qt_version }}/gcc_64/plugins/iconengines/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/plugins/iconengines

          cp /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/
          cp /usr/lib/x86_64-linux-gnu/libssl.so.1.1 ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/
          cp /usr/lib/x86_64-linux-gnu/libOpenGL.so.0* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/

          LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib"
          LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-8-openjdk/lib/amd64/server"
          LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-8-openjdk/lib/amd64"
          LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-17-openjdk/lib/server"
          LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-17-openjdk/lib"
          export LD_LIBRARY_PATH

          chmod +x AppImageUpdate-x86_64.AppImage
          ./AppImageUpdate-x86_64.AppImage --appimage-extract

          mkdir -p ${{ env.INSTALL_APPIMAGE_DIR }}/usr/optional
          mkdir -p ${{ env.INSTALL_APPIMAGE_DIR }}/usr/plugins

          cp -r squashfs-root/usr/bin/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/bin
          cp -r squashfs-root/usr/lib/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib
          cp -r squashfs-root/usr/optional/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/optional
          cp -r squashfs-root/usr/optional/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/plugins

          export UPDATE_INFORMATION="gh-releases-zsync|${{ github.repository_owner }}|${{ github.event.repository.name }}|latest|PrismLauncher-Linux-x86_64.AppImage.zsync" 

          if [ '${{ secrets.GPG_PRIVATE_KEY_ID }}' != '' ]; then
            export SIGN=1
            export SIGN_KEY=${{ secrets.GPG_PRIVATE_KEY_ID }}
            mkdir -p ~/.gnupg/
            printf "$GPG_PRIVATE_KEY" | base64 --decode > ~/.gnupg/private.key
            gpg --import ~/.gnupg/private.key
          else
            echo ":warning: Skipped code signing for Linux AppImage, as gpg key was not present." >> $GITHUB_STEP_SUMMARY
          fi

          ./linuxdeploy-x86_64.AppImage --appdir ${{ env.INSTALL_APPIMAGE_DIR }} --output appimage --plugin qt -i ${{ env.INSTALL_APPIMAGE_DIR }}/usr/share/icons/hicolor/scalable/apps/org.prismlauncher.PrismLauncher.svg

          mv "PrismLauncher-Linux-x86_64.AppImage" "PrismLauncher-Linux-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage"

      ##
      # UPLOAD BUILDS
      ##

      - name: Upload binary tarball (macOS)
        if: runner.os == 'macOS'
        uses: actions/upload-artifact@v3
        with:
          name: PrismLauncher-${{ matrix.name }}-${{ env.VERSION }}-${{ inputs.build_type }}
          path: PrismLauncher.tar.gz

      - name: Upload binary zip (Windows)
        if: runner.os == 'Windows'
        uses: actions/upload-artifact@v3
        with:
          name: PrismLauncher-${{ matrix.name }}-${{ env.VERSION }}-${{ inputs.build_type }}
          path: ${{ env.INSTALL_DIR }}/**

      - name: Upload binary zip (Windows, portable)
        if: runner.os == 'Windows'
        uses: actions/upload-artifact@v3
        with:
          name: PrismLauncher-${{ matrix.name }}-Portable-${{ env.VERSION }}-${{ inputs.build_type }}
          path: ${{ env.INSTALL_PORTABLE_DIR }}/**

      - name: Upload installer (Windows)
        if: runner.os == 'Windows'
        uses: actions/upload-artifact@v3
        with:
          name: PrismLauncher-${{ matrix.name }}-Setup-${{ env.VERSION }}-${{ inputs.build_type }}
          path: PrismLauncher-Setup.exe

      - name: Upload binary tarball (Linux, Qt 5)
        if: runner.os == 'Linux' && matrix.qt_ver != 6
        uses: actions/upload-artifact@v3
        with:
          name: PrismLauncher-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}
          path: PrismLauncher.tar.gz

      - name: Upload binary tarball (Linux, portable, Qt 5)
        if: runner.os == 'Linux' && matrix.qt_ver != 6
        uses: actions/upload-artifact@v3
        with:
          name: PrismLauncher-${{ runner.os }}-Portable-${{ env.VERSION }}-${{ inputs.build_type }}
          path: PrismLauncher-portable.tar.gz

      - name: Upload binary tarball (Linux, Qt 6)
        if: runner.os == 'Linux' && matrix.qt_ver !=5
        uses: actions/upload-artifact@v3
        with:
          name: PrismLauncher-${{ runner.os }}-Qt6-${{ env.VERSION }}-${{ inputs.build_type }}
          path: PrismLauncher.tar.gz

      - name: Upload binary tarball (Linux, portable, Qt 6)
        if: runner.os == 'Linux' && matrix.qt_ver != 5
        uses: actions/upload-artifact@v3
        with:
          name: PrismLauncher-${{ runner.os }}-Qt6-Portable-${{ env.VERSION }}-${{ inputs.build_type }}
          path: PrismLauncher-portable.tar.gz

      - name: Upload AppImage (Linux)
        if: runner.os == 'Linux' && matrix.qt_ver != 5
        uses: actions/upload-artifact@v3
        with:
          name: PrismLauncher-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage
          path: PrismLauncher-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage
      
      - name: Upload AppImage Zsync (Linux)
        if: runner.os == 'Linux' && matrix.qt_ver != 5
        uses: actions/upload-artifact@v3
        with:
          name: PrismLauncher-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage.zsync
          path: PrismLauncher-Linux-x86_64.AppImage.zsync

      - name: ccache stats (Windows MinGW-w64)
        if: runner.os == 'Windows' && matrix.msystem != ''
        shell: msys2 {0}
        run: |
          ccache -s

  flatpak:
    runs-on: ubuntu-latest
    container:
      image: bilelmoussaoui/flatpak-github-actions:kde-5.15-22.08
      options: --privileged
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        if: inputs.build_type == 'Debug'
        with:
          submodules: 'true'
      - name: Build Flatpak (Linux)
        if: inputs.build_type == 'Debug'
        uses: flatpak/flatpak-github-actions/flatpak-builder@v6
        with:
          bundle: "Prism Launcher.flatpak"
          manifest-path: flatpak/org.prismlauncher.PrismLauncher.yml