-
Notifications
You must be signed in to change notification settings - Fork 35
/
get_version
executable file
·45 lines (38 loc) · 1.15 KB
/
get_version
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
if [ ! -d .git ]; then
echo "not in an development environment, no .git directory found" >&2
exit 1
fi
# find an exact match, if found use it as version as we are currently
# exactly on one tag
# ex.: v0.42
version=`git describe --tag --exact-match 2>/dev/null`
if [ $? -eq 0 ]; then
echo $version | tr -d 'v'
exit 0
fi
# if we are not on a exact tag, use the current version and add the date
# ex.: v0.43.20101018
# "git describe --tag --abbrev=0 --always" does not work correctly with git versions < 1.7
# see issue #198
version=`grep OMD_VERSION Makefile.omd | head -n 1 | awk '{print $3}' |sed -e 's/-labs-edition//g'`
if [ $? -eq 0 ]; then
date=`date +%Y%m%d`
major=`echo $version | cut -d . -f 1`
minor=`echo $version | cut -d . -f 2`
# do we have a even minor version?
let mod=$minor%2
if [ $mod -eq 0 ]; then
minor=$(printf '%02d' $((minor+1)))
fi
version="$major.$minor"
# get current git branch
branch=$(git rev-parse --abbrev-ref HEAD)
if [[ ! $branch =~ labs|.*maint ]]; then
echo $version.$date-$branch | tr -d 'v'
exit 0
fi
echo $version.$date-labs-edition | tr -d 'v'
exit 0
fi
echo "unknown"