fix: make version update check more robust (#2437)

This commit is contained in:
ReenigneArcher 2024-04-18 15:35:49 -04:00 committed by GitHub
commit 69191cafe9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 33 additions and 5 deletions

View file

@ -211,6 +211,7 @@ jobs:
then then
echo "This is a PUSH event" echo "This is a PUSH event"
branch=${{ github.ref_name }} branch=${{ github.ref_name }}
build_version=${{ needs.check_changelog.outputs.next_version }}
commit=${{ github.sha }} commit=${{ github.sha }}
clone_url=${{ github.event.repository.clone_url }} clone_url=${{ github.event.repository.clone_url }}
else else
@ -227,6 +228,7 @@ jobs:
cd build cd build
cmake -DGITHUB_CLONE_URL=${clone_url} \ cmake -DGITHUB_CLONE_URL=${clone_url} \
-DBUILD_VERSION=${build_version} \
-DGITHUB_BRANCH=${branch} \ -DGITHUB_BRANCH=${branch} \
-DGITHUB_COMMIT=${commit} \ -DGITHUB_COMMIT=${commit} \
-DSUNSHINE_CONFIGURE_FLATPAK_MAN=ON \ -DSUNSHINE_CONFIGURE_FLATPAK_MAN=ON \
@ -377,7 +379,7 @@ jobs:
- name: Build Linux - name: Build Linux
env: env:
BRANCH: ${{ github.head_ref || github.ref_name }} BRANCH: ${{ github.head_ref || github.ref_name }}
BUILD_VERSION: ${{ needs.check_changelog.outputs.next_version_bare }} BUILD_VERSION: ${{ needs.check_changelog.outputs.next_version }}
COMMIT: ${{ github.event.pull_request.head.sha || github.sha }} COMMIT: ${{ github.event.pull_request.head.sha || github.sha }}
timeout-minutes: 5 timeout-minutes: 5
run: | run: |
@ -565,13 +567,16 @@ jobs:
if [ -z "$branch" ] if [ -z "$branch" ]
then then
echo "This is a PUSH event" echo "This is a PUSH event"
build_version=${{ needs.check_changelog.outputs.next_version }}
clone_url=${{ github.event.repository.clone_url }} clone_url=${{ github.event.repository.clone_url }}
branch="${{ github.ref_name }}" branch="${{ github.ref_name }}"
commit=${{ github.sha }}
default_branch="${{ github.event.repository.default_branch }}" default_branch="${{ github.event.repository.default_branch }}"
else else
echo "This is a PR event" echo "This is a PR event"
clone_url=${{ github.event.pull_request.head.repo.clone_url }} clone_url=${{ github.event.pull_request.head.repo.clone_url }}
branch="${{ github.event.pull_request.head.ref }}" branch="${{ github.event.pull_request.head.ref }}"
commit=${{ github.event.pull_request.head.sha }}
default_branch="${{ github.event.pull_request.head.repo.default_branch }}" default_branch="${{ github.event.pull_request.head.repo.default_branch }}"
fi fi
echo "Branch: ${branch}" echo "Branch: ${branch}"
@ -580,7 +585,9 @@ jobs:
mkdir build mkdir build
cd build cd build
cmake \ cmake \
-DBUILD_VERSION="${build_version}" \
-DGITHUB_BRANCH="${branch}" \ -DGITHUB_BRANCH="${branch}" \
-DGITHUB_COMMIT="${commit}" \
-DGITHUB_CLONE_URL="${clone_url}" \ -DGITHUB_CLONE_URL="${clone_url}" \
-DGITHUB_DEFAULT_BRANCH="${default_branch}" \ -DGITHUB_DEFAULT_BRANCH="${default_branch}" \
-DSUNSHINE_CONFIGURE_HOMEBREW=ON \ -DSUNSHINE_CONFIGURE_HOMEBREW=ON \
@ -678,6 +685,8 @@ jobs:
if [ -z "$branch" ] if [ -z "$branch" ]
then then
echo "This is a PUSH event" echo "This is a PUSH event"
branch="${{ github.ref_name }}"
build_version=${{ needs.check_changelog.outputs.next_version }}
commit=${{ github.sha }} commit=${{ github.sha }}
clone_url=${{ github.event.repository.clone_url }} clone_url=${{ github.event.repository.clone_url }}
else else
@ -691,6 +700,8 @@ jobs:
mkdir build mkdir build
cd build cd build
cmake \ cmake \
-DBUILD_VERSION=${build_version} \
-DGITHUB_BRANCH=${branch} \
-DGITHUB_COMMIT=${commit} \ -DGITHUB_COMMIT=${commit} \
-DGITHUB_CLONE_URL=${clone_url} \ -DGITHUB_CLONE_URL=${clone_url} \
-DSUNSHINE_CONFIGURE_PORTFILE=ON \ -DSUNSHINE_CONFIGURE_PORTFILE=ON \
@ -1024,7 +1035,7 @@ jobs:
shell: msys2 {0} shell: msys2 {0}
env: env:
BRANCH: ${{ github.head_ref || github.ref_name }} BRANCH: ${{ github.head_ref || github.ref_name }}
BUILD_VERSION: ${{ needs.check_changelog.outputs.next_version_bare }} BUILD_VERSION: ${{ needs.check_changelog.outputs.next_version }}
COMMIT: ${{ github.event.pull_request.head.sha || github.sha }} COMMIT: ${{ github.event.pull_request.head.sha || github.sha }}
run: | run: |
mkdir build mkdir build

View file

@ -329,6 +329,9 @@ modules:
build-args: build-args:
- --share=network - --share=network
env: env:
BUILD_VERSION: "@BUILD_VERSION@"
BRANCH: "@GITHUB_BRANCH@"
COMMIT: "@GITHUB_COMMIT@"
npm_config_nodedir: /usr/lib/sdk/node18 npm_config_nodedir: /usr/lib/sdk/node18
NPM_CONFIG_LOGLEVEL: info NPM_CONFIG_LOGLEVEL: info
config-opts: config-opts:

View file

@ -51,6 +51,10 @@ configure.args -DBUILD_WERROR=ON \
-DCMAKE_INSTALL_PREFIX=${prefix} \ -DCMAKE_INSTALL_PREFIX=${prefix} \
-DSUNSHINE_ASSETS_DIR=etc/sunshine/assets -DSUNSHINE_ASSETS_DIR=etc/sunshine/assets
configure.env-append BRANCH=@GITHUB_BRANCH@
configure.env-append BUILD_VERSION=@BUILD_VERSION@
configure.env-append COMMIT=@GITHUB_COMMIT@
startupitem.create yes startupitem.create yes
startupitem.executable "${prefix}/bin/{$name}" startupitem.executable "${prefix}/bin/{$name}"
startupitem.location LaunchDaemons startupitem.location LaunchDaemons

View file

@ -19,6 +19,10 @@ class @PROJECT_NAME@ < Formula
depends_on "opus" depends_on "opus"
def install def install
ENV["BRANCH"] = "@GITHUB_BRANCH@"
ENV["BUILD_VERSION"] = "@BUILD_VERSION@"
ENV["COMMIT"] = "@GITHUB_COMMIT@"
args = %W[ args = %W[
-DBUILD_WERROR=ON -DBUILD_WERROR=ON
-DCMAKE_INSTALL_PREFIX=#{prefix} -DCMAKE_INSTALL_PREFIX=#{prefix}

View file

@ -112,10 +112,16 @@
stableBuildAvailable() { stableBuildAvailable() {
// If we can't get versions, return false // If we can't get versions, return false
if (!this.githubVersion || !this.version) return false; if (!this.githubVersion || !this.version) return false;
// Get the GitHub version tag // Get the GitHub version tag
let v = this.githubVersion.name; let v_github = this.githubVersion.name;
// If the version starts with a v, remove it // If the version starts with a v, remove it
if (v.indexOf("v") === 0) v = v.substring(1); if (v_github.indexOf("v") === 0) v_github = v_github.substring(1);
// Get the current version
let v_this = this.version;
// If the version starts with a v, remove it
if (v_this.indexOf("v") === 0) v_this = v_this.substring(1);
// if nightly or dirty, we do an additional check to make sure it's an actual upgrade. // if nightly or dirty, we do an additional check to make sure it's an actual upgrade.
if (this.buildVersionIsNightly || this.buildVersionIsDirty) { if (this.buildVersionIsNightly || this.buildVersionIsDirty) {
@ -124,7 +130,7 @@
} }
// return true if the version is different, otherwise false // return true if the version is different, otherwise false
return v !== this.version; return v_github !== v_this;
}, },
nightlyBuildAvailable() { nightlyBuildAvailable() {
// Verify nightly data is available and the build version is not stable // Verify nightly data is available and the build version is not stable