Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
39ec202
Get version from git tags
TheElixZammuto Jan 13, 2023
14e0e6b
Added UI for Version Checking
TheElixZammuto Jan 13, 2023
730f713
Style fixes
TheElixZammuto Jan 28, 2023
dd49fc9
Moved version.h.in into src folder
TheElixZammuto Jan 28, 2023
a225b22
Fix version typo
TheElixZammuto Jan 28, 2023
740c47d
Fix build
TheElixZammuto Jan 28, 2023
7b7f9a0
cmake: fix cmake-lint errors
ReenigneArcher Jan 28, 2023
b612a11
Get version from cmakefiles
TheElixZammuto Jan 29, 2023
41dffbf
Merge pull request #85 from TheElixZammuto/nightly
TheElixZammuto Feb 4, 2023
82feeb5
Get version from git tags
TheElixZammuto Jan 13, 2023
0018cdf
Added UI for Version Checking
TheElixZammuto Jan 13, 2023
b934aee
Style fixes
TheElixZammuto Jan 28, 2023
bbca8bc
Moved version.h.in into src folder
TheElixZammuto Jan 28, 2023
f31d632
Fix version typo
TheElixZammuto Jan 28, 2023
3b8d847
Fix build
TheElixZammuto Jan 28, 2023
7f7d3dd
cmake: fix cmake-lint errors
ReenigneArcher Jan 28, 2023
8a2d218
Get version from cmakefiles
TheElixZammuto Jan 29, 2023
97d4531
cmake: fix lint error
ReenigneArcher Mar 8, 2023
2383577
docker: do not ignore .git directory
ReenigneArcher Mar 8, 2023
0f46490
docker: add git dependency
ReenigneArcher Mar 8, 2023
a2fc1c3
cmake: quote messages
ReenigneArcher Mar 8, 2023
d48d5aa
Let GitHub actions override git status
TheElixZammuto Mar 8, 2023
d5e92a1
Merge branch 'versioning-improvements' of github.com:TheElixZammuto/S…
TheElixZammuto Mar 8, 2023
594c836
add build env variables
ReenigneArcher Mar 8, 2023
c55f8d1
remove unnecessary cmake lint disable comment
ReenigneArcher Mar 8, 2023
1357d7d
fix branch and version checks
ReenigneArcher Mar 8, 2023
ef74ac7
replace `-` in version with `.`
ReenigneArcher Mar 9, 2023
268c5e1
cmake: quote messages and warn if git not installed
ReenigneArcher Mar 9, 2023
c55315b
Merge branch 'nightly' into pr/768
ReenigneArcher Mar 9, 2023
9965700
Merge branch 'nightly' into pr/768
ReenigneArcher Mar 9, 2023
55faada
update version checks in js
ReenigneArcher Mar 9, 2023
bd048d4
config: skip writing version
ReenigneArcher Mar 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# ignore git files
.git*

# ignore hidden files
.*

# do not ignore .git, needed for versioning
!/.git

# ignore repo directories and files
docs/
scripts/
Expand Down
24 changes: 19 additions & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
last_version: ${{ steps.verify_changelog.outputs.latest_release_tag_name }}
release_body: ${{ steps.verify_changelog.outputs.changelog_parser_description }}

# todo - remove this job once versioning is fully automated by cmake
check_versions:
name: Check Versions
runs-on: ubuntu-latest
Expand Down Expand Up @@ -362,6 +363,10 @@ jobs:
sudo rm /root/cuda.run

- name: Build Linux
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
BUILD_VERSION: ${{ needs.check_changelog.outputs.next_version_bare }}
COMMIT: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
mkdir -p build
mkdir -p artifacts
Expand Down Expand Up @@ -485,6 +490,10 @@ jobs:
ln -sf /usr/local/opt/openssl/include/openssl /usr/local/include/openssl

- name: Build MacOS
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
BUILD_VERSION: ${{ needs.check_changelog.outputs.next_version_bare }}
COMMIT: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
npm install

Expand Down Expand Up @@ -590,7 +599,8 @@ jobs:

mkdir build
cd build
cmake -DGITHUB_COMMIT=${commit} \
cmake \
-DGITHUB_COMMIT=${commit} \
-DGITHUB_CLONE_URL=${clone_url} \
-DSUNSHINE_CONFIGURE_PORTFILE=ON \
-DSUNSHINE_CONFIGURE_ONLY=ON \
Expand Down Expand Up @@ -641,6 +651,8 @@ jobs:
echo "subportlist=${subportlist}" >> $GITHUB_OUTPUT

- name: Run port lint for all subports
env:
subportlist: ${{ steps.subportlist.outputs.subportlist }}
run: |
set -eu
fail=0
Expand All @@ -662,10 +674,10 @@ jobs:
echo "::endgroup::"
done
exit "$fail"
env:
subportlist: ${{ steps.subportlist.outputs.subportlist }}

- name: Build subports
env:
subportlist: ${{ steps.subportlist.outputs.subportlist }}
run: |
set -eu
fail=0
Expand Down Expand Up @@ -714,8 +726,6 @@ jobs:
echo "::endgroup::"
done
exit "$fail"
env:
subportlist: ${{ steps.subportlist.outputs.subportlist }}

- name: Package
run: |
Expand Down Expand Up @@ -795,6 +805,10 @@ jobs:

- name: Build Windows
shell: msys2 {0}
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
BUILD_VERSION: ${{ needs.check_changelog.outputs.next_version_bare }}
COMMIT: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
mkdir build
cd build
Expand Down
64 changes: 62 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.18)
# `CMAKE_CUDA_ARCHITECTURES` requires 3.18

# todo - set version to 0.0.0 once confident in automated versioning
project(Sunshine VERSION 0.18.4
DESCRIPTION "Sunshine is a self-hosted game stream host for Moonlight."
HOMEPAGE_URL "https://app.lizardbyte.dev")
Expand All @@ -10,6 +11,65 @@ and Nvidia GPUs for hardware encoding. Software encoding is also available. You
Moonlight client on a variety of devices. A web UI is provided to allow configuration, and client pairing, from \
your favorite web browser. Pair from the local server or any mobile device.")

# Check if env vars are defined before attempting to access them, variables will be defined even if blank
if((DEFINED ENV{BRANCH}) AND (DEFINED ENV{BUILD_VERSION}) AND (DEFINED ENV{COMMIT})) # cmake-lint: disable=W0106
if(($ENV{BRANCH} STREQUAL "master") AND (NOT $ENV{BUILD_VERSION} STREQUAL ""))
# If BRANCH is "master" and BUILD_VERSION is not empty, then we are building a master branch
MESSAGE("Got from CI master branch and version $ENV{BUILD_VERSION}")
set(PROJECT_VERSION $ENV{BUILD_VERSION})
elseif((DEFINED ENV{BRANCH}) AND (DEFINED ENV{COMMIT}))
# If BRANCH is set but not BUILD_VERSION we are building nightly, we gather only the commit hash
MESSAGE("Got from CI $ENV{BRANCH} branch and commit $ENV{COMMIT}")
set(PROJECT_VERSION ${PROJECT_VERSION}.$ENV{COMMIT})
endif()
# Generate Sunshine Version based of the git tag
# https://github.com/nocnokneo/cmake-git-versioning-example/blob/master/LICENSE
else()
find_package(Git)
if(GIT_EXECUTABLE)
MESSAGE("${CMAKE_CURRENT_SOURCE_DIR}")
get_filename_component(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
#Get current Branch
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
#WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_DESCRIBE_BRANCH
RESULT_VARIABLE GIT_DESCRIBE_ERROR_CODE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Gather current commit
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
#WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_DESCRIBE_VERSION
RESULT_VARIABLE GIT_DESCRIBE_ERROR_CODE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Check if Dirty
execute_process(
COMMAND ${GIT_EXECUTABLE} diff --quiet --exit-code
#WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_IS_DIRTY
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT GIT_DESCRIBE_ERROR_CODE)
MESSAGE("Sunshine Branch: ${GIT_DESCRIBE_BRANCH}")
if(NOT GIT_DESCRIBE_BRANCH STREQUAL "master")
set(PROJECT_VERSION ${PROJECT_VERSION}.${GIT_DESCRIBE_VERSION})
MESSAGE("Sunshine Version: ${GIT_DESCRIBE_VERSION}")
endif()
if(GIT_IS_DIRTY)
set(PROJECT_VERSION ${PROJECT_VERSION}.dirty)
MESSAGE("Git tree is dirty!")
endif()
else()
MESSAGE(ERROR ": Got git error while fetching tags: ${GIT_DESCRIBE_ERROR_CODE}")
endif()
else()
MESSAGE(WARNING ": Git not found, cannot find git version")
endif()
endif()

option(SUNSHINE_CONFIGURE_APPIMAGE "Configuration specific for AppImage." OFF)
option(SUNSHINE_CONFIGURE_AUR "Configure files required for AUR." OFF)
option(SUNSHINE_CONFIGURE_FLATPAK_MAN "Configure manifest file required for Flatpak build." OFF)
Expand Down Expand Up @@ -75,7 +135,7 @@ pkg_check_modules(CURL REQUIRED libcurl)
if(WIN32)
set(Boost_USE_STATIC_LIBS ON) # cmake-lint: disable=C0103
# workaround to prevent link errors against icudata, icui18n
set(Boost_NO_BOOST_CMAKE ON) # cmake-lint: disable=C0103
set(Boost_NO_BOOST_CMAKE ON) # cmake-lint: disable=C0103
endif()

find_package(Boost COMPONENTS locale log filesystem program_options REQUIRED)
Expand Down Expand Up @@ -396,7 +456,7 @@ ${CMAKE_BINARY_DIR}/generated-src/${filename}.h")
configure_file(sunshine.service.in sunshine.service @ONLY)
endif()

configure_file(version.h.in version.h @ONLY)
configure_file(src/version.h.in version.h @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR})

set(SUNSHINE_TARGET_FILES
Expand Down
6 changes: 6 additions & 0 deletions docker/archlinux.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ RUN useradd -m builder && \

FROM sunshine-base as sunshine-build

ARG BRANCH
ARG BUILD_VERSION
ARG COMMIT
ARG CLONE_URL
# note: BUILD_VERSION may be blank

ENV BRANCH=${BRANCH}
ENV BUILD_VERSION=${BUILD_VERSION}
ENV COMMIT=${COMMIT}

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# install dependencies
# cuda, libcap, and libdrm are optional dependencies for PKGBUILD
Expand All @@ -37,6 +42,7 @@ pacman -Syu --noconfirm \
base-devel \
cmake \
cuda \
git \
libcap \
libdrm \
namcap
Expand Down
10 changes: 10 additions & 0 deletions docker/debian-bullseye.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ FROM sunshine-base as sunshine-build
ARG TARGETPLATFORM
RUN echo "target_platform: ${TARGETPLATFORM}"

ARG BRANCH
ARG BUILD_VERSION
ARG COMMIT
# note: BUILD_VERSION may be blank

ENV BRANCH=${BRANCH}
ENV BUILD_VERSION=${BUILD_VERSION}
ENV COMMIT=${COMMIT}

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# install dependencies
RUN <<_DEPS
Expand All @@ -23,6 +32,7 @@ apt-get update -y
apt-get install -y --no-install-recommends \
build-essential=12.9* \
cmake=3.18.4* \
git=1:2.30.2* \
libavdevice-dev=7:4.3.* \
libboost-filesystem-dev=1.74.0* \
libboost-locale-dev=1.74.0* \
Expand Down
10 changes: 10 additions & 0 deletions docker/fedora-36.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ FROM sunshine-base as sunshine-build
ARG TARGETPLATFORM
RUN echo "target_platform: ${TARGETPLATFORM}"

ARG BRANCH
ARG BUILD_VERSION
ARG COMMIT
# note: BUILD_VERSION may be blank

ENV BRANCH=${BRANCH}
ENV BUILD_VERSION=${BUILD_VERSION}
ENV COMMIT=${COMMIT}

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# install dependencies
# hadolint ignore=DL3041
Expand All @@ -25,6 +34,7 @@ dnf -y install \
cmake-3.22.2* \
gcc-12.0.1* \
gcc-c++-12.0.1* \
git-2.39.2* \
libcap-devel-2.48* \
libcurl-devel-7.82.0* \
libdrm-devel-2.4.110* \
Expand Down
10 changes: 10 additions & 0 deletions docker/fedora-37.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ FROM sunshine-base as sunshine-build
ARG TARGETPLATFORM
RUN echo "target_platform: ${TARGETPLATFORM}"

ARG BRANCH
ARG BUILD_VERSION
ARG COMMIT
# note: BUILD_VERSION may be blank

ENV BRANCH=${BRANCH}
ENV BUILD_VERSION=${BUILD_VERSION}
ENV COMMIT=${COMMIT}

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# install dependencies
# hadolint ignore=DL3041
Expand All @@ -25,6 +34,7 @@ dnf -y install \
cmake-3.24.1* \
gcc-12.2.1* \
gcc-c++-12.2.1* \
git-2.39.2* \
libcap-devel-2.48* \
libcurl-devel-7.85.0* \
libdrm-devel-2.4.112* \
Expand Down
10 changes: 10 additions & 0 deletions docker/ubuntu-20.04.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ FROM sunshine-base as sunshine-build
ARG TARGETPLATFORM
RUN echo "target_platform: ${TARGETPLATFORM}"

ARG BRANCH
ARG BUILD_VERSION
ARG COMMIT
# note: BUILD_VERSION may be blank

ENV BRANCH=${BRANCH}
ENV BUILD_VERSION=${BUILD_VERSION}
ENV COMMIT=${COMMIT}

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# install dependencies
RUN <<_DEPS
Expand All @@ -24,6 +33,7 @@ apt-get install -y --no-install-recommends \
build-essential=12.8* \
gcc-10=10.3.0* \
g++-10=10.3.0* \
git=1:2.25.1* \
libavdevice-dev=7:4.2.* \
libboost-filesystem-dev=1.71.0* \
libboost-locale-dev=1.71.0* \
Expand Down
10 changes: 10 additions & 0 deletions docker/ubuntu-22.04.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ FROM sunshine-base as sunshine-build
ARG TARGETPLATFORM
RUN echo "target_platform: ${TARGETPLATFORM}"

ARG BRANCH
ARG BUILD_VERSION
ARG COMMIT
# note: BUILD_VERSION may be blank

ENV BRANCH=${BRANCH}
ENV BUILD_VERSION=${BUILD_VERSION}
ENV COMMIT=${COMMIT}

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# install dependencies
RUN <<_DEPS
Expand All @@ -23,6 +32,7 @@ apt-get update -y
apt-get install -y --no-install-recommends \
build-essential=12.9* \
cmake=3.22.1* \
git=1:2.34.1* \
libavdevice-dev=7:4.4.* \
libboost-filesystem-dev=1.74.0* \
libboost-locale-dev=1.74.0* \
Expand Down
2 changes: 2 additions & 0 deletions src/confighttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "rtsp.h"
#include "utility.h"
#include "uuid.h"
#include "version.h"

using namespace std::literals;

Expand Down Expand Up @@ -503,6 +504,7 @@ void getConfig(resp_https_t response, req_https_t request) {

outputTree.put("status", "true");
outputTree.put("platform", SUNSHINE_PLATFORM);
outputTree.put("version", PROJECT_VER);
outputTree.put("restart_supported", platf::restart_supported());

auto vars = config::parse_config(read_file(config::sunshine.config_file.c_str()));
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ int main(int argc, char *argv[]) {

return fn->second(argv[0], config::sunshine.cmd.argc, config::sunshine.cmd.argv);
}

BOOST_LOG(info) << PROJECT_NAME << " version: " << PROJECT_VER << std::endl;
task_pool.start(1);

// Create signal handler after logging has been initialized
Expand Down
2 changes: 1 addition & 1 deletion version.h.in → src/version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
#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@"
#define PROJECT_VER_PATCH "@PROJECT_VERSION_PATCH@"

#endif // INCLUDE_GUARD
Loading