diff --git a/.github/workflows/build-linux-flatpak.yml b/.github/workflows/build-linux-flatpak.yml index 95902c1083c..02b960e714d 100644 --- a/.github/workflows/build-linux-flatpak.yml +++ b/.github/workflows/build-linux-flatpak.yml @@ -46,6 +46,12 @@ jobs: uses: actions/checkout@v6 with: fetch-depth: 0 + fetch-tags: true + + - name: Populate Git Info for Sandboxed Build + run: | + echo "GENERALS_GIT_OVERRIDE_TSTAMP=$(git log -1 --format=%ct 2>/dev/null || echo '0')" >> $GITHUB_ENV + echo "GENERALS_GIT_OVERRIDE_TAG=$(git describe --tags --exact-match 2>/dev/null || echo '')" >> $GITHUB_ENV - name: Install Build Dependencies run: | diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index e067de9edc1..7304d4a20ce 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -62,6 +62,7 @@ jobs: uses: actions/checkout@v6 with: fetch-depth: 0 + fetch-tags: true - name: Cache vcpkg id: cache-vcpkg diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index e85ebc6accb..38ca416a558 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -47,6 +47,7 @@ jobs: uses: actions/checkout@v6 with: fetch-depth: 0 + fetch-tags: true - name: Cache brew packages id: cache-brew diff --git a/Core/GameEngine/Source/Common/UpdateChecker.cpp b/Core/GameEngine/Source/Common/UpdateChecker.cpp index d3ec769d7cc..6a1be9953ea 100644 --- a/Core/GameEngine/Source/Common/UpdateChecker.cpp +++ b/Core/GameEngine/Source/Common/UpdateChecker.cpp @@ -209,20 +209,28 @@ static int SDLCALL threadFunc(void* /*userData*/) } else { - const bool hasCommitTimestamp = GitCommitTimeStamp > 0; - char publishedAt[64] = {0}; - if (hasCommitTimestamp && extractPublishedAt(responseBody, publishedAt, sizeof(publishedAt))) + // First check if the tag matches exactly. If it does, we are definitely on the latest version. + if (GitTag[0] != '\0' && strcmp(latestTag, GitTag) == 0) { - time_t remoteTime = parseISO8601(publishedAt); - // Signal update only when the remote release was published strictly - // AFTER the commit this binary was built from. - if (remoteTime != (time_t)-1 && remoteTime > GitCommitTimeStamp) - hasUpdate = true; + hasUpdate = false; } - else if (GitTag[0] != '\0') + else { - // No usable published_at comparison; fall back to tag string comparison. - hasUpdate = (strcmp(latestTag, GitTag) != 0); + const bool hasCommitTimestamp = GitCommitTimeStamp > 0; + char publishedAt[64] = {0}; + if (hasCommitTimestamp && extractPublishedAt(responseBody, publishedAt, sizeof(publishedAt))) + { + time_t remoteTime = parseISO8601(publishedAt); + // Signal update only when the remote release was published strictly + // AFTER the commit this binary was built from. + if (remoteTime != (time_t)-1 && remoteTime > GitCommitTimeStamp) + hasUpdate = true; + } + else if (GitTag[0] != '\0') + { + // No usable published_at comparison; fall back to tag string comparison. + hasUpdate = (strcmp(latestTag, GitTag) != 0); + } } } diff --git a/docs/WORKLOG/2026-07-DIARY.md b/docs/WORKLOG/2026-07-DIARY.md index 1a1a32de424..ffdc5d3aa57 100644 --- a/docs/WORKLOG/2026-07-DIARY.md +++ b/docs/WORKLOG/2026-07-DIARY.md @@ -38,3 +38,7 @@ Both issues have been resolved by adding proper counting filters in MiniAudio an - Preserved bone positioning logic in `SlavedUpdate.cpp` and fixed pointer dereferencing for `Coord3D` operations (`*obj->getPosition()`). - Accepted the upstream re-organization of GameClient UI code and removed deprecated ControlBar files. - Ensured deterministic math usage and successfully built the macOS target (`macos-vulkan`). +## 13/07/2026 +### Update Checker Fixes for GitHub Actions +- Fixed `UpdateChecker` not showing up in GitHub Actions deployments due to missing Git metadata in Flatpak builds and `actions/checkout` not fetching tags. +- Fixed a logic bug where a newly compiled release would immediately flag itself as outdated. diff --git a/resources/gitinfo/git_watcher.cmake b/resources/gitinfo/git_watcher.cmake index 40ae042b29f..08ef6b04a2f 100644 --- a/resources/gitinfo/git_watcher.cmake +++ b/resources/gitinfo/git_watcher.cmake @@ -125,6 +125,33 @@ function(GetGitState _working_dir) # RunGitCommand ever returns a non-zero exit code. set(ENV{GIT_RETRIEVED_STATE} "true") + # Allow passing override variables from CI or sandboxed environments via file + include("${_working_dir}/.git-override.cmake" OPTIONAL) + + if(DEFINED GENERALS_GIT_OVERRIDE_TSTAMP OR DEFINED GENERALS_GIT_OVERRIDE_TAG) + set(ENV{GIT_IS_DIRTY} "false") + if(DEFINED GENERALS_GIT_OVERRIDE_IS_DIRTY) + set(ENV{GIT_IS_DIRTY} "${GENERALS_GIT_OVERRIDE_IS_DIRTY}") + endif() + set(ENV{GIT_HEAD_SHA1} "0000000000000000000000000000000000000000") + set(ENV{GIT_AUTHOR_NAME} "GitHub Actions") + set(ENV{GIT_AUTHOR_EMAIL} "actions@github.com") + set(ENV{GIT_COMMIT_DATE_ISO8601} "") + set(ENV{GIT_COMMIT_SUBJECT} "Override") + set(ENV{GIT_COMMIT_BODY} "\"\"") + set(ENV{GIT_COMMIT_TSTAMP} "0") + if(DEFINED GENERALS_GIT_OVERRIDE_TSTAMP) + set(ENV{GIT_COMMIT_TSTAMP} "${GENERALS_GIT_OVERRIDE_TSTAMP}") + endif() + set(ENV{GIT_HEAD_SHORT_SHA1} "00000000") + set(ENV{GIT_REV_LIST_COUNT} "0") + set(ENV{GIT_TAG} "") + if(DEFINED GENERALS_GIT_OVERRIDE_TAG) + set(ENV{GIT_TAG} "${GENERALS_GIT_OVERRIDE_TAG}") + endif() + return() + endif() + if(GIT_EXECUTABLE) # Get whether or not the working tree is dirty. RunGitCommand(status --porcelain) diff --git a/scripts/build/linux/build-linux-flatpak.sh b/scripts/build/linux/build-linux-flatpak.sh index 1bc600997f6..82d4c7bbf32 100755 --- a/scripts/build/linux/build-linux-flatpak.sh +++ b/scripts/build/linux/build-linux-flatpak.sh @@ -94,6 +94,15 @@ BUILDER_ARGS=( --install-deps-from=flathub ) +if [[ -n "${GENERALS_GIT_OVERRIDE_TAG:-}" ]] || [[ -n "${GENERALS_GIT_OVERRIDE_TSTAMP:-}" ]]; then + cat > "${PROJECT_ROOT}/.git-override.cmake" <