From c7a3f7f46e4b47efd627c16da357d126e5ff7e02 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sun, 23 Jan 2022 13:05:35 -0500 Subject: [PATCH 1/3] Add version argument --- CMakeLists.txt | 10 ++++++++-- sunshine/main.cpp | 12 +++++++++++- version.h.in | 10 ++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 version.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 0115a264..20751568 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.0) -project(Sunshine) +project(Sunshine VERSION 0.11.1) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) @@ -258,6 +258,9 @@ else() configure_file(sunshine.service.in sunshine.service @ONLY) endif() +configure_file(version.h.in version.h @ONLY) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + set(SUNSHINE_TARGET_FILES third-party/moonlight-common-c/reedsolomon/rs.c third-party/moonlight-common-c/reedsolomon/rs.h @@ -367,7 +370,10 @@ list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_DEFAULT_DIR="${SUNSHINE_DEFAULT_DIR}") add_executable(sunshine ${SUNSHINE_TARGET_FILES}) target_link_libraries(sunshine ${SUNSHINE_EXTERNAL_LIBRARIES}) target_compile_definitions(sunshine PUBLIC ${SUNSHINE_DEFINITIONS}) -set_target_properties(sunshine PROPERTIES CXX_STANDARD 17) +set_target_properties(sunshine PROPERTIES CXX_STANDARD 17 + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} + ) if(NOT DEFINED CMAKE_CUDA_STANDARD) set(CMAKE_CUDA_STANDARD 17) diff --git a/sunshine/main.cpp b/sunshine/main.cpp index b2bed72f..237b80ff 100644 --- a/sunshine/main.cpp +++ b/sunshine/main.cpp @@ -25,6 +25,7 @@ #include "thread_pool.h" #include "upnp.h" #include "video.h" +#include "version.h" #include "platform/common.h" extern "C" { @@ -63,6 +64,7 @@ void print_help(const char *name) { << std::endl << " --help | print help"sv << std::endl << " --creds username password | set user credentials for the Web manager" << std::endl + << " --version | print the version of sunshine" << std::endl << std::endl << " flags"sv << std::endl << " -0 | Read PIN from stdin"sv << std::endl @@ -80,6 +82,13 @@ int entry(const char *name, int argc, char *argv[]) { } } // namespace help +namespace version { +int entry(const char *name, int argc, char *argv[]) { + std::cout << PROJECT_NAME << " version: " << PROJECT_VER << std::endl; + return 0; +} +} // namespace version + void log_flush() { sink->flush(); } @@ -111,7 +120,8 @@ int entry(const char *name, int argc, char *argv[]) { std::map> cmd_to_func { { "creds"sv, gen_creds::entry }, - { "help"sv, help::entry } + { "help"sv, help::entry }, + { "version"sv, version::entry } }; int main(int argc, char *argv[]) { diff --git a/version.h.in b/version.h.in new file mode 100644 index 00000000..5deb996b --- /dev/null +++ b/version.h.in @@ -0,0 +1,10 @@ +#ifndef INCLUDE_GUARD +#define INCLUDE_GUARD + +#define PROJECT_NAME "@PROJECT_NAME@" +#define PROJECT_VER "@PROJECT_VERSION@" +#define PROJECT_VER_MAJOR "@PROJECT_VERSION_MAJOR@" +#define PROJECT_VER_MINOR "@PROJECT_VERSION_MINOR@" +#define PTOJECT_VER_PATCH "@PROJECT_VERSION_PATCH@" + +#endif // INCLUDE_GUARD From 592cb002bd542b30da11db76f5d62da86144214c Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sun, 23 Jan 2022 18:20:37 -0500 Subject: [PATCH 2/3] Add version test - Add version test on push or PR targets to master branch (AppImage only) --- .github/workflows/create_package.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/create_package.yml b/.github/workflows/create_package.yml index 74e48f5d..b0d896ce 100644 --- a/.github/workflows/create_package.yml +++ b/.github/workflows/create_package.yml @@ -100,6 +100,19 @@ jobs: 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 ./sunshine/sunshine.AppImage + - name: Check Version + if: ${{ github.ref == 'refs/heads/master' || github.base_ref == 'master' }} + # base_ref for pull request check, ref for push + run: | + cd ./appimage_temp/sunshine + version=$(./sunshine.AppImage --version | grep -o -E '[0-9]+\.[0-9]+\.[0-9]+') + echo "sunshine_version=v${version}" >> $GITHUB_ENV + - name: Compare Versions + if: ${{ ( github.ref == 'refs/heads/master' || github.base_ref == 'master') && ( env.sunshine_version != needs.check_changelog.outputs.next_version ) }} + run: | + echo AppImage version: "$sunshine_version" + echo Changelog version: "${{ needs.check_changelog.outputs.next_version }}" + exit 1 - name: Upload Artifacts if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} uses: actions/upload-artifact@v2 From ed62a1f93d74f78d652af2504bd7dcc6594db224 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sun, 23 Jan 2022 18:38:15 -0500 Subject: [PATCH 3/3] Add "v" to --version argument output --- .github/workflows/create_package.yml | 4 ++-- sunshine/main.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/create_package.yml b/.github/workflows/create_package.yml index b0d896ce..76fc3378 100644 --- a/.github/workflows/create_package.yml +++ b/.github/workflows/create_package.yml @@ -105,8 +105,8 @@ jobs: # base_ref for pull request check, ref for push run: | cd ./appimage_temp/sunshine - version=$(./sunshine.AppImage --version | grep -o -E '[0-9]+\.[0-9]+\.[0-9]+') - echo "sunshine_version=v${version}" >> $GITHUB_ENV + version=$(./sunshine.AppImage --version | grep -o -E 'v[0-9]+\.[0-9]+\.[0-9]+') + echo "sunshine_version=${version}" >> $GITHUB_ENV - name: Compare Versions if: ${{ ( github.ref == 'refs/heads/master' || github.base_ref == 'master') && ( env.sunshine_version != needs.check_changelog.outputs.next_version ) }} run: | diff --git a/sunshine/main.cpp b/sunshine/main.cpp index 237b80ff..b5126f66 100644 --- a/sunshine/main.cpp +++ b/sunshine/main.cpp @@ -84,7 +84,7 @@ int entry(const char *name, int argc, char *argv[]) { namespace version { int entry(const char *name, int argc, char *argv[]) { - std::cout << PROJECT_NAME << " version: " << PROJECT_VER << std::endl; + std::cout << PROJECT_NAME << " version: v" << PROJECT_VER << std::endl; return 0; } } // namespace version