From aa34084ba18e8c9c9ce183a707cd54f40e97752c Mon Sep 17 00:00:00 2001 From: Samuel <36420837+Samueru-sama@users.noreply.github.com> Date: Sun, 6 Oct 2024 02:34:01 -0400 Subject: [PATCH] infra: Add AppImage build workflow (#28) Co-authored-by: reggie --- .github/workflows/build.yml | 61 ++++++++++++++----- .gitignore | 8 ++- distribution/linux/appimage/AppRun | 3 + distribution/linux/appimage/build-appimage.sh | 30 +++++++++ 4 files changed, 85 insertions(+), 17 deletions(-) create mode 100755 distribution/linux/appimage/AppRun create mode 100755 distribution/linux/appimage/build-appimage.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fb54516f..4d5c3765 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,65 +40,98 @@ jobs: shell: bash - name: Change config filename + if: github.event_name == 'pull_request' && matrix.platform.os != 'macos-13' 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 + if: github.event_name == 'pull_request' && matrix.platform.os == 'macos-13' 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 + - name: Run tests + uses: ryujinx-mirror/unstable-commands@releases/v1.0.6 + if: matrix.platform.name != 'linux-arm64' 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' + 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 - 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' + 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 - 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' + 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 - name: Set executable bit + if: github.event_name == 'pull_request' && matrix.platform.os == 'ubuntu-latest' 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 + + - name: Build AppImage if: github.event_name == 'pull_request' && matrix.platform.os == 'ubuntu-latest' + run: | + PLATFORM_NAME="${{ matrix.platform.name }}" + + sudo apt install -y zsync desktop-file-utils appstream + + mkdir -p tools + export PATH="$PATH:$(readlink -f tools)" + + # Setup appimagetool + wget -q -O tools/appimagetool "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage" + chmod +x tools/appimagetool + + if [ "$PLATFORM_NAME" = "linux-x64" ]; then + export ARCH=x86_64 + elif [ "$PLATFORM_NAME" = "linux-arm64" ]; then + export ARCH=aarch64 + else + echo "Unexpected PLATFORM_NAME "$PLATFORM_NAME"" + exit 1 + fi + + BUILDDIR=publish OUTDIR=publish_appimage distribution/linux/appimage/build-appimage.sh + shell: bash - name: Upload Ryujinx artifact uses: actions/upload-artifact@v4 + if: github.event_name == 'pull_request' && matrix.platform.os != 'macos-13' 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 (AppImage) artifact + uses: actions/upload-artifact@v4 + if: github.event_name == 'pull_request' && matrix.platform.os == 'ubuntu-latest' + with: + name: ryujinx-${{ matrix.configuration }}-${{ env.RYUJINX_BASE_VERSION }}+${{ steps.git_short_hash.outputs.result }}-${{ matrix.platform.zip_os_name }}-AppImage + path: publish_appimage - name: Upload Ryujinx.Headless.SDL2 artifact uses: actions/upload-artifact@v4 + if: github.event_name == 'pull_request' && matrix.platform.os != 'macos-13' 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 + if: github.event_name == 'pull_request' && matrix.platform.os != 'macos-13' 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 }}) @@ -137,9 +170,9 @@ jobs: run: echo "result=$(git rev-parse --short "${{ github.sha }}")" >> $GITHUB_OUTPUT - name: Change config filename + if: github.event_name == 'pull_request' 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: | @@ -151,14 +184,14 @@ jobs: - name: Upload Ryujinx artifact uses: actions/upload-artifact@v4 + if: github.event_name == 'pull_request' 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 + if: github.event_name == 'pull_request' 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' diff --git a/.gitignore b/.gitignore index 37b419d0..1ffd88a8 100644 --- a/.gitignore +++ b/.gitignore @@ -10,13 +10,15 @@ # Build results -[Dd]ebug/ -[Rr]elease/ +[Dd]ebug*/ +[Rr]elease*/ x64/ build/ [Bb]in/ [Oo]bj/ +AppDir/ + # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets !packages/*/build/ @@ -95,7 +97,7 @@ DocProject/Help/Html2 DocProject/Help/html # Click-Once directory -publish/ +publish*/ # Publish Web Output *.Publish.xml diff --git a/distribution/linux/appimage/AppRun b/distribution/linux/appimage/AppRun new file mode 100755 index 00000000..adbb70a0 --- /dev/null +++ b/distribution/linux/appimage/AppRun @@ -0,0 +1,3 @@ +#!/bin/sh +CURRENTDIR="$(readlink -f "$(dirname "$0")")" +exec "$CURRENTDIR"/usr/bin/Ryujinx.sh "$@" diff --git a/distribution/linux/appimage/build-appimage.sh b/distribution/linux/appimage/build-appimage.sh new file mode 100755 index 00000000..c5ce974e --- /dev/null +++ b/distribution/linux/appimage/build-appimage.sh @@ -0,0 +1,30 @@ +#!/bin/sh +set -e + +ROOTDIR="$(readlink -f "$(dirname "$0")")"/../../../ +cd "$ROOTDIR" + +BUILDDIR=${BUILDDIR:-publish} +OUTDIR=${OUTDIR:-publish_appimage} + +rm -rf AppDir +mkdir -p AppDir/usr/bin/bin + +# Ensure necessary bins are set as executable +chmod +x "$BUILDDIR"/Ryujinx* + +# Add symlinks for the AppImage +ln -s "$ROOTDIR"/distribution/linux/Ryujinx.desktop AppDir/Ryujinx.desktop +ln -s "$ROOTDIR"/distribution/linux/appimage/AppRun AppDir/AppRun +ln -s "$ROOTDIR"/distribution/misc/Logo.svg AppDir/Ryujinx.svg + +cp -r "$BUILDDIR"/* AppDir/usr/bin/ + +mkdir -p "$OUTDIR" + +appimagetool --comp zstd --mksquashfs-opt -Xcompression-level --mksquashfs-opt 21 \ + -u "gh-releases-zsync|$GITHUB_REPOSITORY_OWNER|Ryujinx|latest|*.AppImage.zsync" \ + AppDir "$OUTDIR"/Ryujinx.AppImage + +# ?? +mv ./*.AppImage.zsync "$OUTDIR"