diff options
-rw-r--r-- | ci/update_version.sh | 31 | ||||
-rw-r--r-- | circle.yml | 2 | ||||
-rw-r--r-- | cmake/version.cmake | 22 |
3 files changed, 49 insertions, 6 deletions
diff --git a/ci/update_version.sh b/ci/update_version.sh new file mode 100644 index 000000000..dff4a906d --- /dev/null +++ b/ci/update_version.sh @@ -0,0 +1,31 @@ +if [ -z "$CIRCLE_BUILD_NUM" -o "$CIRCLE_PROJECT_USERNAME" != "navit-gps" ] ; then + exit +fi + +if ! git log -n 1 ; then + echo "This script should be run from the versioned directory" + exit 1 +fi + +if [ "$CIRCLE_BRANCH" != "trunk" ] ; then + exit +fi + +TAG=R$(( 5658 + $CIRCLE_BUILD_NUM )) + +git log -1 --format="%H %d" | grep 'tag: R' + +if [ $? -eq 0 ] ; then + echo "This commit is already tagged." + exit +fi + +if [ "$1" == "prepare" ] ; then + git tag $TAG + exit +fi + +if [ "$1" == "push" ] ; then + git push origin $TAG +fi + diff --git a/circle.yml b/circle.yml index 0f557e94b..6e10b8c12 100644 --- a/circle.yml +++ b/circle.yml @@ -24,6 +24,7 @@ dependencies: - sudo apt-get install libfreetype6-dev - sudo apt-get install libdbus-glib-1-dev - sudo apt-get install g++ + - bash ci/update_version.sh prepare - bash ci/import_translations.sh - bash ci/build_linux.sh - sed -i '/INTEGER/d' bin/po/navit.pot @@ -72,6 +73,7 @@ deployment: merge_into_master: branch: trunk commands: + - bash ci/update_version.sh push - git push origin $CIRCLE_SHA1:refs/heads/master merge_translations: branch: /i18n.*/ diff --git a/cmake/version.cmake b/cmake/version.cmake index 77c79d12a..ee419bbc4 100644 --- a/cmake/version.cmake +++ b/cmake/version.cmake @@ -4,21 +4,31 @@ get_filename_component(SOURCE_DIR ${SRC} PATH) if (GIT_EXECUTABLE) EXECUTE_PROCESS( - COMMAND ${GIT_EXECUTABLE} log -n 1 --format=%h + COMMAND ${GIT_EXECUTABLE} log "--format=%h %d" WORKING_DIRECTORY "${SOURCE_DIR}" OUTPUT_VARIABLE VERSION OUTPUT_STRIP_TRAILING_WHITESPACE ) else() message(STATUS "git not found, cannot record git commit") + set(VERSION "0000") endif(GIT_EXECUTABLE) -set(NAVIT_VARIANT "-") -if (DEFINED VERSION) - set(${NAME} ${VERSION}) -else() - set(${NAME} "---") +string(REGEX MATCH "R[0-9]+" VERSION_NUM ${VERSION} ) +string(REPLACE "R" "" VERSION_NUM ${VERSION_NUM} ) +if(NOT VERSION_NUM) + set(VERSION_NUM "0000") +endif() + +string(REGEX MATCH "^[a-z0-9]+" VERSION ${VERSION} ) + +if (STRIP_M) + set(VERSION ${VERSION_NUM}) endif() +set(NAVIT_VARIANT "-") + +set(${NAME} ${VERSION}) + message (STATUS "Git commit: ${${NAME}}") CONFIGURE_FILE(${SRC} ${DST} @ONLY) |