Skip to content

Commit 3d473fb

Browse files
committed
add workaround to fetch the git-tags
- actions/checkout does not fetch tags when fetch-depth is set (see actions/checkout#2200) -> fetch the tags manually
1 parent ffcc5c5 commit 3d473fb

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

CMake/git.cmake

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
function(get_git_tag output_var)
22
#COMMAND git describe --abbrev=0 --tags
33
execute_process(
4-
COMMAND git tag --sort -creatordate
5-
COMMAND head -n 1
4+
COMMAND git fetch --depth=1 --tags origin +refs/heads/master:refs/remotes/origin/master
65
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
76
RESULT_VARIABLE _EXIT_CODE
87
OUTPUT_VARIABLE GIT_TAG
98
OUTPUT_STRIP_TRAILING_WHITESPACE)
109
if(_EXIT_CODE EQUAL 0)
11-
set(${output_var} ${GIT_TAG} PARENT_SCOPE)
10+
execute_process(
11+
COMMAND git tag --sort -creatordate
12+
COMMAND head -n 1
13+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
14+
RESULT_VARIABLE _EXIT_CODE
15+
OUTPUT_VARIABLE GIT_TAG
16+
OUTPUT_STRIP_TRAILING_WHITESPACE)
17+
if(_EXIT_CODE EQUAL 0)
18+
set(${output_var} ${GIT_TAG} PARENT_SCOPE)
19+
endif()
1220
endif()
1321
endfunction(get_git_tag)
1422

0 commit comments

Comments
 (0)