name: Build Mesen on: [push, pull_request] env: DOTNET_CLI_TELEMETRY_OPTOUT: 1 DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 jobs: windows: if: ${{ (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository) }} strategy: matrix: platform: [ {netversion: 6.x, targetframework: net6.0, aot: false, singleFile: true, aotString: ""}, {netversion: 8.x, targetframework: net8.0, aot: false, singleFile: true, aotString: ""}, {netversion: 8.x, targetframework: net8.0, aot: true, singleFile: false, aotString: " - AoT"} ] fail-fast: false runs-on: windows-2025-vs2026 steps: - name: Checkout repo uses: actions/checkout@v6 with: fetch-depth: 0 - name: Install .NET Core uses: actions/setup-dotnet@v5 with: dotnet-version: ${{ matrix.platform.netversion }} - name: Setup MSBuild.exe uses: microsoft/setup-msbuild@v3 with: msbuild-architecture: x64 - name: Restore packages run: dotnet restore -p:TargetFramework="${{ matrix.platform.targetframework }}" -r win-x64 -p:PublishAot="${{ matrix.platform.aot }}" -p:BuildWithNetFrameworkHostedCompiler=true - name: Write commit SHA1 to file uses: ./.github/actions/build-sha1-action - name: Build Mesen run: msbuild -nologo -v:d -clp:ForceConsoleColor -m -p:Configuration=Release -p:Platform=x64 -t:Clean,UI -p:TargetFramework="${{ matrix.platform.targetframework }}" - name: Publish Mesen run: dotnet publish --no-restore -c Release -p:PublishAot="${{ matrix.platform.aot }}" -p:SelfContained="${{ matrix.platform.aot }}" -p:PublishSingleFile="${{ matrix.platform.singleFile }}" -p:OptimizeUi="true" -p:Platform="Any CPU" -p:TargetFramework="${{ matrix.platform.targetframework }}" -r win-x64 Mesen.sln /p:PublishProfile=UI\Properties\PublishProfiles\Release.pubxml - name: Upload Mesen uses: actions/upload-artifact@v7 if: github.event_name != 'pull_request' with: name: Mesen (Windows - ${{ matrix.platform.targetframework }}${{ matrix.platform.aotString }}) path: | build/TmpReleaseBuild/Mesen.exe linux: if: ${{ (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository) }} strategy: matrix: compiler: [gcc, clang, clang_aot] platform: [ {os: ubuntu-22.04, path: x64}, {os: ubuntu-22.04-arm, path: arm64} ] include: - compiler: gcc make_flags: "USE_GCC=true" - compiler: clang make_flags: "" - compiler: clang_aot make_flags: "USE_AOT=true" fail-fast: false runs-on: ${{ matrix.platform.os }} steps: - name: Checkout repo uses: actions/checkout@v6 with: fetch-depth: 0 - name: Install .NET Core uses: actions/setup-dotnet@v5 with: dotnet-version: 8.x - name: Install dependencies run: | sudo apt-get update -qy sudo apt-get install -qy libsdl2-dev ccache # The compilers are already installed on GitHub's runners. - name: Setup CCache uses: ./.github/actions/setup-ccache-action - name: Write commit SHA1 to file uses: ./.github/actions/build-sha1-action # stderr is not detected as a TTY, so diagnostics are by default printed without colours; # forcing colours makes the log a little nicer to read. - name: Build Mesen run: | make -j$(nproc) -O ${{ matrix.make_flags }} LTO=true STATICLINK=true SYSTEM_LIBEVDEV=false - name: Upload Mesen uses: actions/upload-artifact@v7 if: github.event_name != 'pull_request' with: name: Mesen (Linux - ${{ matrix.platform.os }} - ${{ matrix.compiler }}) path: bin/linux-${{ matrix.platform.path }}/Release/linux-${{ matrix.platform.path }}/publish/Mesen appimage: if: ${{ (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository) }} strategy: matrix: compiler: [clang_appimage] platform: [ {os: ubuntu-22.04, name: x64, script: Linux/appimage/appimage.sh}, {os: ubuntu-22.04-arm, name: ARM64, script: Linux/appimage/appimage-arm64.sh} ] runs-on: ${{ matrix.platform.os }} steps: - name: Checkout repo uses: actions/checkout@v6 with: fetch-depth: 0 - name: Install .NET Core uses: actions/setup-dotnet@v5 with: dotnet-version: 8.x - name: Install dependencies run: | sudo apt-get update -qy sudo apt-get install -qy libsdl2-dev libfuse2 ccache # The compilers are already installed on GitHub's runners. - name: Setup CCache uses: ./.github/actions/setup-ccache-action - name: Write commit SHA1 to file uses: ./.github/actions/build-sha1-action - name: Build Mesen (AppImage) run: | ${{ matrix.platform.script }} - name: Upload Mesen (AppImage) uses: actions/upload-artifact@v7 if: github.event_name != 'pull_request' with: name: Mesen (Linux ${{ matrix.platform.name }} - AppImage) path: Mesen.AppImage macos: if: ${{ (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository) }} strategy: matrix: compiler: [clang, clang_aot] platform: [ {os: macos-15-intel, arch: x64}, {os: macos-15, arch: arm64} ] include: - compiler: clang make_flags: "" - compiler: clang_aot make_flags: "USE_AOT=true" fail-fast: false runs-on: ${{ matrix.platform.os }} steps: - name: Checkout repo uses: actions/checkout@v6 with: fetch-depth: 0 - name: Install .NET Core uses: actions/setup-dotnet@v5 with: dotnet-version: 8.x - name: Install dependencies run: | brew install sdl2 ccache - name: Get brew prefix run: | echo "brewPrefix=$(brew --prefix)" >> "$GITHUB_ENV" - name: Setup CCache uses: ./.github/actions/setup-ccache-action with: ccache-path: '${{ env.brewPrefix }}/opt/ccache/libexec' - name: Write commit SHA1 to file uses: ./.github/actions/build-sha1-action # stderr is not detected as a TTY, so diagnostics are by default printed without colours; # forcing colours makes the log a little nicer to read. - name: Build Mesen run: | ${{ matrix.make_flags }} make -j$(sysctl -n hw.logicalcpu) - name: Sign binary if: github.event_name != 'pull_request' env: APP_NAME: bin/osx-${{ matrix.platform.arch }}/Release/osx-${{ matrix.platform.arch }}/publish/Mesen.app CERT_DATA: ${{ secrets.MACOS_CERTIFICATE }} CERT_PASS: ${{ secrets.MACOS_CERTIFICATE_PWD }} ENTITLEMENTS: UI/Mesen.entitlements SIGNING_IDENTITY: Mesen run: | # Export certs echo "$CERT_DATA" | base64 --decode > /tmp/certs.p12 # Create keychain security create-keychain -p actions macos-build.keychain security default-keychain -s macos-build.keychain security unlock-keychain -p actions macos-build.keychain security set-keychain-settings -t 3600 -u macos-build.keychain # Import certs to keychain security import /tmp/certs.p12 -k ~/Library/Keychains/macos-build.keychain -P "$CERT_PASS" -T /usr/bin/codesign -T /usr/bin/productsign # Key signing security set-key-partition-list -S apple-tool:,apple: -s -k actions macos-build.keychain # print identities security find-identity -v macos-build.keychain echo "[INFO] Signing app file" codesign --force --deep --timestamp --keychain macos-build.keychain --options=runtime --entitlements "$ENTITLEMENTS" --sign "$SIGNING_IDENTITY" "$APP_NAME" - name: Zip Mesen.app if: github.event_name != 'pull_request' run: | ditto -c -k --sequesterRsrc --keepParent bin/osx-${{ matrix.platform.arch }}/Release/osx-${{ matrix.platform.arch }}/publish/Mesen.app bin/osx-${{ matrix.platform.arch }}/Release/Mesen.app.zip - name: Upload Mesen uses: actions/upload-artifact@v7 if: github.event_name != 'pull_request' with: name: Mesen (macOS - ${{ matrix.platform.os }} - ${{ matrix.compiler }}) path: bin/osx-${{ matrix.platform.arch }}/Release/Mesen.app.zip