-
Notifications
You must be signed in to change notification settings - Fork 1
/
setVersionNumber.sh
executable file
·46 lines (35 loc) · 1.23 KB
/
setVersionNumber.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
43
44
45
46
#!/bin/bash
usage()
{
echo "Usage: $0 new_version"
exit 1
}
error()
{
echo "File VERSION is missing. Abort."
exit 1
}
[[ $# == 1 ]] || usage
version=$1
[[ -f VERSION ]] || error
oldversion=`cat VERSION`
echo "Changing version from $oldversion to $version"
sed -i "s/__version__ = '$oldversion'/__version__ = '$version'/g" python/src/__init__.py
sed -i "s/Version: $oldversion/Version: $version/g" distro/rpm/*.spec
sed -i "s/ ($oldversion-/ ($version-/g" distro/debian/changelog
oldmajor=`echo $oldversion | cut -d "." -f 1`
oldminor=`echo $oldversion | cut -d "." -f 2`
oldpatch=`echo $oldversion | cut -d "." -f 3`
major=`echo $version | cut -d "." -f 1`
minor=`echo $version | cut -d "." -f 2`
patch=`echo $version | cut -d "." -f 3`
sed -i "s/CPACK_PACKAGE_VERSION_MAJOR $oldmajor/CPACK_PACKAGE_VERSION_MAJOR $major/g" CMakeLists.txt
sed -i "s/CPACK_PACKAGE_VERSION_MINOR $oldminor/CPACK_PACKAGE_VERSION_MINOR $minor/g" CMakeLists.txt
number_of_dots=`grep -o '\.' <<< $version | wc -l`
if test $number_of_dots -ge 2
then
sed -i "s/set ( CPACK_PACKAGE_VERSION_PATCH $oldpatch/set ( CPACK_PACKAGE_VERSION_PATCH $patch/g" CMakeLists.txt
fi
echo $version > VERSION
echo "Updated file VERSION with new version $version"
exit 0