forked from rundeck/rundeck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setversion.sh
executable file
·51 lines (38 loc) · 1.43 KB
/
setversion.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
47
48
49
50
#!/bin/bash
CUR_VERSION="$(grep version.number= "$PWD/version.properties" | cut -d= -f 2)"
CUR_RELEASE="$(grep version.release.number= "$PWD/version.properties" | cut -d= -f 2)"
CUR_TAG="$(grep version.tag= "$PWD/version.properties" | cut -d= -f 2)"
echo "current NUMBER: $CUR_VERSION"
echo "current RELEASE: $CUR_RELEASE"
echo "current TAG: $CUR_TAG"
if [ -z "$1" ] ; then
echo "usage: setversion.sh <version> [release] [GA]"
exit 2
fi
VNUM="$1"
shift
if [ -z "$1" ]; then
RELEASE="$CUR_RELEASE"
else
RELEASE="$1"
fi
shift
VTAG="${1:-GA}"
VDATE="$(date +%Y%m%d)"
if [ "$VTAG" == "GA" ] ; then
VNAME="$VNUM-$VDATE"
else
VNAME="$VNUM-$VTAG-$VDATE"
fi
echo "new NUMBER: $VNUM"
echo "new RELEASE: $RELEASE"
echo "new DATE: $VDATE"
echo "new VERSION: $VNAME"
#alter version.properties
perl -i'.orig' -p -e "s#^version\\.number\\s*=.*\$#version.number=$VNUM#" "$PWD/version.properties"
perl -i'.orig' -p -e "s#^version\\.release\\.number\\s*=.*\$#version.release.number=$RELEASE#" "$PWD/version.properties"
perl -i'.orig' -p -e "s#^version\\.tag\\s*=.*\$#version.tag=$VTAG#" "$PWD/version.properties"
perl -i'.orig' -p -e "s#^version\\.date\\s*=.*\$#version.date=$VDATE#" "$PWD/version.properties"
perl -i'.orig' -p -e "s#^version\\.version\\s*=.*\$#version.version=$VNAME#" "$PWD/version.properties"
perl -i'.orig' -p -e "s#^currentVersion\\s*=.*\$#currentVersion = $VNUM#" "$PWD"/gradle.properties
echo MODIFIED: "$(pwd)"/version.properties