Skip to content

build(packaging): version number improvements #4037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
10 changes: 6 additions & 4 deletions .github/workflows/ci-flatpak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ jobs:
run: |
# variables for manifest
branch="${{ github.head_ref }}"
build_version=${{ inputs.release_tag }}
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
22 changes: 9 additions & 13 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 Expand Up @@ -152,7 +148,7 @@ jobs:
- name: Validate Homebrew Formula
id: test
if: matrix.release != true
uses: LizardByte/actions/actions/release_homebrew@v2025.627.30023
uses: LizardByte/actions/actions/release_homebrew@v2025.703.21447
with:
formula_file: ${{ github.workspace }}/homebrew/sunshine.rb
git_email: ${{ secrets.GIT_EMAIL }}
Expand Down Expand Up @@ -229,7 +225,7 @@ jobs:
github.repository_owner == 'LizardByte' &&
matrix.release &&
inputs.publish_release == 'true'
uses: LizardByte/actions/actions/release_homebrew@v2025.627.30023
uses: LizardByte/actions/actions/release_homebrew@v2025.703.21447
with:
formula_file: ${{ github.workspace }}/homebrew/sunshine-beta.rb
git_email: ${{ secrets.GIT_EMAIL }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:

- name: Release Setup
id: release-setup
uses: LizardByte/actions/actions/release_setup@v2025.627.30023
uses: LizardByte/actions/actions/release_setup@v2025.703.21447
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -191,7 +191,7 @@ jobs:
run: ls -l artifacts

- name: Create/Update GitHub Release
uses: LizardByte/actions/actions/release_create@v2025.702.213340
uses: LizardByte/actions/actions/release_create@v2025.703.21447
with:
allowUpdates: false
body: ${{ needs.release-setup.outputs.release_body }}
Expand Down
39 changes: 30 additions & 9 deletions cmake/prep/build_version.cmake
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
# 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})
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 @@ -85,3 +100,9 @@ if(PROJECT_VERSION MATCHES "^([0-9]{4})[.]([0-9]{3,4})")
set(PROJECT_DAY "0${PROJECT_DAY}")
endif()
endif()

message("PROJECT_VERSION: ${PROJECT_VERSION}")
message("CMAKE_PROJECT_VERSION: ${CMAKE_PROJECT_VERSION}")
message("PROJECT_YEAR: ${PROJECT_YEAR}")
message("PROJECT_MONTH: ${PROJECT_MONTH}")
message("PROJECT_DAY: ${PROJECT_DAY}")
7 changes: 2 additions & 5 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 @@ -74,13 +75,9 @@ 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
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -201,7 +201,7 @@ class @PROJECT_NAME@ < Formula

def install
ENV["BRANCH"] = "@GITHUB_BRANCH@"
ENV["BUILD_VERSION"] = "@BUILD_VERSION@"
ENV["BUILD_VERSION"] = "v@BUILD_VERSION@"
ENV["COMMIT"] = "@GITHUB_COMMIT@"

args = %W[
Expand Down
Loading