-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ci): fallback to local values for BUILD_REF when not built in CI
- Loading branch information
Showing
3 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
include_guard(GLOBAL) | ||
nodable_log_title_header() | ||
|
||
# Get the git short hash | ||
execute_process( | ||
COMMAND git log -1 --format=%h | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} | ||
OUTPUT_VARIABLE GIT_SHORT_HASH | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
# Get the git hash | ||
execute_process( | ||
COMMAND git log -1 --format=%H | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} | ||
OUTPUT_VARIABLE GIT_HASH | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
# Get the git last tag hash | ||
execute_process( | ||
COMMAND git rev-list --tags --max-count=1 | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} | ||
OUTPUT_VARIABLE GIT_LAST_TAG_HASH | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
# Get the git last tag | ||
execute_process( | ||
COMMAND git describe --tags ${GIT_LAST_TAG_HASH} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} | ||
OUTPUT_VARIABLE GIT_LAST_TAG | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
# define the version number | ||
if(GITHUB_REF_NAME) | ||
set(BUILD_REF "${GITHUB_REF_NAME} ${GITHUB_SHA}") | ||
elseif(GIT_LAST_TAG_HASH EQUAL GIT_HASH) | ||
set(BUILD_REF "${GIT_LAST_TAG} ${GIT_HASH} (local build)") | ||
else() | ||
set(BUILD_REF "v${PROJECT_VERSION}.x (local build)") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters