提交 da433f79 编写于 作者: M minqiyang

Only get tag version when branch name matches release branch

上级 cebf7c60
...@@ -4,25 +4,42 @@ set(tmp_version "HEAD") ...@@ -4,25 +4,42 @@ set(tmp_version "HEAD")
set(TAG_VERSION_REGEX "[0-9]+\\.[0-9]+\\.[0-9]+(\\.(a|b|rc)\\.[0-9]+)?") set(TAG_VERSION_REGEX "[0-9]+\\.[0-9]+\\.[0-9]+(\\.(a|b|rc)\\.[0-9]+)?")
set(COMMIT_VERSION_REGEX "[0-9a-f]+[0-9a-f]+[0-9a-f]+[0-9a-f]+[0-9a-f]+") set(COMMIT_VERSION_REGEX "[0-9a-f]+[0-9a-f]+[0-9a-f]+[0-9a-f]+[0-9a-f]+")
while ("${PADDLE_VERSION}" STREQUAL "") while ("${PADDLE_VERSION}" STREQUAL "")
# Check current branch name
execute_process( execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0 --always ${tmp_version} COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref ${tmp_version}
WORKING_DIRECTORY ${PADDLE_SOURCE_DIR} WORKING_DIRECTORY ${PADDLE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_TAG_NAME OUTPUT_VARIABLE GIT_BRANCH_NAME
RESULT_VARIABLE GIT_RESULT RESULT_VARIABLE GIT_BRANCH_RESULT
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if (NOT ${GIT_RESULT}) if (NOT ${GIT_BRANCH_RESULT})
# Check the tag is a correct version execute_process(
if (${GIT_TAG_NAME} MATCHES "${COMMIT_VERSION_REGEX}") COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0 --always ${tmp_version}
# if no tag was found, set PADDLE_VERSION to latest WORKING_DIRECTORY ${PADDLE_SOURCE_DIR}
set(PADDLE_VERSION "latest") OUTPUT_VARIABLE GIT_TAG_NAME
elseif (${GIT_TAG_NAME} MATCHES "v${TAG_VERSION_REGEX}") RESULT_VARIABLE GIT_RESULT
string(REPLACE "v" "" PADDLE_VERSION ${GIT_TAG_NAME}) ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
else() # otherwise, get the previous git tag name. if (NOT ${GIT_RESULT})
set(tmp_version "${GIT_TAG_NAME}~1") # Check if current branch is release branch
if (${GIT_BRANCH_NAME} MATCHES "release/${TAG_VERSION_REGEX}")
# Check the tag is a correct version
if (${GIT_TAG_NAME} MATCHES "${COMMIT_VERSION_REGEX}")
# if no tag was found, set PADDLE_VERSION to latest
set(PADDLE_VERSION "latest")
elseif (${GIT_TAG_NAME} MATCHES "v${TAG_VERSION_REGEX}")
string(REPLACE "v" "" PADDLE_VERSION ${GIT_TAG_NAME})
else() # otherwise, get the previous git tag name.
set(tmp_version "${GIT_TAG_NAME}~1")
endif()
else() # otherwise, we always set PADDLE_VERSION to latest
set(PADDLE_VERSION "latest")
endif()
else()
set(PADDLE_VERSION "0.0.0")
message(WARNING "Cannot add paddle version from git tag")
endif() endif()
else() else()
set(PADDLE_VERSION "0.0.0") set(PADDLE_VERSION "0.0.0")
message(WARNING "Cannot add paddle version from git tag") message(WARNING "Cannot add paddle version for wrong git branch result")
endif() endif()
endwhile() endwhile()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册