/ .github / workflows / build.yml
build.yml
  1  name: citra-build
  2  
  3  on:
  4    push:
  5      branches: [ "*" ]
  6      tags: [ "*" ]
  7    pull_request:
  8      branches: [ master ]
  9  
 10  jobs:
 11    source:
 12      if: ${{ !github.head_ref }}
 13      runs-on: ubuntu-latest
 14      steps:
 15        - uses: actions/checkout@v4
 16          with:
 17            submodules: recursive
 18        - name: Pack
 19          run: ./.ci/source.sh
 20        - name: Upload
 21          uses: actions/upload-artifact@v4
 22          with:
 23            name: source
 24            path: artifacts/
 25    linux:
 26      runs-on: ubuntu-latest
 27      strategy:
 28        matrix:
 29          target: ["appimage", "fresh"]
 30      container:
 31        image: citraemu/build-environments:linux-${{ matrix.target }}
 32        options: -u 1001
 33      env:
 34        CCACHE_DIR: ${{ github.workspace }}/.ccache
 35        CCACHE_COMPILERCHECK: content
 36        CCACHE_SLOPPINESS: time_macros
 37        OS: linux
 38        TARGET: ${{ matrix.target }}
 39      steps:
 40        - uses: actions/checkout@v4
 41          with:
 42            submodules: recursive
 43        - name: Set up cache
 44          uses: actions/cache@v4
 45          with:
 46            path: ${{ env.CCACHE_DIR }}
 47            key: ${{ runner.os }}-${{ matrix.target }}-${{ github.sha }}
 48            restore-keys: |
 49              ${{ runner.os }}-${{ matrix.target }}-
 50        - name: Build
 51          run: ./.ci/linux.sh
 52        - name: Pack
 53          run: ./.ci/pack.sh
 54          if: ${{ matrix.target == 'appimage' }}
 55        - name: Upload
 56          uses: actions/upload-artifact@v4
 57          if: ${{ matrix.target == 'appimage' }}
 58          with:
 59            name: ${{ env.OS }}-${{ env.TARGET }}
 60            path: artifacts/
 61    macos:
 62      runs-on: ${{ (matrix.target == 'x86_64' && 'macos-13') || 'macos-14' }}
 63      strategy:
 64        matrix:
 65          target: ["x86_64", "arm64"]
 66      env:
 67        CCACHE_DIR: ${{ github.workspace }}/.ccache
 68        CCACHE_COMPILERCHECK: content
 69        CCACHE_SLOPPINESS: time_macros
 70        OS: macos
 71        TARGET: ${{ matrix.target }}
 72      steps:
 73        - uses: actions/checkout@v4
 74          with:
 75            submodules: recursive
 76        - name: Set up cache
 77          uses: actions/cache@v4
 78          with:
 79            path: ${{ env.CCACHE_DIR }}
 80            key: ${{ runner.os }}-${{ matrix.target }}-${{ github.sha }}
 81            restore-keys: |
 82              ${{ runner.os }}-${{ matrix.target }}-
 83        - name: Install tools
 84          run: brew install ccache ninja
 85        - name: Build
 86          run: ./.ci/macos.sh
 87        - name: Prepare outputs for caching
 88          run: mv build/bundle $OS-$TARGET
 89        - name: Cache outputs for universal build
 90          uses: actions/cache/save@v4
 91          with:
 92            path: ${{ env.OS }}-${{ env.TARGET }}
 93            key: ${{ runner.os }}-${{ matrix.target }}-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
 94    macos-universal:
 95      runs-on: macos-14
 96      needs: macos
 97      env:
 98        OS: macos
 99        TARGET: universal
100      steps:
101        - uses: actions/checkout@v4
102        - name: Download x86_64 build from cache
103          uses: actions/cache/restore@v4
104          with:
105            path: ${{ env.OS }}-x86_64
106            key: ${{ runner.os }}-x86_64-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
107            fail-on-cache-miss: true
108        - name: Download ARM64 build from cache
109          uses: actions/cache/restore@v4
110          with:
111            path: ${{ env.OS }}-arm64
112            key: ${{ runner.os }}-arm64-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
113            fail-on-cache-miss: true
114        - name: Create universal app
115          run: ./.ci/macos-universal.sh
116          env:
117            ARTIFACTS: ${{ env.OS }}-x86_64 ${{ env.OS }}-arm64
118        - name: Pack
119          run: ./.ci/pack.sh
120        - name: Upload
121          uses: actions/upload-artifact@v4
122          with:
123            name: ${{ env.OS }}-${{ env.TARGET }}
124            path: artifacts/
125    windows:
126      runs-on: windows-latest
127      strategy:
128        matrix:
129          target: ["msvc", "msys2"]
130      defaults:
131        run:
132          shell: ${{ (matrix.target == 'msys2' && 'msys2') || 'bash' }} {0}
133      env:
134        CCACHE_DIR: ${{ github.workspace }}/.ccache
135        CCACHE_COMPILERCHECK: content
136        CCACHE_SLOPPINESS: time_macros
137        OS: windows
138        TARGET: ${{ matrix.target }}
139      steps:
140        - uses: actions/checkout@v4
141          with:
142            submodules: recursive
143        - name: Set up cache
144          uses: actions/cache@v4
145          with:
146            path: ${{ env.CCACHE_DIR }}
147            key: ${{ runner.os }}-${{ matrix.target }}-${{ github.sha }}
148            restore-keys: |
149              ${{ runner.os }}-${{ matrix.target }}-
150        - name: Set up MSVC
151          uses: ilammy/msvc-dev-cmd@v1
152          if: ${{ matrix.target == 'msvc' }}
153        - name: Install extra tools (MSVC)
154          run: choco install ccache ninja wget
155          if: ${{ matrix.target == 'msvc' }}
156        - name: Set up MSYS2
157          uses: msys2/setup-msys2@v2
158          if: ${{ matrix.target == 'msys2' }}
159          with:
160            msystem: clang64
161            update: true
162            install: git make p7zip
163            pacboy: >-
164              toolchain:p ccache:p cmake:p ninja:p
165              qt6-base:p qt6-multimedia:p qt6-multimedia-wmf:p qt6-tools:p qt6-translations:p
166        - name: Disable line ending translation
167          run: git config --global core.autocrlf input
168        - name: Build
169          run: ./.ci/windows.sh
170        - name: Pack
171          run: ./.ci/pack.sh
172        - name: Upload
173          uses: actions/upload-artifact@v4
174          with:
175            name: ${{ env.OS }}-${{ env.TARGET }}
176            path: artifacts/
177    android:
178      runs-on: ubuntu-latest
179      env:
180        CCACHE_DIR: ${{ github.workspace }}/.ccache
181        CCACHE_COMPILERCHECK: content
182        CCACHE_SLOPPINESS: time_macros
183        OS: android
184        TARGET: universal
185      steps:
186        - uses: actions/checkout@v4
187          with:
188            submodules: recursive
189        - name: Set up cache
190          uses: actions/cache@v4
191          with:
192            path: |
193              ~/.gradle/caches
194              ~/.gradle/wrapper
195              ${{ env.CCACHE_DIR }}
196            key: ${{ runner.os }}-android-${{ github.sha }}
197            restore-keys: |
198              ${{ runner.os }}-android-
199        - name: Set tag name
200          run: |
201            if [[ "$GITHUB_REF_NAME" =~ ^canary- ]] || [[ "$GITHUB_REF_NAME" =~ ^nightly- ]]; then
202                echo "GIT_TAG_NAME=$GITHUB_REF_NAME" >> $GITHUB_ENV
203            fi
204            echo $GIT_TAG_NAME
205        - name: Deps
206          run: |
207            sudo add-apt-repository -y ppa:theofficialgman/gpu-tools
208            sudo apt-get update -y
209            sudo apt-get install ccache apksigner -y
210        - name: Build
211          run: JAVA_HOME=$JAVA_HOME_17_X64 ./.ci/android.sh
212          env:
213            ANDROID_KEYSTORE_B64: ${{ secrets.ANDROID_KEYSTORE_B64 }}
214            ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
215            ANDROID_KEYSTORE_PASS: ${{ secrets.ANDROID_KEYSTORE_PASS }}
216        - name: Pack
217          run: ../../../.ci/pack.sh
218          working-directory: src/android/app
219          env:
220            UNPACKED: 1
221        - name: Upload
222          uses: actions/upload-artifact@v4
223          with:
224            name: ${{ env.OS }}-${{ env.TARGET }}
225            path: src/android/app/artifacts/
226    ios:
227      runs-on: macos-14
228      if: ${{ !startsWith(github.ref, 'refs/tags/') }}
229      env:
230        CCACHE_DIR: ${{ github.workspace }}/.ccache
231        CCACHE_COMPILERCHECK: content
232        CCACHE_SLOPPINESS: time_macros
233        OS: ios
234        TARGET: arm64
235      steps:
236        - uses: actions/checkout@v4
237          with:
238            submodules: recursive
239        - name: Set up cache
240          uses: actions/cache@v4
241          with:
242            path: ${{ env.CCACHE_DIR }}
243            key: ${{ runner.os }}-ios-${{ github.sha }}
244            restore-keys: |
245              ${{ runner.os }}-ios-
246        - name: Install tools
247          run: brew install ccache ninja
248        - name: Build
249          run: ./.ci/ios.sh
250    release:
251      runs-on: ubuntu-latest
252      needs: [windows, linux, macos-universal, android, source]
253      if: ${{ startsWith(github.ref, 'refs/tags/') }}
254      steps:
255        - uses: actions/download-artifact@v4
256        - name: Create release
257          uses: actions/create-release@v1
258          env:
259            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
260          with:
261            tag_name: ${{ github.ref_name }}
262            release_name: ${{ github.ref_name }}
263            draft: false
264            prerelease: false
265        - name: Upload artifacts
266          uses: alexellis/upload-assets@0.4.0
267          env:
268            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
269          with:
270            asset_paths: '["./**/*.tar.*","./**/*.AppImage","./**/*.7z","./**/*.zip","./**/*.apk","./**/*.aab"]'