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