]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Set version numbers correctly on releases 3041/head
authorPieter Lexis <pieter.lexis@powerdns.com>
Tue, 15 Dec 2015 15:21:33 +0000 (16:21 +0100)
committerPieter Lexis <pieter.lexis@powerdns.com>
Tue, 15 Dec 2015 15:21:33 +0000 (16:21 +0100)
build-aux/gen-version

index d761c566ab592c97252e5a0215654eeb1174de9c..cec0e70049d17d483c2e2bb57ce27dfefd57e229 100755 (executable)
@@ -1,6 +1,25 @@
 #!/bin/sh
 VERSION="unknown"
 
+DIRTY=""
+git status | grep -q clean || DIRTY='.dirty'
+
+# Special environment variable to signal that we are building a release, as this
+# has condequenses for the version number.
+if [ "${IS_RELEASE}" = "YES" ]; then
+  TAG="$(git describe --tags --exact-match 2> /dev/null | cut -d- -f 2-)"
+  if [ -n "${TAG}" ]; then
+    # We're on a tag
+    echo "${TAG}${DIRTY}"
+    exit 0
+  fi
+  echo 'This is not a tag, either tag this commit or do not set $IS_RELEASE' >&2
+  exit 1
+fi
+
+#
+# Generate the version number based on the branch
+#
 if [ ! -z "$(git rev-parse --abbrev-ref HEAD 2> /dev/null)" ]; then
   if $(git rev-parse --abbrev-ref HEAD | grep -q 'rel/'); then
     REL_TYPE="$(git rev-parse --abbrev-ref HEAD | cut -d/ -f 2 | cut -d- -f 1)"
@@ -9,7 +28,6 @@ if [ ! -z "$(git rev-parse --abbrev-ref HEAD 2> /dev/null)" ]; then
     GIT_VERSION=$(git show --no-patch --format=format:%h HEAD)
     BRANCH=".$(git rev-parse --abbrev-ref HEAD | perl -p -e 's/-//g;')"
     [ "${BRANCH}" = ".master" ] && BRANCH=''
-    git status | grep -q clean || DIRTY='.dirty'
     VERSION="0.0${BRANCH}.${PDNS_BUILD_NUMBER}g${GIT_VERSION}${DIRTY}"
   fi
   echo "$VERSION" > .version