build.yml 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. name: Build job
  2. on:
  3. workflow_call:
  4. env:
  5. POWERSHELL_TELEMETRY_OPTOUT: 1
  6. DOTNET_CLI_TELEMETRY_OPTOUT: 1
  7. RYUJINX_BASE_VERSION: "1.2.0"
  8. jobs:
  9. build:
  10. name: ${{ matrix.platform.name }} (${{ matrix.configuration }})
  11. runs-on: ${{ matrix.platform.os }}
  12. timeout-minutes: 45
  13. strategy:
  14. matrix:
  15. configuration: [Debug, Release]
  16. platform:
  17. - { name: win-x64, os: windows-latest, zip_os_name: win_x64 }
  18. - { name: linux-x64, os: ubuntu-latest, zip_os_name: linux_x64 }
  19. - { name: linux-arm64, os: ubuntu-latest, zip_os_name: linux_arm64 }
  20. - { name: osx-x64, os: macos-13, zip_os_name: osx_x64 }
  21. fail-fast: false
  22. steps:
  23. - uses: actions/checkout@v4
  24. - uses: actions/setup-dotnet@v4
  25. with:
  26. global-json-file: global.json
  27. - name: Overwrite csc problem matcher
  28. run: echo "::add-matcher::.github/csc.json"
  29. - name: Get git short hash
  30. id: git_short_hash
  31. run: echo "result=$(git rev-parse --short "${{ github.sha }}")" >> $GITHUB_OUTPUT
  32. shell: bash
  33. - name: Change config filename
  34. run: sed -r --in-place 's/\%\%RYUJINX_CONFIG_FILE_NAME\%\%/PRConfig\.json/g;' src/Ryujinx.Common/ReleaseInformation.cs
  35. shell: bash
  36. if: github.event_name == 'pull_request' && matrix.platform.os != 'macos-13'
  37. - name: Change config filename for macOS
  38. run: sed -r -i '' 's/\%\%RYUJINX_CONFIG_FILE_NAME\%\%/PRConfig\.json/g;' src/Ryujinx.Common/ReleaseInformation.cs
  39. shell: bash
  40. if: github.event_name == 'pull_request' && matrix.platform.os == 'macos-13'
  41. - name: Build
  42. run: dotnet build -c "${{ matrix.configuration }}" -p:Version="${{ env.RYUJINX_BASE_VERSION }}" -p:SourceRevisionId="${{ steps.git_short_hash.outputs.result }}" -p:ExtraDefineConstants=DISABLE_UPDATER
  43. - name: Test
  44. uses: TSRBerry/unstable-commands@v1
  45. with:
  46. commands: dotnet test --no-build -c "${{ matrix.configuration }}"
  47. timeout-minutes: 10
  48. retry-codes: 139
  49. if: matrix.platform.name != 'linux-arm64'
  50. - name: Publish Ryujinx
  51. 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
  52. if: github.event_name == 'pull_request' && matrix.platform.os != 'macos-13'
  53. - name: Publish Ryujinx.Headless.SDL2
  54. 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
  55. if: github.event_name == 'pull_request' && matrix.platform.os != 'macos-13'
  56. - name: Set executable bit
  57. run: |
  58. chmod +x ./publish/Ryujinx ./publish/Ryujinx.sh
  59. chmod +x ./publish_sdl2_headless/Ryujinx.Headless.SDL2 ./publish_sdl2_headless/Ryujinx.sh
  60. if: github.event_name == 'pull_request' && matrix.platform.os == 'ubuntu-latest'
  61. - name: Build AppImage
  62. if: github.event_name == 'pull_request' && matrix.platform.os == 'ubuntu-latest'
  63. run: |
  64. PLATFORM_NAME="${{ matrix.platform.name }}"
  65. sudo apt install -y zsync desktop-file-utils appstream
  66. mkdir -p tools
  67. export PATH="$PATH:$(readlink -f tools)"
  68. # Setup appimagetool
  69. wget -q -O tools/appimagetool "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage"
  70. chmod +x tools/appimagetool
  71. chmod +x distribution/linux/appimage/build-appimage.sh
  72. # Explicitly set $ARCH for appimagetool ($ARCH_NAME is for the file name)
  73. if [ "$PLATFORM_NAME" = "linux-x64" ]; then
  74. ARCH_NAME=x64
  75. export ARCH=x86_64
  76. elif [ "$PLATFORM_NAME" = "linux-arm64" ]; then
  77. ARCH_NAME=arm64
  78. export ARCH=aarch64
  79. else
  80. echo "Unexpected PLATFORM_NAME "$PLATFORM_NAME""
  81. exit 1
  82. fi
  83. export UFLAG="gh-releases-zsync|${{ github.repository_owner }}|${{ github.event.repository.name }}|latest|*-$ARCH_NAME.AppImage.zsync"
  84. BUILDDIR=publish OUTDIR=publish_appimage distribution/linux/appimage/build-appimage.sh
  85. shell: bash
  86. env:
  87. RELEASE=0
  88. - name: Upload Ryujinx artifact
  89. uses: actions/upload-artifact@v4
  90. with:
  91. name: ryujinx-${{ matrix.configuration }}-${{ env.RYUJINX_BASE_VERSION }}+${{ steps.git_short_hash.outputs.result }}-${{ matrix.platform.zip_os_name }}
  92. path: publish
  93. if: github.event_name == 'pull_request' && matrix.platform.os != 'macos-13'
  94. - name: Upload Ryujinx (AppImage) artifact
  95. uses: actions/upload-artifact@v4
  96. if: github.event_name == 'pull_request' && matrix.platform.os == 'ubuntu-latest'
  97. with:
  98. name: ryujinx-${{ matrix.configuration }}-${{ env.RYUJINX_BASE_VERSION }}+${{ steps.git_short_hash.outputs.result }}-${{ matrix.platform.zip_os_name }}-AppImage
  99. path: publish_appimage
  100. - name: Upload Ryujinx.Headless.SDL2 artifact
  101. uses: actions/upload-artifact@v4
  102. with:
  103. name: sdl2-ryujinx-headless-${{ matrix.configuration }}-${{ env.RYUJINX_BASE_VERSION }}+${{ steps.git_short_hash.outputs.result }}-${{ matrix.platform.zip_os_name }}
  104. path: publish_sdl2_headless
  105. if: github.event_name == 'pull_request' && matrix.platform.os != 'macos-13'
  106. build_macos:
  107. name: macOS Universal (${{ matrix.configuration }})
  108. runs-on: ubuntu-latest
  109. timeout-minutes: 45
  110. strategy:
  111. matrix:
  112. configuration: [ Debug, Release ]
  113. steps:
  114. - uses: actions/checkout@v4
  115. - uses: actions/setup-dotnet@v4
  116. with:
  117. global-json-file: global.json
  118. - name: Setup LLVM 14
  119. run: |
  120. wget https://apt.llvm.org/llvm.sh
  121. chmod +x llvm.sh
  122. sudo ./llvm.sh 14
  123. - name: Install rcodesign
  124. run: |
  125. mkdir -p $HOME/.bin
  126. gh release download -R indygreg/apple-platform-rs -O apple-codesign.tar.gz -p 'apple-codesign-*-x86_64-unknown-linux-musl.tar.gz'
  127. tar -xzvf apple-codesign.tar.gz --wildcards '*/rcodesign' --strip-components=1
  128. rm apple-codesign.tar.gz
  129. mv rcodesign $HOME/.bin/
  130. echo "$HOME/.bin" >> $GITHUB_PATH
  131. env:
  132. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  133. - name: Get git short hash
  134. id: git_short_hash
  135. run: echo "result=$(git rev-parse --short "${{ github.sha }}")" >> $GITHUB_OUTPUT
  136. - name: Change config filename
  137. run: sed -r --in-place 's/\%\%RYUJINX_CONFIG_FILE_NAME\%\%/PRConfig\.json/g;' src/Ryujinx.Common/ReleaseInformation.cs
  138. shell: bash
  139. if: github.event_name == 'pull_request'
  140. - name: Publish macOS Ryujinx
  141. run: |
  142. ./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"
  143. - name: Publish macOS Ryujinx.Headless.SDL2
  144. run: |
  145. ./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"
  146. - name: Upload Ryujinx artifact
  147. uses: actions/upload-artifact@v4
  148. with:
  149. name: ryujinx-${{ matrix.configuration }}-${{ env.RYUJINX_BASE_VERSION }}+${{ steps.git_short_hash.outputs.result }}-macos_universal
  150. path: "publish/*.tar.gz"
  151. if: github.event_name == 'pull_request'
  152. - name: Upload Ryujinx.Headless.SDL2 artifact
  153. uses: actions/upload-artifact@v4
  154. with:
  155. name: sdl2-ryujinx-headless-${{ matrix.configuration }}-${{ env.RYUJINX_BASE_VERSION }}+${{ steps.git_short_hash.outputs.result }}-macos_universal
  156. path: "publish_headless/*.tar.gz"
  157. if: github.event_name == 'pull_request'