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

on:
  push:
    branches: [ "*" ]
    tags: [ "*" ]
  pull_request:
    branches: [ master ]

jobs:
  source:
    if: ${{ !github.head_ref }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: recursive
      - name: Pack
        run: ./.ci/source.sh
      - name: Upload
        uses: actions/upload-artifact@v4
        with:
          name: source
          path: artifacts/
  linux:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        target: ["appimage", "fresh"]
    container:
      image: citraemu/build-environments:linux-${{ matrix.target }}
      options: -u 1001
    env:
      CCACHE_DIR: ${{ github.workspace }}/.ccache
      CCACHE_COMPILERCHECK: content
      CCACHE_SLOPPINESS: time_macros
      OS: linux
      TARGET: ${{ matrix.target }}
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: recursive
      - name: Set up cache
        uses: actions/cache@v4
        with:
          path: ${{ env.CCACHE_DIR }}
          key: ${{ runner.os }}-${{ matrix.target }}-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-${{ matrix.target }}-
      - name: Build
        run: ./.ci/linux.sh
      - name: Pack
        run: ./.ci/pack.sh
        if: ${{ matrix.target == 'appimage' }}
      - name: Upload
        uses: actions/upload-artifact@v4
        if: ${{ matrix.target == 'appimage' }}
        with:
          name: ${{ env.OS }}-${{ env.TARGET }}
          path: artifacts/
  macos:
    runs-on: ${{ (matrix.target == 'x86_64' && 'macos-13') || 'macos-14' }}
    strategy:
      matrix:
        target: ["x86_64", "arm64"]
    env:
      CCACHE_DIR: ${{ github.workspace }}/.ccache
      CCACHE_COMPILERCHECK: content
      CCACHE_SLOPPINESS: time_macros
      OS: macos
      TARGET: ${{ matrix.target }}
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: recursive
      - name: Set up cache
        uses: actions/cache@v4
        with:
          path: ${{ env.CCACHE_DIR }}
          key: ${{ runner.os }}-${{ matrix.target }}-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-${{ matrix.target }}-
      - name: Install tools
        run: brew install ccache ninja
      - name: Build
        run: ./.ci/macos.sh
      - name: Prepare outputs for caching
        run: mv build/bundle $OS-$TARGET
      - name: Cache outputs for universal build
        uses: actions/cache/save@v4
        with:
          path: ${{ env.OS }}-${{ env.TARGET }}
          key: ${{ runner.os }}-${{ matrix.target }}-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
  macos-universal:
    runs-on: macos-14
    needs: macos
    env:
      OS: macos
      TARGET: universal
    steps:
      - uses: actions/checkout@v4
      - name: Download x86_64 build from cache
        uses: actions/cache/restore@v4
        with:
          path: ${{ env.OS }}-x86_64
          key: ${{ runner.os }}-x86_64-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
          fail-on-cache-miss: true
      - name: Download ARM64 build from cache
        uses: actions/cache/restore@v4
        with:
          path: ${{ env.OS }}-arm64
          key: ${{ runner.os }}-arm64-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
          fail-on-cache-miss: true
      - name: Create universal app
        run: ./.ci/macos-universal.sh
        env:
          ARTIFACTS: ${{ env.OS }}-x86_64 ${{ env.OS }}-arm64
      - name: Pack
        run: ./.ci/pack.sh
      - name: Upload
        uses: actions/upload-artifact@v4
        with:
          name: ${{ env.OS }}-${{ env.TARGET }}
          path: artifacts/
  windows:
    runs-on: windows-latest
    strategy:
      matrix:
        target: ["msvc", "msys2"]
    defaults:
      run:
        shell: ${{ (matrix.target == 'msys2' && 'msys2') || 'bash' }} {0}
    env:
      CCACHE_DIR: ${{ github.workspace }}/.ccache
      CCACHE_COMPILERCHECK: content
      CCACHE_SLOPPINESS: time_macros
      OS: windows
      TARGET: ${{ matrix.target }}
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: recursive
      - name: Set up cache
        uses: actions/cache@v4
        with:
          path: ${{ env.CCACHE_DIR }}
          key: ${{ runner.os }}-${{ matrix.target }}-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-${{ matrix.target }}-
      - name: Set up MSVC
        uses: ilammy/msvc-dev-cmd@v1
        if: ${{ matrix.target == 'msvc' }}
      - name: Install extra tools (MSVC)
        run: choco install ccache ninja wget
        if: ${{ matrix.target == 'msvc' }}
      - name: Set up MSYS2
        uses: msys2/setup-msys2@v2
        if: ${{ matrix.target == 'msys2' }}
        with:
          msystem: clang64
          update: true
          install: git make p7zip
          pacboy: >-
            toolchain:p ccache:p cmake:p ninja:p
            qt6-base:p qt6-multimedia:p qt6-multimedia-wmf:p qt6-tools:p qt6-translations:p
      - name: Disable line ending translation
        run: git config --global core.autocrlf input
      - name: Build
        run: ./.ci/windows.sh
      - name: Pack
        run: ./.ci/pack.sh
      - name: Upload
        uses: actions/upload-artifact@v4
        with:
          name: ${{ env.OS }}-${{ env.TARGET }}
          path: artifacts/
  android:
    runs-on: ubuntu-latest
    env:
      CCACHE_DIR: ${{ github.workspace }}/.ccache
      CCACHE_COMPILERCHECK: content
      CCACHE_SLOPPINESS: time_macros
      OS: android
      TARGET: universal
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: recursive
      - name: Set up cache
        uses: actions/cache@v4
        with:
          path: |
            ~/.gradle/caches
            ~/.gradle/wrapper
            ${{ env.CCACHE_DIR }}
          key: ${{ runner.os }}-android-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-android-
      - name: Set tag name
        run: |
          if [[ "$GITHUB_REF_NAME" =~ ^canary- ]] || [[ "$GITHUB_REF_NAME" =~ ^nightly- ]]; then
              echo "GIT_TAG_NAME=$GITHUB_REF_NAME" >> $GITHUB_ENV
          fi
          echo $GIT_TAG_NAME
      - name: Deps
        run: |
          sudo add-apt-repository -y ppa:theofficialgman/gpu-tools
          sudo apt-get update -y
          sudo apt-get install ccache apksigner -y
      - name: Build
        run: JAVA_HOME=$JAVA_HOME_17_X64 ./.ci/android.sh
        env:
          ANDROID_KEYSTORE_B64: ${{ secrets.ANDROID_KEYSTORE_B64 }}
          ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
          ANDROID_KEYSTORE_PASS: ${{ secrets.ANDROID_KEYSTORE_PASS }}
      - name: Pack
        run: ../../../.ci/pack.sh
        working-directory: src/android/app
        env:
          UNPACKED: 1
      - name: Upload
        uses: actions/upload-artifact@v4
        with:
          name: ${{ env.OS }}-${{ env.TARGET }}
          path: src/android/app/artifacts/
  ios:
    runs-on: macos-14
    if: ${{ !startsWith(github.ref, 'refs/tags/') }}
    env:
      CCACHE_DIR: ${{ github.workspace }}/.ccache
      CCACHE_COMPILERCHECK: content
      CCACHE_SLOPPINESS: time_macros
      OS: ios
      TARGET: arm64
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: recursive
      - name: Set up cache
        uses: actions/cache@v4
        with:
          path: ${{ env.CCACHE_DIR }}
          key: ${{ runner.os }}-ios-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-ios-
      - name: Install tools
        run: brew install ccache ninja
      - name: Build
        run: ./.ci/ios.sh
  release:
    runs-on: ubuntu-latest
    needs: [windows, linux, macos-universal, android, source]
    if: ${{ startsWith(github.ref, 'refs/tags/') }}
    steps:
      - uses: actions/download-artifact@v4
      - name: Create release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref_name }}
          release_name: ${{ github.ref_name }}
          draft: false
          prerelease: false
      - name: Upload artifacts
        uses: alexellis/upload-assets@0.4.0
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          asset_paths: '["./**/*.tar.*","./**/*.AppImage","./**/*.7z","./**/*.zip","./**/*.apk","./**/*.aab"]'