From c409022df53d273c03e9f1812d6e1a4e6780e78f Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Fri, 6 May 2022 12:55:43 -0400 Subject: [PATCH] Combine AppImage and Linux build --- .github/workflows/CI.yml | 155 +++++++++------------------------------ CMakeLists.txt | 9 +-- 2 files changed, 39 insertions(+), 125 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 504e706f..e9d2a4bc 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -52,106 +52,6 @@ jobs: echo Within 'CMakeLists.txt' change "project(Sunshine VERSION $cmakelists_version)" to "project(Sunshine VERSION ${{ needs.check_changelog.outputs.next_version_bare }})" exit 1 - build_appimage: - name: AppImage - runs-on: ubuntu-20.04 - needs: check_changelog - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Setup Dependencies AppImage - run: | - sudo apt-get update -y && \ - sudo apt-get --reinstall install -y \ - git wget gcc-10 g++-10 build-essential cmake libssl-dev libavdevice-dev libboost-thread-dev libboost-filesystem-dev libboost-log-dev libpulse-dev libopus-dev libxtst-dev libx11-dev libxrandr-dev libxfixes-dev libevdev-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev libdrm-dev libcap-dev libwayland-dev - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 - sudo wget https://developer.download.nvidia.com/compute/cuda/11.4.2/local_installers/cuda_11.4.2_470.57.02_linux.run --progress=bar:force:noscroll -q --show-progress -O /root/cuda.run && sudo chmod a+x /root/cuda.run - sudo /root/cuda.run --silent --toolkit --toolkitpath=/usr --no-opengl-libs --no-man-page --no-drm && sudo rm /root/cuda.run - sudo add-apt-repository ppa:savoury1/graphics -y - sudo add-apt-repository ppa:savoury1/multimedia -y - sudo add-apt-repository ppa:savoury1/ffmpeg4 -y - sudo apt-get update -y - sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y - sudo apt-get install ffmpeg -y - - - name: Build AppImage - run: | - CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" - SUNSHINE_EXECUTABLE_PATH="${SUNSHINE_EXECUTABLE_PATH:-/usr/bin/sunshine}" - SUNSHINE_ASSETS_DIR="${SUNSHINE_ASSETS_DIR:-sunshine.AppImage.config}" - - SUNSHINE_ENABLE_WAYLAND=${SUNSHINE_ENABLE_WAYLAND:-ON} - SUNSHINE_ENABLE_X11=${SUNSHINE_ENABLE_X11:-ON} - SUNSHINE_ENABLE_DRM=${SUNSHINE_ENABLE_DRM:-ON} - SUNSHINE_ENABLE_CUDA=${SUNSHINE_ENABLE_CUDA:-ON} - - mkdir -p appimage-build && cd appimage-build - - cmake "-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" "-DSUNSHINE_EXECUTABLE_PATH=$SUNSHINE_EXECUTABLE_PATH" "-DSUNSHINE_ASSETS_DIR=$SUNSHINE_ASSETS_DIR" "-DSUNSHINE_ENABLE_WAYLAND=$SUNSHINE_ENABLE_WAYLAND" "-DSUNSHINE_ENABLE_X11=$SUNSHINE_ENABLE_X11" "-DSUNSHINE_ENABLE_DRM=$SUNSHINE_ENABLE_DRM" "-DSUNSHINE_ENABLE_CUDA=$SUNSHINE_ENABLE_CUDA" "../" -DCMAKE_INSTALL_PREFIX=/usr - make -j ${nproc} DESTDIR=AppDir - - - name: Set AppImage Version - if: ${{ needs.check_changelog.outputs.next_version_bare != needs.check_changelog.outputs.latest_version }} - run: | - version=${{ needs.check_changelog.outputs.next_version_bare }} - echo "VERSION=${version}" >> $GITHUB_ENV - - - name: Package AppImage - # https://docs.appimage.org/packaging-guide/index.html - run: | - mkdir -p artifacts - mkdir -p appimage_temp && cd appimage_temp - - DESKTOP_FILE="${DESKTOP_FILE:-sunshine.desktop}" - ICON_FILE="${ICON_FILE:-sunshine.png}" - # CONFIG_DIR="${CONFIG_DIR:-sunshine/sunshine.AppImage.config/}" - # HOME_DIR="${HOME_DIR:-sunshine/sunshine.AppImage.home/}" - - wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage && chmod +x linuxdeploy-x86_64.AppImage - - ./linuxdeploy-x86_64.AppImage --appdir ../AppDir -e ../appimage-build/sunshine -i "../$ICON_FILE" -d "../appimage-build/$DESKTOP_FILE" --output appimage - - # mv sunshine*.AppImage sunshine.AppImage - # mkdir sunshine && mv sunshine.AppImage sunshine/ - # ./sunshine/sunshine.AppImage --appimage-portable-config - # ./sunshine/sunshine.AppImage --appimage-portable-home - # cp -r ../assets/assets_common/* "$CONFIG_DIR" - # cp -r ../assets/assets_linux/* "$CONFIG_DIR" - - # mkdir -p ./"$HOME_DIR"/.config/"$CONFIG_DIR" - # cp ./"$CONFIG_DIR"/apps.json ./"$HOME_DIR"/.config/"$CONFIG_DIR" - # zip -r ./sunshine-appimage.zip ./sunshine/* - - # mv sunshine-appimage.zip ../artifacts/ - - mv sunshine*.AppImage ../artifacts/sunshine.AppImage - - # if testing succeeds, can remove commented lines - - - name: Verify AppImage - run: | - # cd appimage_temp - wget https://github.com/TheAssassin/appimagelint/releases/download/continuous/appimagelint-x86_64.AppImage && chmod +x appimagelint-x86_64.AppImage && ./appimagelint-x86_64.AppImage ./artifacts/sunshine.AppImage - - - name: Upload Artifacts - if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} - uses: actions/upload-artifact@v3 - with: - name: sunshine-appimage - path: artifacts/ - - - name: Create Release - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} - uses: SunshineStream/actions/create_release@master - with: - token: ${{ secrets.GITHUB_TOKEN }} - next_version: ${{ needs.check_changelog.outputs.next_version }} - last_version: ${{ needs.check_changelog.outputs.last_version }} - release_body: ${{ needs.check_changelog.outputs.release_body }} - build_linux: name: Linux runs-on: ubuntu-20.04 @@ -163,7 +63,6 @@ jobs: submodules: recursive - name: Setup Dependencies Linux run: | - mkdir -p artifacts sudo apt-get update -y && \ sudo apt-get --reinstall install -y \ git wget gcc-10 g++-10 build-essential cmake libssl-dev libavdevice-dev libboost-thread-dev libboost-filesystem-dev libboost-log-dev libpulse-dev libopus-dev libxtst-dev libx11-dev libxrandr-dev libxfixes-dev libevdev-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev libdrm-dev libcap-dev libwayland-dev @@ -179,31 +78,47 @@ jobs: - name: Build Linux run: | - CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" - SUNSHINE_EXECUTABLE_PATH="${SUNSHINE_EXECUTABLE_PATH:-/usr/bin/sunshine}" - SUNSHINE_ENABLE_WAYLAND=${SUNSHINE_ENABLE_WAYLAND:-ON} - SUNSHINE_ENABLE_X11=${SUNSHINE_ENABLE_X11:-ON} - SUNSHINE_ENABLE_DRM=${SUNSHINE_ENABLE_DRM:-ON} - SUNSHINE_ENABLE_CUDA=${SUNSHINE_ENABLE_CUDA:-ON} - SUNSHINE_CONFIG_DIR=${SUNSHINE_CONFIG_DIR:-.} - - mkdir -p build - mkdir -p artifacts + mkdir -p build cd build - cmake "-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" "-DSUNSHINE_CONFIG_DIR=$SUNSHINE_CONFIG_DIR" "-DSUNSHINE_EXECUTABLE_PATH=$SUNSHINE_EXECUTABLE_PATH" "-DSUNSHINE_ASSETS_DIR=$SUNSHINE_ASSETS_DIR" "-DSUNSHINE_ENABLE_WAYLAND=$SUNSHINE_ENABLE_WAYLAND" "-DSUNSHINE_ENABLE_X11=$SUNSHINE_ENABLE_X11" "-DSUNSHINE_ENABLE_DRM=$SUNSHINE_ENABLE_DRM" "-DSUNSHINE_ENABLE_CUDA=$SUNSHINE_ENABLE_CUDA" "../" -DCMAKE_INSTALL_PREFIX=/usr + cmake -DCMAKE_BUILD_TYPE=Release -DSUNSHINE_CONFIG_DIR=. -DSUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine -DSUNSHINE_ENABLE_WAYLAND=ON -DSUNSHINE_ENABLE_X11=ON -DSUNSHINE_ENABLE_DRM=ON -DSUNSHINE_ENABLE_CUDA=ON "../" + make -j ${nproc} + + - name: Set AppImage Version + if: ${{ needs.check_changelog.outputs.next_version_bare != needs.check_changelog.outputs.latest_version }} + run: | + version=${{ needs.check_changelog.outputs.next_version_bare }} + echo "VERSION=${version}" >> $GITHUB_ENV - name: Package Linux run: | + mkdir -p artifacts cd build + + # variables + DESKTOP_FILE="${DESKTOP_FILE:-sunshine.desktop}" + ICON_FILE="${ICON_FILE:-sunshine.png}" + + # AppImage + # https://docs.appimage.org/packaging-guide/index.html + wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage && chmod +x linuxdeploy-x86_64.AppImage + ./linuxdeploy-x86_64.AppImage --appdir . -e ./sunshine -i "../$ICON_FILE" -d "./$DESKTOP_FILE" --output appimage # package cpack -G DEB cpack -G RPM # move - mv Sunshine.deb ../artifacts/sunshine.deb - mv Sunshine.rpm ../artifacts/sunshine.rpm + mv sunshine*.AppImage ../artifacts/sunshine.AppImage + mv ./cpack_artifacts/Sunshine.deb ../artifacts/sunshine.deb + mv ./cpack_artifacts/Sunshine.rpm ../artifacts/sunshine.rpm + + - name: Verify AppImage + run: | + wget https://github.com/TheAssassin/appimagelint/releases/download/continuous/appimagelint-x86_64.AppImage + chmod +x appimagelint-x86_64.AppImage + + ./appimagelint-x86_64.AppImage ./artifacts/sunshine.AppImage - name: Upload Artifacts if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} @@ -244,7 +159,7 @@ jobs: run: | mkdir build cd build - cmake -DCMAKE_BUILD_TYPE=Release -DSUNSHINE_ASSETS_DIR=assets .. + cmake -DCMAKE_BUILD_TYPE=Release .. make -j ${nproc} - name: Package MacOS @@ -257,9 +172,9 @@ jobs: cpack -G ZIP # move - mv Sunshine.dmg ../artifacts/sunshine-macos.dmg - mv Sunshine.zip ../artifacts/sunshine-macos.zip mv Portfile ../artifacts/Portfile + mv ./cpack_artifacts/Sunshine.dmg ../artifacts/sunshine-macos.dmg + mv ./cpack_artifacts/Sunshine.zip ../artifacts/sunshine-macos.zip - name: Upload Artifacts if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} @@ -313,7 +228,7 @@ jobs: run: | mkdir build cd build - cmake -DCMAKE_BUILD_TYPE=Release -DSUNSHINE_ASSETS_DIR=assets -G "MinGW Makefiles" .. + cmake -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles" .. mingw32-make -j2 - name: Package Windows @@ -327,8 +242,8 @@ jobs: cpack -G ZIP # move - mv Sunshine.exe ../artifacts/sunshine-windows.exe - mv Sunshine.zip ../artifacts/sunshine-windows.zip + mv ./cpack_artifacts/Sunshine.exe ../artifacts/sunshine-windows.exe + mv ./cpack_artifacts/Sunshine.zip ../artifacts/sunshine-windows.zip - name: Upload Artifacts if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} diff --git a/CMakeLists.txt b/CMakeLists.txt index c12957b3..0640625a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -449,7 +449,8 @@ target_compile_options(sunshine PRIVATE $<$:${SUNSHINE_COM # Common options set(CPACK_PACKAGE_NAME "SunshineStream") -set(CPACK_PACKAGE_VENDOR "CMake.org") +set(CPACK_PACKAGE_VENDOR "SunshineStream") +set(CPACK_PACKAGE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cpack_artifacts) set(CPACK_PACKAGE_CONTACT "https://github.com/SunshineStream/Sunshine") set(CPACK_DEBIAN_PACKAGE_MAINTAINER "https://github.com/SunshineStream/Sunshine") set(CPACK_PACKAGE_DESCRIPTION "Gamestream host for Moonlight") @@ -486,7 +487,7 @@ if(WIN32) # see options at: https://cmake.org/cmake/help/latest/cpack_gen/nsis.h ") # Adding an option for the start menu and PATH - set(CPACK_NSIS_MODIFY_PATH "ON") # TODO: it asks to add it to the PATH but then it seems I can't just run it from powershell + set(CPACK_NSIS_MODIFY_PATH "OFF") # TODO: it asks to add it to the PATH but is not working https://gitlab.kitware.com/cmake/cmake/-/issues/15635 set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".") set(CPACK_NSIS_MUI_FINISHPAGE_RUN "${CMAKE_PROJECT_NAME}.exe") set(CPACK_NSIS_INSTALLED_ICON_NAME "${CMAKE_PROJECT_NAME}.exe") # This will be shown on the installed apps Windows settings @@ -501,12 +502,12 @@ if(WIN32) # see options at: https://cmake.org/cmake/help/latest/cpack_gen/nsis.h set(CPACK_COMPONENT_APPLICATION_DESCRIPTION "The main application.") set(CPACK_COMPONENT_APPLICATION_GROUP "${CMAKE_PROJECT_NAME}") set(CPACK_COMPONENT_APPLICATION_REQUIRED true) + set(CPACK_COMPONENT_APPLICATION_DEPENDS assets) # assets set(CPACK_COMPONENT_ASSETS_DISPLAY_NAME "Assets") set(CPACK_COMPONENT_ASSETS_DESCRIPTION "Assets include the apps and configurations, shaders, default box art, and web ui.") set(CPACK_COMPONENT_ASSETS_GROUP "${CMAKE_PROJECT_NAME}") - set(CPACK_COMPONENT_ASSETS_DEPENDS "${CMAKE_PROJECT_NAME}") set(CPACK_COMPONENT_ASSETS_REQUIRED true) # audio tool @@ -523,8 +524,6 @@ if(WIN32) # see options at: https://cmake.org/cmake/help/latest/cpack_gen/nsis.h set(CPACK_COMPONENT_SUNSHINESVC_DISPLAY_NAME "sunshinesvc.exe") set(CPACK_COMPONENT_SUNSHINESVC_DESCRIPTION "CLI tool that allows you to enable/disable the Sunshine service.") set(CPACK_COMPONENT_SUNSHINESVC_GROUP "Tools") - - # set(CPACK_COMPONENT_APPLICATION_DEPENDS assets) endif() if(APPLE) # TODO: test