From 73b36c955e0eb83f24cb867d1881ee88d908e1d7 Mon Sep 17 00:00:00 2001 From: Fanshu Kong Date: Sun, 31 Mar 2024 15:34:11 +0800 Subject: [PATCH] support suyu linux CI --- .github/workflows/strato-android-build.yml | 24 ++-- .github/workflows/sudachi-android-build.yml | 16 ++- .github/workflows/suyu-android-build.yml | 10 +- .github/workflows/suyu-linux-build.yml | 128 ++++++++++++++++++++ .github/workflows/turnip-android-build.yml | 33 ++++- README.md | 13 +- README_CN.md | 13 +- script/package_suyu_linux.sh | 105 ++++++++++++++++ script/turnip_builder.sh | 5 +- 9 files changed, 306 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/suyu-linux-build.yml create mode 100644 script/package_suyu_linux.sh diff --git a/.github/workflows/strato-android-build.yml b/.github/workflows/strato-android-build.yml index 8b59ade..a2a8c74 100644 --- a/.github/workflows/strato-android-build.yml +++ b/.github/workflows/strato-android-build.yml @@ -46,16 +46,16 @@ jobs: echo "short_hash=$(git describe --always --long)" >> $GITHUB_OUTPUT echo "version=$(git describe --tags --always)" >> $GITHUB_OUTPUT - - name: Set up cache - uses: actions/cache@v4 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - ~/.ccache - key: ${{ runner.os }}-android-${{ steps.version.outputs.hash }} - restore-keys: | - ${{ runner.os }}-android- + # - name: Set up cache + # uses: actions/cache@v4 + # with: + # path: | + # ~/.gradle/caches + # ~/.gradle/wrapper + # ~/.cache + # key: ${{ runner.os }}-strato-android-${{ steps.version.outputs.hash }} + # restore-keys: | + # ${{ runner.os }}-strato-android- - name: Prepare environment run: | @@ -66,12 +66,12 @@ jobs: - name: Build Android run: | export NDK_CCACHE="$(which ccache)" - ccache -s + ccache -sv cd ${{ github.workspace }}/strato chmod +x ./gradlew ./gradlew --no-daemon --stacktrace --build-cache --parallel --configure-on-demand assemble${{ github.event.inputs.flavor || 'mainline' }}Release mv $(find app/build/outputs/apk -type f | grep -E "\.apk$") ${{ github.workspace }}/strato-${{ github.event.inputs.flavor || 'mainline' }}-${{ steps.version.outputs.date }}-${{ steps.version.outputs.version }}.apk - ccache -s + ccache -sv - name: Release Strato Android (Strato-Android) uses: softprops/action-gh-release@v2 diff --git a/.github/workflows/sudachi-android-build.yml b/.github/workflows/sudachi-android-build.yml index 25577bd..b32f5ee 100644 --- a/.github/workflows/sudachi-android-build.yml +++ b/.github/workflows/sudachi-android-build.yml @@ -28,7 +28,10 @@ jobs: - name: Download sudachi source code run: | cd ${{ github.workspace }} - git clone --branch ${{ github.event.inputs.branch || 'main' }} https://github.com/sudachi-emu/sudachi.git --recursive + git clone --branch ${{ github.event.inputs.branch || 'main' }} https://github.com/sudachi-emu/sudachi.git + cd sudachi + git submodule update --init --recursive --remote + # cd externals/sirit && git reset --hard - id: version name: Get version @@ -45,10 +48,10 @@ jobs: path: | ~/.gradle/caches ~/.gradle/wrapper - ~/.ccache - key: ${{ runner.os }}-android-${{ steps.version.outputs.hash }} + ~/.cache + key: ${{ runner.os }}-sudachi-android-${{ steps.version.outputs.hash }} restore-keys: | - ${{ runner.os }}-android- + ${{ runner.os }}-sudachi-android- - name: Prepare environment run: | @@ -57,12 +60,13 @@ jobs: - name: Build Android run: | export NDK_CCACHE="$(which ccache)" - ccache -s + ccache -sv cd ${{ github.workspace }}/sudachi/src/android chmod +x ./gradlew ./gradlew "assembleMainlineRelease" + # bash gradlew build mv $(find app/build/outputs/apk -type f | grep -E "\.apk$") ${{ github.workspace }}/sudachi-${{ github.event.inputs.flavor || 'ea' }}-${{ steps.version.outputs.date }}-${{ steps.version.outputs.version }}.apk - ccache -s + ccache -sv - name: Release Sudachi (Sudachi-Android) uses: softprops/action-gh-release@v2 diff --git a/.github/workflows/suyu-android-build.yml b/.github/workflows/suyu-android-build.yml index fc27e95..decd879 100644 --- a/.github/workflows/suyu-android-build.yml +++ b/.github/workflows/suyu-android-build.yml @@ -41,10 +41,10 @@ jobs: path: | ~/.gradle/caches ~/.gradle/wrapper - ~/.ccache - key: ${{ runner.os }}-android-${{ steps.version.outputs.hash }} + ~/.cache + key: ${{ runner.os }}-suyu-android-${{ steps.version.outputs.hash }} restore-keys: | - ${{ runner.os }}-android- + ${{ runner.os }}-suyu-android- - name: Prepare environment run: | @@ -53,12 +53,12 @@ jobs: - name: Build Android run: | export NDK_CCACHE="$(which ccache)" - ccache -s + ccache -sv cd ${{ github.workspace }}/suyu/src/android chmod +x ./gradlew ./gradlew "assembleMainlineRelease" mv app/build/outputs/apk/mainline/release/app-mainline-release.apk ${{ github.workspace }}/suyu-${{ steps.version.outputs.date }}-${{ steps.version.outputs.version }}.apk - ccache -s + ccache -sv - name: Release Suyu Android (Suyu-Android) uses: softprops/action-gh-release@v2 diff --git a/.github/workflows/suyu-linux-build.yml b/.github/workflows/suyu-linux-build.yml new file mode 100644 index 0000000..ddf3cb7 --- /dev/null +++ b/.github/workflows/suyu-linux-build.yml @@ -0,0 +1,128 @@ +name: suyu-linux-build + +on: + workflow_dispatch: + inputs: + branch: + description: 'select branch to build(default: dev)' + required: false + default: 'dev' + release_type: + description: 'select release_type to build(default: mainline)' + required: false + default: 'mainline' + schedule: + - cron: "0 0 */2 * *" + +jobs: + suyu_linux_build: + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: { ref: main } + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + + - name: Setup Ninja + uses: ashutoshvarma/setup-ninja@v1.1 + + - name: Download and install Boost + uses: MarkusJx/install-boost@v2.4.5 + id: install-boost + with: + boost_version: 1.79.0 + platform_version: 22.04 + + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + version: '6.6.1' + host: 'linux' + target: 'desktop' + install-deps: 'true' + + - name: Download suyu source code + run: | + cd ${{ github.workspace }} + git clone --branch ${{ github.event.inputs.branch || 'dev' }} https://git.suyu.dev/suyu/suyu.git --recursive + + - id: version + name: Get version + run: | + echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT + cd ${{ github.workspace }}/suyu + echo "hash=$(git log -1 --pretty=format:%H)" >> $GITHUB_OUTPUT + echo "version=$(git describe --tags --always)" >> $GITHUB_OUTPUT + + - name: Set up cache + uses: actions/cache@v4 + with: + path: | + ~/.cache + key: ${{ runner.os }}-suyu-linux-${{ steps.version.outputs.hash }} + restore-keys: | + ${{ runner.os }}-suyu-linux- + + - name: Prepare environment + run: | + sudo apt update + sudo apt-get install ccache autoconf cmake g++-11 gcc-11 git glslang-tools libasound2 libboost-context-dev libglu1-mesa-dev libhidapi-dev libpulse-dev libtool libudev-dev libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-xinerama0 libxcb-xkb1 libxext-dev libxkbcommon-x11-0 mesa-common-dev nasm ninja-build qtbase5-dev qtbase5-private-dev qtwebengine5-dev qtmultimedia5-dev libmbedtls-dev catch2 libfmt-dev liblz4-dev nlohmann-json3-dev libzstd-dev libssl-dev libavfilter-dev libavcodec-dev libswscale-dev + + - name: Build Linux + run: | + cd ${{ github.workspace }}/suyu + set -e + ccache -sv + mkdir build || true && cd build + cmake .. \ + -DBoost_USE_STATIC_LIBS=ON \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DSUYU_USE_PRECOMPILED_HEADERS=OFF \ + -DDYNARMIC_USE_PRECOMPILED_HEADERS=OFF \ + -DCMAKE_CXX_FLAGS="-march=x86-64-v2" \ + -DCMAKE_CXX_COMPILER=g++ \ + -DCMAKE_C_COMPILER=gcc \ + -DCMAKE_INSTALL_PREFIX="/usr" \ + -DDISPLAY_VERSION="1.0.0" \ + -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=OFF \ + -DENABLE_QT_TRANSLATION=OFF \ + -DSUYU_USE_BUNDLED_VCPKG=ON \ + -DUSE_DISCORD_PRESENCE=ON \ + -DSUYU_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} \ + -DSUYU_USE_BUNDLED_FFMPEG=ON \ + -DSUYU_ENABLE_LTO=OFF \ + -DSUYU_CRASH_DUMPS=ON \ + -DENABLE_QT6=ON \ + -DSUYU_USE_FASTER_LD=ON \ + -DBoost_INCLUDE_DIR=${{steps.install-boost.outputs.BOOST_ROOT}}/include \ + -DBoost_LIBRARY_DIRS=${{steps.install-boost.outputs.BOOST_ROOT}}/lib \ + -DQT6_LOCATION=${QT_ROOT_DIR} \ + -GNinja + ninja + ccache -sv + - name: Package Artifacts + run: | + export DATE=${{ steps.version.outputs.date }} + export VERSION=${{ steps.version.outputs.version }} + export WORKSPACE=${{ github.workspace }} + export RELEASE_TYPE=${{ github.event.inputs.release_type || 'mainline' }} + cd ${{ github.workspace }}/suyu/build + bash ${{ github.workspace }}/script/package_suyu_linux.sh + + - name: Release Suyu Linux (Suyu-Linux) + uses: softprops/action-gh-release@v2 + with: + name: Suyu Linux ${{ steps.version.outputs.date }} + tag_name: suyu-linux + files: suyu-linux-${{ github.event.inputs.release_type || 'mainline' }}-${{ steps.version.outputs.date }}-${{ steps.version.outputs.version }}.AppImage + + - name: Release Suyu Linux ${{ steps.version.outputs.date }} + uses: softprops/action-gh-release@v2 + with: + name: ${{ steps.version.outputs.date }} + tag_name: ${{ steps.version.outputs.date }} + files: suyu-linux-${{ github.event.inputs.release_type || 'mainline' }}-${{ steps.version.outputs.date }}-${{ steps.version.outputs.version }}.AppImage \ No newline at end of file diff --git a/.github/workflows/turnip-android-build.yml b/.github/workflows/turnip-android-build.yml index ea4242a..1f4aaea 100644 --- a/.github/workflows/turnip-android-build.yml +++ b/.github/workflows/turnip-android-build.yml @@ -26,18 +26,41 @@ jobs: sudo apt build-dep mesa -y sudo sed -i 's/jammy/mantic/g' /etc/apt/sources.list sudo apt update - sudo apt install meson - - - name: Execute build script - run: bash ./script/turnip_builder.sh ${{ github.event.inputs.branch || 'main'}} - + sudo apt install meson ccache -y + + - name: Download suyu source code + run: | + mkdir -p ${{ github.workspace }}/turnip_workdir + cd ${{ github.workspace }}/turnip_workdir + git clone --branch ${{ github.event.inputs.branch || 'main'}} https://gitlab.freedesktop.org/mesa/mesa.git + - id: version name: Get date run: | cd ${{ github.workspace }}/turnip_workdir/mesa echo "date=$(date -u "+%Y%m%d")" >> $GITHUB_OUTPUT + echo "hash=$(git log -1 --pretty=format:%H)" >> $GITHUB_OUTPUT echo "tag=$(git describe --tags --always)" >> $GITHUB_OUTPUT + - name: Set up cache + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + ~/.cache + key: ${{ runner.os }}-turnip-${{ steps.version.outputs.hash }} + restore-keys: | + ${{ runner.os }}-turnip- + + - name: Execute build script + run: | + export NDK_CCACHE="$(which ccache)" + ccache -sv + cd ${{ github.workspace }} + bash ./script/turnip_builder.sh ${{ github.event.inputs.branch || 'main'}} + ccache -sv + - name: Release Turnip (Mesa-Turnip-Android) uses: softprops/action-gh-release@v2 with: diff --git a/README.md b/README.md index 7c07fc6..37ae99c 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,12 @@ This is an automated CI project for suyu, sudachi, strato and mesa turnip. 1. Suyu Android version is automatically generated daily at 00:00:00 (UTC). 2. Suyu Windows version is automatically generated every 2 days at 00:00:00 (UTC). -3. Mesa Turnip Android version is automatically generated daily at 00:00:00 (UTC). -4. Sudachi Android version is automatically generated every 3 days at 00:00:00 (UTC). -5. Strato Android version is automatically generated on the 1st of every month at 00:00:00 (UTC). -6. Naming format: "Project Name - Date - Tag - Branch". (Tag depends on the developer, a decrease in version number does not indicate a backward release version) -7. Release frequency may be adjusted based on project code commit frequency. +3. Suyu Linux version is automatically generated every 2 days at 00:00:00 (UTC). +4. Mesa Turnip Android version is automatically generated daily at 00:00:00 (UTC). +5. Sudachi Android version is automatically generated every 3 days at 00:00:00 (UTC). +6. Strato Android version is automatically generated on the 1st of every month at 00:00:00 (UTC). +7. Naming format: "Project Name - Date - Tag - Branch". (Tag depends on the developer, a decrease in version number does not indicate a backward release version) +8. Release frequency may be adjusted based on project code commit frequency. ## Driver Usage Instructions @@ -31,6 +32,8 @@ The daily release includes all projects that underwent CI execution on that day. [Suyu Windows](https://github.com/ImpXada/Auto-CI/releases/tag/suyu-windows) +[Suyu Linux](https://github.com/ImpXada/Auto-CI/releases/tag/suyu-linux) + [Turnip Android](https://github.com/ImpXada/Auto-CI/releases/tag/mesa-turnip-android) [Sudachi Android](https://github.com/ImpXada/Auto-CI/releases/tag/sudachi-android) diff --git a/README_CN.md b/README_CN.md index a732427..c355167 100644 --- a/README_CN.md +++ b/README_CN.md @@ -12,11 +12,12 @@ suyu sudachi strato mesa-turnip的自动CI项目 1. 每天的00:00:00(UTC)会自动生成Suyu安卓版。 2. 每2天的00:00:00(UTC)会自动生成Suyu Windows版。 -3. 每天的00:00:00(UTC)会自动生成Mesa Turnip 安卓版。 -4. 每3天的00:00:00(UTC)会自动生成Sudachi安卓版。 -5. 每月1号的00:00:00(UTC)会自动生成Strato安卓版。 -6. 命名方式为”项目名-日期-Tag-分支“。(Tag取决于开发者,如果出现版本号下降,不代表发包版本落后) -7. 发布频率可能会根据项目代码提交频率进行调整。 +3. 每2天的00:00:00(UTC)会自动生成Suyu Linux版。 +4. 每天的00:00:00(UTC)会自动生成Mesa Turnip 安卓版。 +5. 每3天的00:00:00(UTC)会自动生成Sudachi安卓版。 +6. 每月1号的00:00:00(UTC)会自动生成Strato安卓版。 +7. 命名方式为”项目名-日期-Tag-分支“。(Tag取决于开发者,如果出现版本号下降,不代表发包版本落后) +8. 发布频率可能会根据项目代码提交频率进行调整。 ## 驱动使用说明 @@ -31,6 +32,8 @@ suyu sudachi strato mesa-turnip的自动CI项目 [Suyu Windows版](https://github.com/ImpXada/Auto-CI/releases/tag/suyu-windows) +[Suyu Linux版](https://github.com/ImpXada/Auto-CI/releases/tag/suyu-linux) + [Turnip Android版](https://github.com/ImpXada/Auto-CI/releases/tag/mesa-turnip-android) [Sudachi Android版](https://github.com/ImpXada/Auto-CI/releases/tag/sudachi-android) diff --git a/script/package_suyu_linux.sh b/script/package_suyu_linux.sh new file mode 100644 index 0000000..77e7e03 --- /dev/null +++ b/script/package_suyu_linux.sh @@ -0,0 +1,105 @@ +#!/bin/bash -ex +cd ${WORKSPACE}/suyu/build +for EXE in suyu; do + EXE_PATH="bin/$EXE" + # Copy debug symbols out + objcopy --only-keep-debug $EXE_PATH $EXE_PATH.debug + # Add debug link and strip debug symbols + objcopy -g --add-gnu-debuglink=$EXE_PATH.debug $EXE_PATH $EXE_PATH.out + # Overwrite original with stripped copy + mv $EXE_PATH.out $EXE_PATH +done + +find bin/ -type f -not -regex '.*.debug' -exec strip -g {} ';' + +DESTDIR="$PWD/AppDir" ninja install +rm -vf AppDir/usr/bin/suyu-cmd AppDir/usr/bin/suyu-tester + +# Download tools needed to build an AppImage +wget -nc https://gitlab.com/suyu-emu/ext-linux-bin/-/raw/main/appimage/deploy-linux.sh +wget -nc https://gitlab.com/suyu-emu/ext-linux-bin/-/raw/main/appimage/exec-x86_64.so +wget -nc https://gitlab.com/suyu-emu/AppImageKit-checkrt/-/raw/old/AppRun.sh + +chmod 755 \ + deploy-linux.sh \ + AppRun.sh \ + exec-x86_64.so \ + +export APPIMAGE_EXTRACT_AND_RUN=1 + +mkdir -p AppDir/usr/optional +mkdir -p AppDir/usr/optional/libstdc++ +mkdir -p AppDir/usr/optional/libgcc_s + +# Deploy suyu's needed dependencies +DEPLOY_QT=1 ./deploy-linux.sh AppDir/usr/bin/suyu AppDir + +# Workaround for libQt5MultimediaGstTools indirectly requiring libwayland-client and breaking Vulkan usage on end-user systems +find AppDir -type f -regex '.*libwayland-client\.so.*' -delete -print + +# Workaround for building suyu with GCC 10 but also trying to distribute it to Ubuntu 18.04 et al. +# See https://github.com/darealshinji/AppImageKit-checkrt +cp exec-x86_64.so AppDir/usr/optional/exec.so +cp AppRun.sh AppDir/AppRun +cp --dereference /usr/lib/x86_64-linux-gnu/libstdc++.so.6 AppDir/usr/optional/libstdc++/libstdc++.so.6 +cp --dereference /lib/x86_64-linux-gnu/libgcc_s.so.1 AppDir/usr/optional/libgcc_s/libgcc_s.so.1 + +#################################################### + +cd ${WORKSPACE}/suyu + +GITDATE=$DATE +GITREV=$VERSION +ARTIFACTS_DIR="$PWD/artifacts" +RELEASE_NAME=${RELEASE_TYPE} + +mkdir -p "${ARTIFACTS_DIR}/" + +APPIMAGE_NAME="suyu-linux-${RELEASE_NAME}-${GITDATE}-${GITREV}.AppImage" +BASE_NAME="suyu-linux" +REV_NAME="${BASE_NAME}-${GITDATE}-${GITREV}" +ARCHIVE_NAME="${REV_NAME}.tar.xz" +COMPRESSION_FLAGS="-cJvf" + +DIR_NAME="${BASE_NAME}-${RELEASE_NAME}" + +mkdir "$DIR_NAME" + +cp build/bin/suyu-cmd "$DIR_NAME" +if [ "${RELEASE_NAME}" != "early-access" ] && [ "${RELEASE_NAME}" != "mainline" ]; then + cp build/bin/suyu "$DIR_NAME" +fi + +# Build an AppImage +cd build + +wget -nc https://gitlab.com/suyu-emu/ext-linux-bin/-/raw/main/appimage/appimagetool-x86_64.AppImage +chmod 755 appimagetool-x86_64.AppImage + +# if FUSE is not available, then fallback to extract and run +if ! ./appimagetool-x86_64.AppImage --version; then + export APPIMAGE_EXTRACT_AND_RUN=1 +fi + +# Don't let AppImageLauncher ask to integrate EA +if [ "${RELEASE_NAME}" = "mainline" ] || [ "${RELEASE_NAME}" = "early-access" ]; then + echo "X-AppImage-Integrate=false" >> AppDir/org.suyu_emu.suyu.desktop +fi + +./appimagetool-x86_64.AppImage AppDir "${APPIMAGE_NAME}" +echo "AppImage created: ${PWD}/${APPIMAGE_NAME}" +cd .. + +# Copy the AppImage and update info to the artifacts directory and avoid compressing it +cp "build/${APPIMAGE_NAME}" "${ARTIFACTS_DIR}/" +if [ -f "build/${APPIMAGE_NAME}.zsync" ]; then + cp "build/${APPIMAGE_NAME}.zsync" "${ARTIFACTS_DIR}/" +fi + +# Copy the AppImage to the general release directory and remove git revision info +if [ "${RELEASE_NAME}" = "mainline" ] || [ "${RELEASE_NAME}" = "early-access" ]; then + echo "Copying AppImage to release directory" + cp "build/${APPIMAGE_NAME}" "${DIR_NAME}/suyu-${RELEASE_NAME}.AppImage" +fi + +cp "build/${APPIMAGE_NAME}" "${WORKSPACE}/" \ No newline at end of file diff --git a/script/turnip_builder.sh b/script/turnip_builder.sh index c43dbca..805f0b4 100644 --- a/script/turnip_builder.sh +++ b/script/turnip_builder.sh @@ -32,8 +32,8 @@ pip install mako &> /dev/null -echo "Creating and entering to work directory ..." $'\n' -mkdir -p $workdir && cd $workdir +echo "Entering to work directory ..." $'\n' +cd $workdir @@ -43,7 +43,6 @@ echo "Exracting android-ndk to a folder ..." $'\n' unzip "$ndkver"-linux.zip &> /dev/null -git clone --branch $1 https://gitlab.freedesktop.org/mesa/mesa.git cd mesa version=$(