]> git.ipfire.org Git - thirdparty/pdns.git/blob - build-aux/gen-version
No longer filter DNSSEC metadata when DNSSEC is enabled in gsql
[thirdparty/pdns.git] / build-aux / gen-version
1 #!/bin/sh
2
3 if [ ! -z "$BUILDER_VERSION" ]; then
4 printf $BUILDER_VERSION
5 echo $BUILDER_VERSION > .version
6 exit 0
7 fi
8
9 VERSION="unknown"
10
11 DIRTY=""
12 git status | grep -q clean || DIRTY='.dirty'
13
14 # Special environment variable to signal that we are building a release, as this
15 # has consequences for the version number.
16 if [ "${IS_RELEASE}" = "YES" ]; then
17 TAG="$(git describe --tags --exact-match 2> /dev/null | cut -d- -f 2-)"
18 if [ -n "${TAG}" ]; then
19 # We're on a tag
20 echo "${TAG}${DIRTY}" > .version
21 printf "${TAG}${DIRTY}"
22 exit 0
23 fi
24 echo 'This is not a tag, either tag this commit or do not set $IS_RELEASE' >&2
25 exit 1
26 fi
27
28 #
29 # Generate the version number based on the branch
30 #
31 if [ ! -z "$(git rev-parse --abbrev-ref HEAD 2> /dev/null)" ]; then
32 if $(git rev-parse --abbrev-ref HEAD | grep -q 'rel/'); then
33 REL_TYPE="$(git rev-parse --abbrev-ref HEAD | cut -d/ -f 2 | cut -d- -f 1)"
34 VERSION="$(git describe --match=${REL_TYPE}-* --tags --dirty=.dirty | cut -d- -f 2-)"
35 else
36 GIT_VERSION=$(git show --no-patch --format=format:%h HEAD)
37 BRANCH=".$(git rev-parse --abbrev-ref HEAD | perl -p -e 's/[^[:alnum:]]//g;')"
38 [ "${BRANCH}" = ".master" ] && BRANCH=''
39 VERSION="0.0${BRANCH}.${PDNS_BUILD_NUMBER}g${GIT_VERSION}${DIRTY}"
40 fi
41 echo "$VERSION" > .version
42 elif [ -f .version ]; then
43 VERSION="$(cat .version)"
44 fi
45
46 printf $VERSION