forked from rundeck/rundeck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setversion.sh
executable file
·79 lines (59 loc) · 2.3 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/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 VERSION: $CUR_VERSION"
echo "current RELEASE: $CUR_RELEASE"
echo "current TAG: $CUR_TAG"
if [ -z "$1" ] ; then
echo "usage: setversion.sh <version> [release] [tag]"
exit 2
fi
VERSION=$1
shift
if [ -z "$1" ]; then
RELEASE=$CUR_RELEASE
else
RELEASE=$1
fi
shift
if [ -z "$1" ]; then
TAG=$CUR_TAG
else
TAG=$1
fi
IDENT_TAG="-$TAG"
if [ "$TAG" = "GA" ] ; then
IDENT_TAG=
fi
echo "new VERSION: $VERSION"
echo "new RELEASE: $RELEASE"
echo "new TAG: $TAG"
#alter version.properties
perl -i'.orig' -p -e "s#^version\.number\s*=.*\$#version.number=$VERSION#" `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=$TAG#" `pwd`/version.properties
echo MODIFIED: `pwd`/version.properties
#alter pom.xml version
XML=$(which xmlstarlet)
if [ -z "$XML" ] ; then
XML=$(which xml)
fi
$XML ed -P -S -N p=http://maven.apache.org/POM/4.0.0 -u "/p:project/p:version" -v "$VERSION" pom.xml > pom_new.xml
mv pom_new.xml pom.xml
echo MODIFIED: `pwd`/pom.xml
#alter grails i18n messages main.app.version.num=1.0.0
perl -i'.orig' -p -e "s#^app\.version\s*=.*\$#app.version=$VERSION#" `pwd`/rundeckapp/application.properties
perl -i'.orig' -p -e "s#^build\.ident\s*=.*\$#build.ident=$VERSION-$RELEASE$IDENT_TAG#" `pwd`/rundeckapp/application.properties
echo MODIFIED: `pwd`/rundeckapp/application.properties
$XML ed -P -S -N p=http://maven.apache.org/POM/4.0.0 -u "/p:project/p:version" -v "$VERSION" rundeckapp/pom.xml > rundeckapp/pom_new.xml
mv rundeckapp/pom_new.xml rundeckapp/pom.xml
echo MODIFIED: `pwd`/rundeckapp/pom.xml
#modify core/build.gradle
perl -i'.orig' -p -e "s#^version\s*=.*\$#version = '$VERSION'#" `pwd`/core/build.gradle
cd core/ && ./gradlew createPom && cd ..
echo MODIFIED: `pwd`/core/build.gradle
#modify plugins/build.gradle
perl -i'.orig' -p -e "s#^(\s*)version\s*=.*\$#\1version = '$VERSION'#" `pwd`/plugins/build.gradle
cd plugins/ && ./gradlew createPom && cd ..
echo MODIFIED: `pwd`/plugins/build.gradle