-
Notifications
You must be signed in to change notification settings - Fork 14
/
bumpVersion.sh
55 lines (49 loc) · 1.54 KB
/
bumpVersion.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
#!/bin/bash
## resolve folder of this script, following all symlinks,
## http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
SCRIPT_SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SCRIPT_SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
SCRIPT_DIR="$( cd -P "$( dirname "$SCRIPT_SOURCE" )" && pwd )"
SCRIPT_SOURCE="$(readlink "$SCRIPT_SOURCE")"
# if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
[[ $SCRIPT_SOURCE != /* ]] && SCRIPT_SOURCE="$SCRIPT_DIR/$SCRIPT_SOURCE"
done
readonly SCRIPT_DIR="$( cd -P "$( dirname "$SCRIPT_SOURCE" )" && pwd )"
set -e
current=`head ${SCRIPT_DIR}/pom.xml -n 20 | grep "<version>" | sed "s;./\?version.;;g" | sed "s/\s\+//g"`
echo "current version: $current"
echo -n "type future one: "
read future
echo $current "->" $future
echo "ok? y/n"
read yn
if [ ! $yn == y ] ; then
echo aborted
exit 0
fi
poms=`find ${SCRIPT_DIR}| grep "/pom.xml"`
for pom in $poms ; do
echo " * $pom * "
cat $pom | grep --color "<version>$current</version>" -A 1 -B 3
done
echo "ok? y/n"
read yn
if [ ! $yn == y ] ; then
echo aborted
exit 0
fi
poms=`find ${SCRIPT_DIR}| grep "/pom.xml"`
for pom in $poms ; do
echo " * $pom * "
sed -i "s;<version>$current</version>;<version>$future</version>;g" ${pom}
cat $pom | grep --color "<version>$future</version>" -A 1 -B 3
done
echo "ok? y/n"
read yn
if [ ! $yn == y ] ; then
echo "run 'git reset --hard' in ${SCRIPT_DIR}"
exit 0
fi
pushd ${SCRIPT_DIR}
git diff
popd