forked from BrightcoveOS/Diamond
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.sh
executable file
·42 lines (39 loc) · 1001 Bytes
/
version.sh
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
#!/bin/bash
DESC=($(git describe --match 'v*' | sed "s/v\([0-9\.]*\)-*\([0-9]*\)-*\([0-9a-z]*\)/\1 \2 \3/"))
VERSION=($(echo ${DESC[0]} | tr "." " "))
COMMIT=${DESC[1]}
VERSION_MAJ=${VERSION[0]}
VERSION_MIN=${VERSION[1]}
VERSION_REV=${COMMIT}
if [ -z "${VERSION_REV}" ]; then
VERSION_REV="0"
fi
while getopts "mnr" opt; do
case $opt in
m)
# Major Version
echo "${VERSION_MAJ}"
exit 0
;;
n)
# Minor Version
echo "${VERSION_MIN}"
exit 0
;;
r)
# Revision Version
echo "${VERSION_REV}"
exit 0
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
VERSION="${VERSION_MAJ}.${VERSION_MIN}.${VERSION_REV}"
if [ -e src/diamond/version.py.tmpl ]
then
cat src/diamond/version.py.tmpl | sed "s/__VERSIONTOKENHERE__/${VERSION}/g" > src/diamond/version.py
fi
echo $VERSION