Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 7 additions & 5 deletions .github/workflows/ci-flatpak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
release_commit:
required: true
type: string
release_tag:
release_version:
required: true
type: string

Expand Down Expand Up @@ -104,14 +104,14 @@ jobs:
run: |
# variables for manifest
branch="${{ github.head_ref }}"
build_version=${{ inputs.release_version }}
commit=${{ inputs.release_commit }}

# check the branch variable
if [ -z "$branch" ]
then
echo "This is a PUSH event"
branch=${{ github.ref_name }}
build_version=${{ inputs.release_tag }}
clone_url=${{ github.event.repository.clone_url }}
else
echo "This is a PR event"
Expand All @@ -121,15 +121,17 @@ jobs:
echo "Commit: ${commit}"
echo "Clone URL: ${clone_url}"

export BRANCH=${branch}
export BUILD_VERSION=${build_version}
export CLONE_URL=${clone_url}
export COMMIT=${commit}

mkdir -p build
mkdir -p artifacts

cmake -DGITHUB_CLONE_URL=${clone_url} \
-B build \
-S . \
-DBUILD_VERSION=${build_version} \
-DGITHUB_BRANCH=${branch} \
-DGITHUB_COMMIT=${commit} \
-DSUNSHINE_CONFIGURE_FLATPAK_MAN=ON \
-DSUNSHINE_CONFIGURE_ONLY=ON

Expand Down
18 changes: 7 additions & 11 deletions .github/workflows/ci-homebrew.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,49 +76,45 @@ jobs:
run: |
# variables for formula
branch="${{ github.head_ref }}"
build_version=${{ inputs.release_version }}
commit=${{ inputs.release_commit }}

# check the branch variable
if [ -z "$branch" ]
then
echo "This is a PUSH event"
build_version=${{ inputs.release_tag }}
clone_url=${{ github.event.repository.clone_url }}
branch="${{ github.ref_name }}"
default_branch="${{ github.event.repository.default_branch }}"

if [ "${{ matrix.release }}" == "true" ]; then
# we will publish the formula with the release tag
tag="${{ inputs.release_tag }}"
version="${{ inputs.release_version }}"
else
tag="${{ github.ref_name }}"
version="0.0.${{ github.run_number }}"
fi
else
echo "This is a PR event"
build_version="0.0.${{ github.event.number }}"
clone_url=${{ github.event.pull_request.head.repo.clone_url }}
branch="${{ github.event.pull_request.head.ref }}"
default_branch="${{ github.event.pull_request.head.repo.default_branch }}"
tag="${{ github.event.pull_request.head.ref }}"
version="0.0.${{ github.event.number }}"
fi
echo "Branch: ${branch}"
echo "Clone URL: ${clone_url}"
echo "Tag: ${tag}"

export BRANCH=${branch}
export BUILD_VERSION=${build_version}
export CLONE_URL=${clone_url}
export COMMIT=${commit}
export TAG=${tag}

mkdir -p build
cmake \
-B build \
-S . \
-DBUILD_VERSION="${build_version}" \
-DFORMULA_VERSION="${version}" \
-DGITHUB_BRANCH="${branch}" \
-DGITHUB_COMMIT="${commit}" \
-DGITHUB_CLONE_URL="${clone_url}" \
-DGITHUB_DEFAULT_BRANCH="${default_branch}" \
-DGITHUB_TAG="${tag}" \
-DSUNSHINE_CONFIGURE_HOMEBREW=ON \
-DSUNSHINE_CONFIGURE_ONLY=ON

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
release_commit:
required: true
type: string
release_tag:
release_version:
required: true
type: string

Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
- name: Build Linux
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
BUILD_VERSION: ${{ inputs.release_tag }}
BUILD_VERSION: ${{ inputs.release_version }}
COMMIT: ${{ inputs.release_commit }}
run: |
chmod +x ./scripts/linux_build.sh
Expand All @@ -102,7 +102,7 @@ jobs:
- name: Set AppImage Version
if: matrix.name == 'AppImage'
run: |
version=${{ inputs.release_tag }}
version=${{ inputs.release_version }}
echo "VERSION=${version}" >> $GITHUB_ENV

- name: Package Linux - AppImage
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
release_commit:
required: true
type: string
release_tag:
release_version:
required: true
type: string
secrets:
Expand Down Expand Up @@ -257,7 +257,7 @@ jobs:
shell: msys2 {0}
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
BUILD_VERSION: ${{ inputs.release_tag }}
BUILD_VERSION: ${{ inputs.release_version }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
COMMIT: ${{ inputs.release_commit }}
run: |
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ jobs:
publish_release: ${{ needs.release-setup.outputs.publish_release }}
release_commit: ${{ needs.release-setup.outputs.release_commit }}
release_tag: ${{ needs.release-setup.outputs.release_tag }}
release_version: ${{ needs.release-setup.outputs.release_version }}
secrets:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
Expand Down Expand Up @@ -87,10 +88,11 @@ jobs:
uses: ./.github/workflows/ci-linux.yml
with:
release_commit: ${{ needs.release-setup.outputs.release_commit }}
release_tag: ${{ needs.release-setup.outputs.release_tag }}
release_version: ${{ needs.release-setup.outputs.release_version }}

build-linux-copr:
name: Linux Copr
if: github.event_name != 'push' # releases are handled directly in ci-copr.yml
needs: release-setup
uses: ./.github/workflows/ci-copr.yml
secrets:
Expand All @@ -104,15 +106,15 @@ jobs:
uses: ./.github/workflows/ci-flatpak.yml
with:
release_commit: ${{ needs.release-setup.outputs.release_commit }}
release_tag: ${{ needs.release-setup.outputs.release_tag }}
release_version: ${{ needs.release-setup.outputs.release_version }}

build-windows:
name: Windows
needs: release-setup
uses: ./.github/workflows/ci-windows.yml
with:
release_commit: ${{ needs.release-setup.outputs.release_commit }}
release_tag: ${{ needs.release-setup.outputs.release_tag }}
release_version: ${{ needs.release-setup.outputs.release_version }}
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Expand Down
3 changes: 0 additions & 3 deletions cmake/compile_definitions/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ include_directories(BEFORE SYSTEM "${CMAKE_SOURCE_DIR}/third-party/nv-codec-head
file(GLOB NVENC_SOURCES CONFIGURE_DEPENDS "src/nvenc/*.cpp" "src/nvenc/*.h")
list(APPEND PLATFORM_TARGET_FILES ${NVENC_SOURCES})

configure_file("${CMAKE_SOURCE_DIR}/src/version.h.in" version.h @ONLY)
include_directories(BEFORE "${CMAKE_CURRENT_BINARY_DIR}") # required for importing version.h

set(SUNSHINE_TARGET_FILES
"${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/src/Input.h"
"${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/src/Rtsp.h"
Expand Down
5 changes: 4 additions & 1 deletion cmake/packaging/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
# common cpack options
set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
set(CPACK_PACKAGE_VENDOR "LizardByte")
string(REGEX REPLACE "^v" "" CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) # remove the v prefix if it exists
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cpack_artifacts)
set(CPACK_PACKAGE_CONTACT "https://app.lizardbyte.dev")
set(CPACK_PACKAGE_DESCRIPTION ${CMAKE_PROJECT_DESCRIPTION})
Expand Down
78 changes: 66 additions & 12 deletions cmake/prep/build_version.cmake
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
# Set build variables if env variables are defined
# These are used in configured files such as manifests for different packages
if(DEFINED ENV{BRANCH}) # cmake-lint: disable=W0106
set(GITHUB_BRANCH $ENV{BRANCH})
endif()
if(DEFINED ENV{BUILD_VERSION}) # cmake-lint: disable=W0106
set(BUILD_VERSION $ENV{BUILD_VERSION})
endif()
if(DEFINED ENV{CLONE_URL}) # cmake-lint: disable=W0106
set(GITHUB_CLONE_URL $ENV{CLONE_URL})
endif()
if(DEFINED ENV{COMMIT}) # cmake-lint: disable=W0106
set(GITHUB_COMMIT $ENV{COMMIT})
endif()
if(DEFINED ENV{TAG}) # cmake-lint: disable=W0106
set(GITHUB_TAG $ENV{TAG})
endif()

# 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}")
if((DEFINED ENV{BRANCH}) AND (DEFINED ENV{BUILD_VERSION})) # cmake-lint: disable=W0106
if((DEFINED ENV{BRANCH}) AND (NOT $ENV{BUILD_VERSION} STREQUAL ""))
# If BRANCH is defined and BUILD_VERSION is not empty, then we are building from CI
# If BRANCH is master we are building a push/release build
MESSAGE("Got from CI '$ENV{BRANCH}' branch and version '$ENV{BUILD_VERSION}'")
set(PROJECT_VERSION $ENV{BUILD_VERSION})
string(REGEX REPLACE "^v" "" PROJECT_VERSION ${PROJECT_VERSION}) # remove the v prefix if it exists
set(CMAKE_PROJECT_VERSION ${PROJECT_VERSION}) # cpack will use this to set the binary versions
elseif((DEFINED ENV{BRANCH}) AND (DEFINED ENV{COMMIT}))
# If BRANCH is set but not BUILD_VERSION we are building a PR, 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()
else()
# 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_SOURCE_DIR}")
Expand Down Expand Up @@ -60,18 +76,24 @@ set(PROJECT_YEAR "1990")
set(PROJECT_MONTH "01")
set(PROJECT_DAY "01")

# Extract year, month, and day
if(PROJECT_VERSION MATCHES "^([0-9]{4})[.]([0-9]{3,4})")
# Extract year, month, and day (do this AFTER version parsing)
# Note: Cmake doesn't support "{}" regex syntax
if(PROJECT_VERSION MATCHES "^([0-9][0-9][0-9][0-9])\\.([0-9][0-9][0-9][0-9]?)\\.([0-9]+)$")
message("Extracting year and month/day from PROJECT_VERSION: ${PROJECT_VERSION}")
# First capture group is the year
set(PROJECT_YEAR "${CMAKE_MATCH_1}")

# Second capture group is month/day
# Second capture group contains month and day
set(MONTH_DAY "${CMAKE_MATCH_2}")

# Extract month (first 1-2 digits) and day (last 2 digits)
string(LENGTH "${MONTH_DAY}" MONTH_DAY_LENGTH)
if(MONTH_DAY_LENGTH EQUAL 3)
# Format: MDD (e.g., 703 = month 7, day 03)
string(SUBSTRING "${MONTH_DAY}" 0 1 PROJECT_MONTH)
string(SUBSTRING "${MONTH_DAY}" 1 2 PROJECT_DAY)
elseif(MONTH_DAY_LENGTH EQUAL 4)
# Format: MMDD (e.g., 1203 = month 12, day 03)
string(SUBSTRING "${MONTH_DAY}" 0 2 PROJECT_MONTH)
string(SUBSTRING "${MONTH_DAY}" 2 2 PROJECT_DAY)
endif()
Expand All @@ -85,3 +107,35 @@ if(PROJECT_VERSION MATCHES "^([0-9]{4})[.]([0-9]{3,4})")
set(PROJECT_DAY "0${PROJECT_DAY}")
endif()
endif()

# Parse PROJECT_VERSION to extract major, minor, and patch components
if(PROJECT_VERSION MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+)")
set(PROJECT_VERSION_MAJOR "${CMAKE_MATCH_1}")
set(CMAKE_PROJECT_VERSION_MAJOR "${CMAKE_MATCH_1}")

set(PROJECT_VERSION_MINOR "${CMAKE_MATCH_2}")
set(CMAKE_PROJECT_VERSION_MINOR "${CMAKE_MATCH_2}")

set(PROJECT_VERSION_PATCH "${CMAKE_MATCH_3}")
set(CMAKE_PROJECT_VERSION_PATCH "${CMAKE_MATCH_3}")
endif()

message("PROJECT_NAME: ${PROJECT_NAME}")
message("PROJECT_VERSION: ${PROJECT_VERSION}")
message("PROJECT_VERSION_MAJOR: ${PROJECT_VERSION_MAJOR}")
message("PROJECT_VERSION_MINOR: ${PROJECT_VERSION_MINOR}")
message("PROJECT_VERSION_PATCH: ${PROJECT_VERSION_PATCH}")
message("CMAKE_PROJECT_VERSION: ${CMAKE_PROJECT_VERSION}")
message("CMAKE_PROJECT_VERSION_MAJOR: ${CMAKE_PROJECT_VERSION_MAJOR}")
message("CMAKE_PROJECT_VERSION_MINOR: ${CMAKE_PROJECT_VERSION_MINOR}")
message("CMAKE_PROJECT_VERSION_PATCH: ${CMAKE_PROJECT_VERSION_PATCH}")
message("PROJECT_YEAR: ${PROJECT_YEAR}")
message("PROJECT_MONTH: ${PROJECT_MONTH}")
message("PROJECT_DAY: ${PROJECT_DAY}")

list(APPEND SUNSHINE_DEFINITIONS PROJECT_NAME="${PROJECT_NAME}")
list(APPEND SUNSHINE_DEFINITIONS PROJECT_VERSION="${PROJECT_VERSION}")
list(APPEND SUNSHINE_DEFINITIONS PROJECT_VERSION_MAJOR="${PROJECT_VERSION_MAJOR}")
list(APPEND SUNSHINE_DEFINITIONS PROJECT_VERSION_MINOR="${PROJECT_VERSION_MINOR}")
list(APPEND SUNSHINE_DEFINITIONS PROJECT_VERSION_PATCH="${PROJECT_VERSION_PATCH}")
list(APPEND SUNSHINE_DEFINITIONS PROJECT_VERSION_COMMIT="${GITHUB_COMMIT}")
14 changes: 6 additions & 8 deletions docker/archlinux.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ ARG CLONE_URL
ENV BRANCH=${BRANCH}
ENV BUILD_VERSION=${BUILD_VERSION}
ENV COMMIT=${COMMIT}
ENV CLONE_URL=${CLONE_URL}

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

Expand Down Expand Up @@ -68,19 +69,16 @@ WORKDIR /build/sunshine/build
RUN <<_MAKE
#!/bin/bash
set -e
if [[ "${BUILD_VERSION}" == '' ]]; then

sub_version=""
if [[ "${BRANCH}" != "master" ]]; then
sub_version=".r${COMMIT}"
else
sub_version=""
fi

cmake \
-DSUNSHINE_CONFIGURE_ONLY=ON \
-DSUNSHINE_CONFIGURE_PKGBUILD=ON \
-DSUNSHINE_SUB_VERSION="${sub_version}" \
-DGITHUB_CLONE_URL="${CLONE_URL}" \
-DGITHUB_BRANCH=${BRANCH} \
-DGITHUB_BUILD_VERSION=${BUILD_VERSION} \
-DGITHUB_COMMIT="${COMMIT}" \
-DSUNSHINE_CONFIGURE_ONLY=ON \
/build/sunshine
_MAKE

Expand Down
2 changes: 1 addition & 1 deletion packaging/linux/Arch/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ prepare() {

build() {
export BRANCH="@GITHUB_BRANCH@"
export BUILD_VERSION="@GITHUB_BUILD_VERSION@"
export BUILD_VERSION="@BUILD_VERSION@"
export COMMIT="@GITHUB_COMMIT@"

export CC="gcc-${_gcc_version}"
Expand Down
2 changes: 1 addition & 1 deletion packaging/sunshine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class @PROJECT_NAME@ < Formula
homepage "@PROJECT_HOMEPAGE_URL@"
url "@GITHUB_CLONE_URL@",
tag: "@GITHUB_TAG@"
version "@FORMULA_VERSION@"
version "@BUILD_VERSION@"
license all_of: ["GPL-3.0-only"]
head "@GITHUB_CLONE_URL@", branch: "@GITHUB_DEFAULT_BRANCH@"

Expand Down
3 changes: 1 addition & 2 deletions src/confighttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "process.h"
#include "utility.h"
#include "uuid.h"
#include "version.h"

using namespace std::literals;

Expand Down Expand Up @@ -843,7 +842,7 @@ namespace confighttp {
nlohmann::json output_tree;
output_tree["status"] = true;
output_tree["platform"] = SUNSHINE_PLATFORM;
output_tree["version"] = PROJECT_VER;
output_tree["version"] = PROJECT_VERSION;

auto vars = config::parse_config(file_handler::read_file(config::sunshine.config_file.c_str()));

Expand Down
1 change: 0 additions & 1 deletion src/entry_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "logging.h"
#include "network.h"
#include "platform/common.h"
#include "version.h"

extern "C" {
#ifdef _WIN32
Expand Down
Loading
Loading