build.yml 6.7 KB

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