From: Joel Rosdahl Date: Fri, 8 Aug 2025 18:33:41 +0000 (+0200) Subject: build: Detect ccache version from GitHub Actions environment X-Git-Tag: v4.12~35 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aa1e617051a647e51da767b0b9d8b0e6abbaad53;p=thirdparty%2Fccache.git build: Detect ccache version from GitHub Actions environment --- diff --git a/cmake/CcacheVersion.cmake b/cmake/CcacheVersion.cmake index 34e7c965..f9541e42 100644 --- a/cmake/CcacheVersion.cmake +++ b/cmake/CcacheVersion.cmake @@ -15,12 +15,10 @@ # 2. Building from a source code archive not generated by "git archive" (i.e., # version_info has not been substituted). In this case we fail the # configuration. -# 3. Building from a Git repository. In this case the version will be a proper +# 3. Building from a GitHub Actions job. +# 4. Building from a Git repository. In this case the version will be a proper # version if building a tagged commit, otherwise "branch.hash(+dirty)". In # case Git is not available, the version will be "unknown". -# -# CCACHE_VERSION_ORIGIN is set to "archive" in scenario 1 and "git" in scenario -# 3. set(version_info "$Format:%H %D$") set(CCACHE_VERSION "unknown") @@ -38,8 +36,17 @@ if(version_info MATCHES "^([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a # Untagged commit. set(CCACHE_VERSION "${hash}") endif() -elseif(EXISTS "${CMAKE_SOURCE_DIR}/.git") +elseif(DEFINED ENV{GITHUB_REF}) # Scenario 3. + set(CCACHE_VERSION_ORIGIN github) + if("$ENV{GITHUB_REF}" MATCHES "^refs/tags/v(.+)$") + set(CCACHE_VERSION "${CMAKE_MATCH_1}") + else() + string(SUBSTRING "$ENV{GITHUB_SHA}" 0 8 hash) + set(CCACHE_VERSION "$ENV{GITHUB_REF_NAME}.${hash}") + endif() +elseif(EXISTS "${CMAKE_SOURCE_DIR}/.git") + # Scenario 4. set(CCACHE_VERSION_ORIGIN git) find_package(Git QUIET)