From 3bdda3ea50f365f27a201dd33e0635a920b730b7 Mon Sep 17 00:00:00 2001 From: Briar <205427297+icybriarr@users.noreply.github.com> Date: Tue, 1 Apr 2025 18:49:53 +0200 Subject: [PATCH] ci/cd: Initial implantation Co-Authored-By: Morph <39850852+morph1984@users.noreply.github.com> --- .ci/android.sh | 19 +++ .ci/install-vulkan-sdk.ps1 | 33 +++++ .ci/linux.sh | 40 ++++++ .ci/package-appimage.sh | 120 ++++++++++++++++ .ci/source.sh | 20 +++ .github/workflows/build.yml | 263 ++++++++++++++++++++++++++++++++++++ 6 files changed, 495 insertions(+) create mode 100755 .ci/android.sh create mode 100644 .ci/install-vulkan-sdk.ps1 create mode 100755 .ci/linux.sh create mode 100755 .ci/package-appimage.sh create mode 100755 .ci/source.sh create mode 100644 .github/workflows/build.yml diff --git a/.ci/android.sh b/.ci/android.sh new file mode 100755 index 0000000000..db3dac4196 --- /dev/null +++ b/.ci/android.sh @@ -0,0 +1,19 @@ +#!/bin/bash -ex + +export NDK_CCACHE=$(which ccache) + +if [ ! -z "${ANDROID_KEYSTORE_B64}" ]; then + export ANDROID_KEYSTORE_FILE="${GITHUB_WORKSPACE}/ks.jks" + base64 --decode <<< "${ANDROID_KEYSTORE_B64}" > "${ANDROID_KEYSTORE_FILE}" +fi + +cd src/android +chmod +x ./gradlew +./gradlew assembleRelease +./gradlew bundleRelease + +ccache -s -v + +if [ ! -z "${ANDROID_KEYSTORE_B64}" ]; then + rm "${ANDROID_KEYSTORE_FILE}" +fi diff --git a/.ci/install-vulkan-sdk.ps1 b/.ci/install-vulkan-sdk.ps1 new file mode 100644 index 0000000000..de218d90ad --- /dev/null +++ b/.ci/install-vulkan-sdk.ps1 @@ -0,0 +1,33 @@ +# SPDX-FileCopyrightText: 2023 yuzu Emulator Project +# SPDX-License-Identifier: GPL-3.0-or-later + +$ErrorActionPreference = "Stop" + +$VulkanSDKVer = "1.3.250.1" +$ExeFile = "VulkanSDK-$VulkanSDKVer-Installer.exe" +$Uri = "https://sdk.lunarg.com/sdk/download/$VulkanSDKVer/windows/$ExeFile" +$Destination = "./$ExeFile" + +echo "Downloading Vulkan SDK $VulkanSDKVer from $Uri" +$WebClient = New-Object System.Net.WebClient +$WebClient.DownloadFile($Uri, $Destination) +echo "Finished downloading $ExeFile" + +$VULKAN_SDK = "C:/VulkanSDK/$VulkanSDKVer" +$Arguments = "--root `"$VULKAN_SDK`" --accept-licenses --default-answer --confirm-command install" + +echo "Installing Vulkan SDK $VulkanSDKVer" +$InstallProcess = Start-Process -FilePath $Destination -NoNewWindow -PassThru -Wait -ArgumentList $Arguments +$ExitCode = $InstallProcess.ExitCode + +if ($ExitCode -ne 0) { + echo "Error installing Vulkan SDK $VulkanSDKVer (Error: $ExitCode)" + Exit $ExitCode +} + +echo "Finished installing Vulkan SDK $VulkanSDKVer" + +if ("$env:GITHUB_ACTIONS" -eq "true") { + echo "VULKAN_SDK=$VULKAN_SDK" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + echo "$VULKAN_SDK/Bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append +} diff --git a/.ci/linux.sh b/.ci/linux.sh new file mode 100755 index 0000000000..e152c1b962 --- /dev/null +++ b/.ci/linux.sh @@ -0,0 +1,40 @@ +#!/bin/bash -ex + +if [ "$TARGET" = "appimage" ]; then + # Compile the AppImage we distribute with Clang. + export EXTRA_CMAKE_FLAGS=(-DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_LINKER=/etc/bin/ld.lld) + # Bundle required QT wayland libraries + export EXTRA_QT_PLUGINS="waylandcompositor" + export EXTRA_PLATFORM_PLUGINS="libqwayland-egl.so;libqwayland-generic.so" +else + # For the linux-fresh verification target, verify compilation without PCH as well. + export EXTRA_CMAKE_FLAGS=(-DCITRA_USE_PRECOMPILED_HEADERS=OFF) +fi + +if [ "$GITHUB_REF_TYPE" == "tag" ]; then + export EXTRA_CMAKE_FLAGS=($EXTRA_CMAKE_FLAGS -DENABLE_QT_UPDATE_CHECKER=ON) +fi + +mkdir -p build && cd build +cmake .. -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DENABLE_QT_TRANSLATION=ON \ + -DUSE_DISCORD_PRESENCE=ON \ + -DYUZU_USE_BUNDLED_VCPKG=ON \ + "${EXTRA_CMAKE_FLAGS[@]}" +ninja +if [ -d "bin/Release" ]; then + strip -s bin/Release/* +else + strip -s bin/* +fi + +if [ "$TARGET" = "appimage" ]; then + ccache -s +else + ccache -s -v +fi + +ctest -VV -C Release diff --git a/.ci/package-appimage.sh b/.ci/package-appimage.sh new file mode 100755 index 0000000000..1a4f0bf775 --- /dev/null +++ b/.ci/package-appimage.sh @@ -0,0 +1,120 @@ +#!/bin/bash -ex + +GITDATE="$(git show -s --date=short --format='%ad' | sed 's/-//g')" +GITREV="$(git show -s --format='%h')" +ARTIFACTS_DIR="$PWD/artifacts" +mkdir -p "${ARTIFACTS_DIR}/" + +if [ "$1" == "master" ]; then + RELEASE_NAME="mainline" +else + RELEASE_NAME="$1" +fi + +BASE_NAME="eden-linux" +REV_NAME="${BASE_NAME}-${GITDATE}-${GITREV}" +ARCHIVE_NAME="${REV_NAME}.tar.xz" +COMPRESSION_FLAGS="-cJvf" + +if [ "${RELEASE_NAME}" = "mainline" ] || [ "${RELEASE_NAME}" = "early-access" ]; then + DIR_NAME="${BASE_NAME}-${RELEASE_NAME}" +else + DIR_NAME="${REV_NAME}-${RELEASE_NAME}" +fi + +mkdir -p "$DIR_NAME" + + +cp LICENSE.txt "$DIR_NAME/" || echo "LICENSE.txt not found" +cp README.md "$DIR_NAME/" || echo "README.md not found" + +create_appimage() { + local binary_name="$1" + local display_name="$2" + local needs_qt="$3" + local app_dir="build/AppDir-${binary_name}" + local appimage_output="${binary_name}.AppImage" + + echo "Creating AppImage for ${binary_name}..." + + mkdir -p "${app_dir}/usr/bin" + mkdir -p "${app_dir}/usr/lib" + mkdir -p "${app_dir}/usr/share/applications" + mkdir -p "${app_dir}/usr/share/icons/hicolor/scalable/apps" + mkdir -p "${app_dir}/usr/optional/libstdc++" + mkdir -p "${app_dir}/usr/optional/libgcc_s" + + if [ -d "build/bin/Release" ]; then + cp "build/bin/Release/${binary_name}" "${app_dir}/usr/bin/" || echo "${binary_name} not found for AppDir" + else + cp "build/bin/${binary_name}" "${app_dir}/usr/bin/" || echo "${binary_name} not found for AppDir" + fi + + strip -s "${app_dir}/usr/bin/${binary_name}" + + cat > "${app_dir}/org.yuzu_emu.${binary_name}.desktop" << EOL +[Desktop Entry] +Type=Application +Name=${display_name} +Icon=org.yuzu_emu.${binary_name} +Exec=${binary_name} +Categories=Game;Emulator; +EOL + + cp "${app_dir}/org.yuzu_emu.${binary_name}.desktop" "${app_dir}/usr/share/applications/" + + cp "dist/yuzu.svg" "${app_dir}/org.yuzu_emu.${binary_name}.svg" + cp "dist/yuzu.svg" "${app_dir}/usr/share/icons/hicolor/scalable/apps/org.yuzu_emu.${binary_name}.svg" + + cd build + wget -nc https://raw.githubusercontent.com/eden-emulator/ext-linux-bin/main/appimage/deploy-linux.sh || echo "Failed to download deploy script" + wget -nc https://raw.githubusercontent.com/eden-emulator/AppImageKit-checkrt/old/AppRun.sh || echo "Failed to download AppRun script" + wget -nc https://github.com/eden-emulator/ext-linux-bin/raw/main/appimage/exec-x86_64.so || echo "Failed to download exec wrapper" + chmod +x deploy-linux.sh + + cd .. + if [ "$needs_qt" = "true" ]; then + echo "Deploying with Qt dependencies for ${binary_name}..." + DEPLOY_QT=1 build/deploy-linux.sh "${app_dir}/usr/bin/${binary_name}" "${app_dir}" + else + echo "Deploying without Qt dependencies for ${binary_name}..." + build/deploy-linux.sh "${app_dir}/usr/bin/${binary_name}" "${app_dir}" + fi + + cp --dereference /usr/lib/x86_64-linux-gnu/libstdc++.so.6 "${app_dir}/usr/optional/libstdc++/libstdc++.so.6" || true + cp --dereference /lib/x86_64-linux-gnu/libgcc_s.so.1 "${app_dir}/usr/optional/libgcc_s/libgcc_s.so.1" || true + + cp build/exec-x86_64.so "${app_dir}/usr/optional/exec.so" || true + cp build/AppRun.sh "${app_dir}/AppRun" + chmod +x "${app_dir}/AppRun" + + find "${app_dir}" -type f -regex '.*libwayland-client\.so.*' -delete -print || true + + cd build + + if [ ! -f "appimagetool-x86_64.AppImage" ]; then + wget -nc https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage + chmod +x appimagetool-x86_64.AppImage + fi + + if ! ./appimagetool-x86_64.AppImage --version; then + echo "FUSE not available, using extract and run mode" + export APPIMAGE_EXTRACT_AND_RUN=1 + fi + + echo "Generating AppImage: ${appimage_output}" + ./appimagetool-x86_64.AppImage "AppDir-${binary_name}" "${appimage_output}" || echo "AppImage generation failed for ${binary_name}" + + cp "${appimage_output}" "../${DIR_NAME}/" || echo "AppImage not copied to DIR_NAME for ${binary_name}" + cp "${appimage_output}" "../${ARTIFACTS_DIR}/" || echo "AppImage not copied to artifacts for ${binary_name}" + cd .. +} + +create_appimage "eden" "Eden" "true" +create_appimage "eden-cli" "Eden-CLI" "false" +create_appimage "eden-room" "Eden-Room" "false" + +tar $COMPRESSION_FLAGS "$ARCHIVE_NAME" "$DIR_NAME" +mv "$ARCHIVE_NAME" "${ARTIFACTS_DIR}/" + +ls -la "${ARTIFACTS_DIR}/" \ No newline at end of file diff --git a/.ci/source.sh b/.ci/source.sh new file mode 100755 index 0000000000..1928d7df99 --- /dev/null +++ b/.ci/source.sh @@ -0,0 +1,20 @@ +#!/bin/bash -ex + +GITDATE="`git show -s --date=short --format='%ad' | sed 's/-//g'`" +GITREV="`git show -s --format='%h'`" +REV_NAME="eden-unified-source-${GITDATE}-${GITREV}" + +COMPAT_LIST='dist/compatibility_list/compatibility_list.json' + +mkdir artifacts + +pip3 install git-archive-all +touch "${COMPAT_LIST}" +git describe --abbrev=0 --always HEAD > GIT-COMMIT +git describe --tags HEAD > GIT-TAG || echo 'unknown' > GIT-TAG +git archive-all --include "${COMPAT_LIST}" --include GIT-COMMIT --include GIT-TAG --force-submodules artifacts/"${REV_NAME}.tar" + +cd artifacts/ +xz -T0 -9 "${REV_NAME}.tar" +sha256sum "${REV_NAME}.tar.xz" > "${REV_NAME}.tar.xz.sha256sum" +cd .. diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..a033ceb1fe --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,263 @@ +name: eden-build + +on: + push: + branches: [ "*" ] + tags: [ "*" ] + pull_request: + branches: [ master ] + +jobs: + source: + if: ${{ !github.head_ref }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Pack + run: ./.ci/source.sh + - name: Upload + uses: actions/upload-artifact@v4 + with: + name: source + path: artifacts/ + windows: + runs-on: windows-latest + strategy: + matrix: + target: ["msvc"] # TODO: Add msys2 + defaults: + run: + shell: ${{ (matrix.target == 'msys2' && 'msys2') || 'bash' }} {0} + env: + CCACHE_DIR: ${{ github.workspace }}/.ccache + CCACHE_COMPILERCHECK: content + CCACHE_SLOPPINESS: time_macros + OS: windows + TARGET: ${{ matrix.target }} + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + - name: Set up ccache + uses: actions/cache@v4 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ runner.os }}-${{ matrix.target }}-ccache-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-${{ matrix.target }}-ccache- + - name: Set up vcpkg cache + uses: actions/cache@v4 + with: + path: | + ${{ github.workspace }}/build/vcpkg_installed + ${{ github.workspace }}/build/externals + ${{ github.workspace }}/.vcpkg + key: ${{ runner.os }}-${{ matrix.target }}-vcpkg-${{ hashFiles('**/CMakeLists.txt', '**/vcpkg.json') }}-${{ github.run_id }} + restore-keys: | + ${{ runner.os }}-${{ matrix.target }}-vcpkg- + - name: Set up MSVC + uses: ilammy/msvc-dev-cmd@v1 + if: ${{ matrix.target == 'msvc' }} + - name: Install extra tools + run: choco install ccache ninja wget cygwin + if: ${{ matrix.target == 'msvc' }} + - name: Install vulkan-SDK + run: ./.ci/install-vulkan-sdk.ps1 + shell: pwsh + - name: Cygwin with autoconf # NEEDED FOR LIBUSB + shell: cmd + run: | + C:\tools\cygwin\cygwinsetup.exe -q -P autoconf,automake,libtool,make,pkg-config + + REM Create wrapper batch files for Cygwin tools in a directory that will be in PATH + mkdir C:\cygwin-wrappers + + REM Create autoconf.bat wrapper + echo @echo off > C:\cygwin-wrappers\autoconf.bat + echo C:\tools\cygwin\bin\bash.exe -l -c "autoconf %%*" >> C:\cygwin-wrappers\autoconf.bat + + REM Add other wrappers if needed for other Cygwin tools + echo @echo off > C:\cygwin-wrappers\automake.bat + echo C:\tools\cygwin\bin\bash.exe -l -c "automake %%*" >> C:\cygwin-wrappers\automake.bat + + REM Add the wrappers directory to PATH + echo C:\cygwin-wrappers>>"%GITHUB_PATH%" + echo C:\tools\cygwin\bin>>"%GITHUB_PATH%" + - name: CMake Configure + id: cmake + shell: cmd + run: | + mkdir build + cd build + cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_TOOLCHAIN_FILE="%CD%\..\CMakeModules\MSVCCache.cmake" -DYUZU_USE_BUNDLED_QT=ON -DENABLE_QT_TRANSLATION=ON -DUSE_DISCORD_PRESENCE=ON -DYUZU_USE_BUNDLED_VCPKG=ON -DYUZU_USE_BUNDLED_SDL2=ON -DUSE_CCACHE=ON + - name: Build + id: build + shell: cmd + run: | + cd build + ninja yuzu yuzu-cmd yuzu-room tests + ccache -s -v + - name: Package artifacts + if: steps.build.outcome == 'success' + shell: pwsh + run: | + $GITDATE = $(git show -s --date=short --format='%ad') -replace "-", "" + $GITREV = $(git show -s --format='%h') + $RELEASE_DIST = "eden-windows-msvc" + $ARTIFACTS_DIR = "${{ github.workspace }}/artifacts" + + mkdir -p $ARTIFACTS_DIR + mkdir -p $RELEASE_DIST + mkdir -p pdb + + Copy-Item "build/bin/Release/*" -Destination "$RELEASE_DIST" -Recurse -ErrorAction SilentlyContinue + if (-not $?) { + # Try without Release subfolder if that doesn't exist + Copy-Item "build/bin/*" -Destination "$RELEASE_DIST" -Recurse -ErrorAction SilentlyContinue + } + + Get-ChildItem "build/bin/" -Recurse -Filter "*.pdb" | Copy-Item -destination .\pdb -ErrorAction SilentlyContinue + + $BUILD_ZIP = "eden-windows-msvc-$GITDATE-$GITREV.zip" + $BUILD_PDB = "eden-windows-msvc-$GITDATE-$GITREV-debugsymbols.zip" + $BUILD_7Z = "eden-windows-msvc-$GITDATE-$GITREV.7z" + + 7z a -tzip $BUILD_ZIP $RELEASE_DIST\* + + if (Test-Path -Path ".\pdb\*.pdb") { + 7z a -tzip $BUILD_PDB .\pdb\*.pdb + Move-Item $BUILD_PDB $ARTIFACTS_DIR/ -ErrorAction SilentlyContinue + } + + 7z a $BUILD_7Z $RELEASE_DIST + + Move-Item $BUILD_ZIP $ARTIFACTS_DIR/ -ErrorAction SilentlyContinue + Move-Item $BUILD_7Z $ARTIFACTS_DIR/ -ErrorAction SilentlyContinue + + Copy-Item "LICENSE*" -Destination "$RELEASE_DIST" -ErrorAction SilentlyContinue + Copy-Item "README*" -Destination "$RELEASE_DIST" -ErrorAction SilentlyContinue + - name: Upload Windows artifacts + if: steps.build.outcome == 'success' + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.target }} + path: artifacts/* + linux: + runs-on: ubuntu-latest + env: + CCACHE_DIR: ${{ github.workspace }}/.ccache + CCACHE_COMPILERCHECK: content + CCACHE_SLOPPINESS: time_macros + OS: linux + TARGET: fresh + container: + image: icybriar/eden-build-environment:latest + options: -u 1001 + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + - name: Set up cache + uses: actions/cache@v4 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ runner.os }}-fresh-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-fresh- + + - name: Set up vcpkg cache + uses: actions/cache@v4 + with: + path: | + ${{ github.workspace }}/build/vcpkg_installed + ${{ github.workspace }}/build/externals + ${{ github.workspace }}/.vcpkg + key: ${{ runner.os }}-fresh-vcpkg-${{ hashFiles('**/CMakeLists.txt', '**/vcpkg.json') }}-${{ github.run_id }} + restore-keys: | + ${{ runner.os }}-fresh-vcpkg- + + - name: Build + run: ./.ci/linux.sh + + - name: Package AppImages + run: | + ./.ci/package-appimage.sh "${{ github.ref_name }}" + + - name: Upload Linux artifacts + uses: actions/upload-artifact@v4 + with: + name: linux + path: artifacts/* + android: + runs-on: ubuntu-latest + env: + CCACHE_DIR: ${{ github.workspace }}/.ccache + CCACHE_COMPILERCHECK: content + CCACHE_SLOPPINESS: time_macros + OS: android + TARGET: universal + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + - name: Set up cache + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + ${{ env.CCACHE_DIR }} + key: ${{ runner.os }}-android-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-android- + - name: Set tag name + run: | + if [[ "$GITHUB_REF_TYPE" == "tag" ]]; then + echo "GIT_TAG_NAME=$GITHUB_REF_NAME" >> $GITHUB_ENV + fi + echo $GIT_TAG_NAME + - name: Deps + run: | + sudo apt-get update -y + sudo apt-get install ccache glslang-dev glslang-tools apksigner -y + - name: Build + run: JAVA_HOME=$JAVA_HOME_21_X64 ./.ci/android.sh + env: + ANDROID_KEYSTORE_B64: ${{ secrets.ANDROID_KEYSTORE_B64 }} + ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }} + ANDROID_KEYSTORE_PASS: ${{ secrets.ANDROID_KEYSTORE_PASS }} + - name: Package Android artifacts + run: | + GITDATE="$(git show -s --date=short --format='%ad' | sed 's/-//g')" + GITREV="$(git show -s --format='%h')" + ARTIFACTS_DIR="$PWD/artifacts" + mkdir -p "${ARTIFACTS_DIR}/" + + REV_NAME="eden-android-${GITDATE}-${GITREV}" + BUILD_FLAVOR="mainline" + BUILD_TYPE_LOWER="release" + BUILD_TYPE_UPPER="Release" + + if [ "${GITHUB_REPOSITORY}" == "eden-emulator/eden" ]; then + BUILD_TYPE_LOWER="relWithDebInfo" + BUILD_TYPE_UPPER="RelWithDebInfo" + fi + + cp src/android/app/build/outputs/apk/"${BUILD_FLAVOR}/${BUILD_TYPE_LOWER}/app-${BUILD_FLAVOR}-${BUILD_TYPE_LOWER}.apk" \ + "${ARTIFACTS_DIR}/${REV_NAME}.apk" || echo "APK not found" + + cp src/android/app/build/outputs/bundle/"${BUILD_FLAVOR}${BUILD_TYPE_UPPER}"/"app-${BUILD_FLAVOR}-${BUILD_TYPE_LOWER}.aab" \ + "${ARTIFACTS_DIR}/${REV_NAME}.aab" || echo "AAB not found" + + ls -la "${ARTIFACTS_DIR}/" + + - name: Upload Android artifacts + uses: actions/upload-artifact@v4 + with: + name: android + path: artifacts/* \ No newline at end of file