build: refactor build to host-first CMake with nxdk child (#151) #333
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| name: CI | |
| permissions: {} | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - master | |
| concurrency: | |
| group: "${{ github.workflow }}-${{ github.ref }}" | |
| cancel-in-progress: true | |
| jobs: | |
| setup_release: | |
| name: Setup Release | |
| outputs: | |
| publish_release: ${{ steps.setup_release.outputs.publish_release }} | |
| release_body: ${{ steps.setup_release.outputs.release_body }} | |
| release_commit: ${{ steps.setup_release.outputs.release_commit }} | |
| release_generate_release_notes: ${{ steps.setup_release.outputs.release_generate_release_notes }} | |
| release_tag: ${{ steps.setup_release.outputs.release_tag }} | |
| release_version: ${{ steps.setup_release.outputs.release_version }} | |
| permissions: | |
| contents: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Setup Release | |
| id: setup_release | |
| uses: LizardByte/actions/actions/release_setup@0affa4f7bcb27562658960eee840eff8ff844578 # v2026.328.161128 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| build: | |
| name: Build (${{ matrix.os }}) | |
| needs: setup_release | |
| permissions: | |
| contents: read | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: macos-latest | |
| shell: "bash" | |
| - os: ubuntu-latest | |
| shell: "bash" | |
| - os: windows-latest | |
| shell: "msys2 {0}" | |
| defaults: | |
| run: | |
| shell: ${{ matrix.shell }} | |
| env: | |
| CMAKE_BUILD: build | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| submodules: recursive | |
| - name: Setup Dependencies Linux | |
| if: runner.os == 'Linux' | |
| run: | | |
| nxdk_dependencies=( | |
| "bison" | |
| "build-essential" | |
| "clang" | |
| "cmake" | |
| "flex" | |
| "git" | |
| "lld" | |
| "llvm" | |
| ) | |
| moonlight_dependencies=( | |
| ) | |
| dependencies=("${nxdk_dependencies[@]}" "${moonlight_dependencies[@]}") | |
| sudo apt-get update | |
| sudo apt-get install --no-install-recommends -y "${dependencies[@]}" | |
| - name: Setup Dependencies macOS | |
| if: runner.os == 'macOS' | |
| run: | | |
| nxdk_dependencies=( | |
| "cmake" | |
| "coreutils" | |
| "lld" | |
| "llvm" | |
| ) | |
| moonlight_dependencies=( | |
| ) | |
| dependencies=("${nxdk_dependencies[@]}" "${moonlight_dependencies[@]}") | |
| brew install "${dependencies[@]}" | |
| - name: Setup Dependencies Windows | |
| if: runner.os == 'Windows' | |
| uses: msys2/setup-msys2@cafece8e6baf9247cf9b1bf95097b0b983cc558d # v2.31.0 | |
| with: | |
| msystem: MINGW64 | |
| update: true | |
| install: >- | |
| bison | |
| cmake | |
| flex | |
| git | |
| make | |
| mingw-w64-x86_64-clang | |
| mingw-w64-x86_64-gcc | |
| mingw-w64-x86_64-lld | |
| mingw-w64-x86_64-llvm | |
| - name: Setup python | |
| id: setup-python | |
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | |
| with: | |
| python-version: '3.14' | |
| - name: Python Path | |
| id: python-path | |
| run: | | |
| if [ "${{ runner.os }}" = "Windows" ]; then | |
| # replace backslashes with double backslashes | |
| python_path=$(echo "${{ steps.setup-python.outputs.python-path }}" | sed 's/\\/\\\\/g') | |
| else | |
| python_path=${{ steps.setup-python.outputs.python-path }} | |
| fi | |
| # step output | |
| echo "python-path=${python_path}" | |
| echo "python-path=${python_path}" >> $GITHUB_OUTPUT | |
| - name: Build | |
| run: | | |
| chmod +x build.sh | |
| ./build.sh --build-dir ${CMAKE_BUILD} | |
| # recursively list all files in build directory | |
| ls -R ${CMAKE_BUILD} | |
| # move artifacts | |
| mkdir -p artifacts | |
| tar -czf ./artifacts/Moonlight.tar.gz ./${CMAKE_BUILD}/xbox/xbe | |
| cp ./${CMAKE_BUILD}/xbox/Moonlight.iso ./artifacts | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | |
| with: | |
| name: moonlight-${{ runner.os }} | |
| path: artifacts/ | |
| - name: Run tests | |
| id: test | |
| working-directory: ${{ env.CMAKE_BUILD }}/tests | |
| run: ./test_moonlight --gtest_color=yes --gtest_output=xml:test_results.xml | |
| - name: Generate gcov report | |
| id: test_report | |
| # any except canceled or skipped | |
| if: >- | |
| always() && | |
| (steps.test.outcome == 'success' || steps.test.outcome == 'failure') | |
| run: | | |
| ${{ steps.python-path.outputs.python-path }} -m pip install ".[test]" | |
| ${{ steps.python-path.outputs.python-path }} -m gcovr ${CMAKE_BUILD} -r . \ | |
| --filter src \ | |
| --exclude-noncode-lines \ | |
| --exclude-throw-branches \ | |
| --exclude-unreachable-branches \ | |
| --verbose \ | |
| --xml-pretty \ | |
| -o "${CMAKE_BUILD}/coverage.xml" | |
| - name: Debug coverage file | |
| if: >- | |
| always() && | |
| steps.test_report.outcome == 'success' | |
| run: cat "${CMAKE_BUILD}/coverage.xml" | |
| - name: Upload coverage | |
| # any except canceled or skipped | |
| if: >- | |
| always() && | |
| (steps.test.outcome == 'success' || steps.test.outcome == 'failure') && | |
| startsWith(github.repository, 'LizardByte/') | |
| uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0 | |
| with: | |
| disable_search: true | |
| fail_ci_if_error: true | |
| files: ./${{ env.CMAKE_BUILD }}/coverage.xml | |
| flags: ${{ runner.os }} | |
| report_type: coverage | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| verbose: true | |
| - name: Upload test results | |
| # any except canceled or skipped | |
| if: >- | |
| always() && | |
| (steps.test.outcome == 'success' || steps.test.outcome == 'failure') && | |
| startsWith(github.repository, 'LizardByte/') | |
| uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0 | |
| with: | |
| disable_search: true | |
| fail_ci_if_error: true | |
| files: ./${{ env.CMAKE_BUILD }}/tests/test_results.xml | |
| flags: ${{ runner.os }} | |
| handle_no_reports_found: true | |
| report_type: test_results | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| verbose: true | |
| - name: Create/Update GitHub Release | |
| # only publish release on ubuntu-latest, is there any difference between the different builds? | |
| if: needs.setup_release.outputs.publish_release == 'true' && matrix.os == 'ubuntu-latest' | |
| uses: LizardByte/actions/actions/release_create@0affa4f7bcb27562658960eee840eff8ff844578 # v2026.328.161128 | |
| with: | |
| allowUpdates: false | |
| body: ${{ needs.setup_release.outputs.release_body }} | |
| draft: true | |
| generateReleaseNotes: ${{ needs.setup_release.outputs.release_generate_release_notes }} | |
| name: ${{ needs.setup_release.outputs.release_tag }} | |
| prerelease: true | |
| tag: ${{ needs.setup_release.outputs.release_tag }} | |
| token: ${{ secrets.GH_BOT_TOKEN }} |