aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/build.yml
blob: 221c7732e9ef50a1251483e096aeeed1fbba4ad4 (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
name: Build job

on:
  workflow_call:

env:
  POWERSHELL_TELEMETRY_OPTOUT: 1
  DOTNET_CLI_TELEMETRY_OPTOUT: 1
  RYUJINX_BASE_VERSION: "1.1.0"

jobs:
  build:
    name: ${{ matrix.platform.name }} (${{ matrix.configuration }})
    runs-on: ${{ matrix.platform.os }}
    timeout-minutes: 45
    strategy:
      matrix:
        configuration: [Debug, Release]
        platform:
          - { name: win-x64,     os: windows-latest, zip_os_name: win_x64     }
          - { name: linux-x64,   os: ubuntu-latest,  zip_os_name: linux_x64   }
          - { name: linux-arm64, os: ubuntu-latest,  zip_os_name: linux_arm64 }
          - { name: osx-x64,     os: macos-13,       zip_os_name: osx_x64     }

      fail-fast: false
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-dotnet@v4
        with:
          global-json-file: global.json

      - name: Overwrite csc problem matcher
        run: echo "::add-matcher::.github/csc.json"

      - name: Get git short hash
        id: git_short_hash
        run: echo "result=$(git rev-parse --short "${{ github.sha }}")" >> $GITHUB_OUTPUT
        shell: bash

      - name: Change config filename
        run: sed -r --in-place 's/\%\%RYUJINX_CONFIG_FILE_NAME\%\%/PRConfig\.json/g;' src/Ryujinx.Common/ReleaseInformation.cs
        shell: bash
        if: github.event_name == 'pull_request' && matrix.platform.os != 'macos-13'

      - name: Change config filename for macOS
        run: sed -r -i '' 's/\%\%RYUJINX_CONFIG_FILE_NAME\%\%/PRConfig\.json/g;' src/Ryujinx.Common/ReleaseInformation.cs
        shell: bash
        if: github.event_name == 'pull_request' && matrix.platform.os == 'macos-13'

      - name: Build
        run: dotnet build -c "${{ matrix.configuration }}" -p:Version="${{ env.RYUJINX_BASE_VERSION }}" -p:SourceRevisionId="${{ steps.git_short_hash.outputs.result }}" -p:ExtraDefineConstants=DISABLE_UPDATER

      - name: Test
        uses: TSRBerry/unstable-commands@v1
        with:
          commands: dotnet test --no-build -c "${{ matrix.configuration }}"
          timeout-minutes: 10
          retry-codes: 139
        if: matrix.platform.name != 'linux-arm64'

      - name: Publish Ryujinx
        run: dotnet publish -c "${{ matrix.configuration }}" -r "${{ matrix.platform.name }}" -o ./publish -p:Version="${{ env.RYUJINX_BASE_VERSION }}" -p:DebugType=embedded -p:SourceRevisionId="${{ steps.git_short_hash.outputs.result }}" -p:ExtraDefineConstants=DISABLE_UPDATER src/Ryujinx --self-contained true
        if: github.event_name == 'pull_request' && matrix.platform.os != 'macos-13'

      - name: Publish Ryujinx.Headless.SDL2
        run: dotnet publish -c "${{ matrix.configuration }}" -r "${{ matrix.platform.name }}" -o ./publish_sdl2_headless -p:Version="${{ env.RYUJINX_BASE_VERSION }}" -p:DebugType=embedded -p:SourceRevisionId="${{ steps.git_short_hash.outputs.result }}" -p:ExtraDefineConstants=DISABLE_UPDATER src/Ryujinx.Headless.SDL2 --self-contained true
        if: github.event_name == 'pull_request' && matrix.platform.os != 'macos-13'

      - name: Publish Ryujinx.Gtk3
        run: dotnet publish -c "${{ matrix.configuration }}" -r "${{ matrix.platform.name }}" -o ./publish_gtk -p:Version="${{ env.RYUJINX_BASE_VERSION }}" -p:DebugType=embedded -p:SourceRevisionId="${{ steps.git_short_hash.outputs.result }}" -p:ExtraDefineConstants=DISABLE_UPDATER src/Ryujinx.Gtk3 --self-contained true
        if: github.event_name == 'pull_request' && matrix.platform.os != 'macos-13'

      - name: Set executable bit
        run: |
          chmod +x ./publish/Ryujinx ./publish/Ryujinx.sh
          chmod +x ./publish_sdl2_headless/Ryujinx.Headless.SDL2 ./publish_sdl2_headless/Ryujinx.sh
          chmod +x ./publish_gtk/Ryujinx.Gtk3 ./publish_gtk/Ryujinx.sh
        if: github.event_name == 'pull_request' && matrix.platform.os == 'ubuntu-latest'

      - name: Upload Ryujinx artifact
        uses: actions/upload-artifact@v4
        with:
          name: ryujinx-${{ matrix.configuration }}-${{ env.RYUJINX_BASE_VERSION }}+${{ steps.git_short_hash.outputs.result }}-${{ matrix.platform.zip_os_name }}
          path: publish
        if: github.event_name == 'pull_request' && matrix.platform.os != 'macos-13'

      - name: Upload Ryujinx.Headless.SDL2 artifact
        uses: actions/upload-artifact@v4
        with:
          name: sdl2-ryujinx-headless-${{ matrix.configuration }}-${{ env.RYUJINX_BASE_VERSION }}+${{ steps.git_short_hash.outputs.result }}-${{ matrix.platform.zip_os_name }}
          path: publish_sdl2_headless
        if: github.event_name == 'pull_request' && matrix.platform.os != 'macos-13'

      - name: Upload Ryujinx.Gtk3 artifact
        uses: actions/upload-artifact@v4
        with:
          name: gtk-ryujinx-${{ matrix.configuration }}-${{ env.RYUJINX_BASE_VERSION }}+${{ steps.git_short_hash.outputs.result }}-${{ matrix.platform.zip_os_name }}
          path: publish_gtk
        if: github.event_name == 'pull_request' && matrix.platform.os != 'macos-13'

  build_macos:
    name: macOS Universal (${{ matrix.configuration }})
    runs-on: ubuntu-latest
    timeout-minutes: 45
    strategy:
      matrix:
        configuration: [ Debug, Release ]

    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-dotnet@v4
        with:
          global-json-file: global.json

      - name: Setup LLVM 14
        run: |
          wget https://apt.llvm.org/llvm.sh
          chmod +x llvm.sh
          sudo ./llvm.sh 14

      - name: Install rcodesign
        run: |
          mkdir -p $HOME/.bin
          gh release download -R indygreg/apple-platform-rs -O apple-codesign.tar.gz -p 'apple-codesign-*-x86_64-unknown-linux-musl.tar.gz'
          tar -xzvf apple-codesign.tar.gz --wildcards '*/rcodesign' --strip-components=1
          rm apple-codesign.tar.gz
          mv rcodesign $HOME/.bin/
          echo "$HOME/.bin" >> $GITHUB_PATH
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Get git short hash
        id: git_short_hash
        run: echo "result=$(git rev-parse --short "${{ github.sha }}")" >> $GITHUB_OUTPUT

      - name: Change config filename
        run: sed -r --in-place 's/\%\%RYUJINX_CONFIG_FILE_NAME\%\%/PRConfig\.json/g;' src/Ryujinx.Common/ReleaseInformation.cs
        shell: bash
        if: github.event_name == 'pull_request'

      - name: Publish macOS Ryujinx
        run: |
          ./distribution/macos/create_macos_build_ava.sh . publish_tmp publish ./distribution/macos/entitlements.xml "${{ env.RYUJINX_BASE_VERSION }}" "${{ steps.git_short_hash.outputs.result }}" "${{ matrix.configuration }}" "-p:ExtraDefineConstants=DISABLE_UPDATER"

      - name: Publish macOS Ryujinx.Headless.SDL2
        run: |
          ./distribution/macos/create_macos_build_headless.sh . publish_tmp_headless publish_headless ./distribution/macos/entitlements.xml "${{ env.RYUJINX_BASE_VERSION }}" "${{ steps.git_short_hash.outputs.result }}" "${{ matrix.configuration }}" "-p:ExtraDefineConstants=DISABLE_UPDATER"

      - name: Upload Ryujinx artifact
        uses: actions/upload-artifact@v4
        with:
          name: ryujinx-${{ matrix.configuration }}-${{ env.RYUJINX_BASE_VERSION }}+${{ steps.git_short_hash.outputs.result }}-macos_universal
          path: "publish/*.tar.gz"
        if: github.event_name == 'pull_request'

      - name: Upload Ryujinx.Headless.SDL2 artifact
        uses: actions/upload-artifact@v4
        with:
          name: sdl2-ryujinx-headless-${{ matrix.configuration }}-${{ env.RYUJINX_BASE_VERSION }}+${{ steps.git_short_hash.outputs.result }}-macos_universal
          path: "publish_headless/*.tar.gz"
        if: github.event_name == 'pull_request'