-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetVersion.sh
More file actions
executable file
·107 lines (84 loc) · 2.04 KB
/
setVersion.sh
File metadata and controls
executable file
·107 lines (84 loc) · 2.04 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
set_version()
{
ov=`mvn help:evaluate -Dexpression=project.version -f $1 -q -DforceStdout`
replace_version $1 $2 $ov
}
replace_version()
{
backup="$1.versionsBackup"
cp $1 $backup
sed "s/$3/$2/g" $backup > $1
}
commit_verion()
{
backupPom="$1.versionsBackup"
rm $backupPom
}
revert_verion()
{
backupPom="$1.versionsBackup"
mv $backupPom $1
}
update_child_app()
{
cd $1
./setVersion.sh $2
cd ..
}
VALIDATED=0
if [ $# -lt 1 ] ;then
echo "you need input a parameter as the new version you want to set"
else
NEW_VERSION=${1}
echo "Please confirm to update version to $NEW_VERSION"
read -r -p "Are You Sure? [Y/n] " input
case $input in
[yY][eE][sS]|[yY])
echo "Yes"
VALIDATED=1
;;
[nN][oO]|[nN])
echo "No"
;;
*)
echo "Invalid input..."
;;
esac
fi
if [ $VALIDATED -eq 0 ] ;then
echo "version not updated"
exit 1;
fi
BACKUP=true
OLD_VERSION=`mvn help:evaluate -Dexpression=project.version -q -DforceStdout`
VERSION_FILE=src/main/resources/tascreed.yaml
echo "start to update version from $OLD_VERSION to $NEW_VERSION"
mvn versions:set -DnewVersion=$NEW_VERSION -DgenerateBackupPoms=$BACKUP
replace_version tascreed-core/tascreed-infra/$VERSION_FILE $NEW_VERSION $OLD_VERSION
CONFIRMED=0
echo "Version updated to $NEW_VERSION, please double check and confirm with it."
read -r -p "Are you sure? [Y/n] " input
case $input in
[yY][eE][sS]|[yY])
echo "Yes"
CONFIRMED=1
;;
[nN][oO]|[nN])
echo "No"
;;
*)
echo "Invalid input..."
;;
esac
if [ $CONFIRMED -eq 1 ] ;then
echo "Confirmed to update to $NEW_VERSION, will remove all the backup files ..."
mvn versions:commit
commit_verion tascreed-core/tascreed-infra/$VERSION_FILE
echo "version update finished."
else
echo "Will revert back to $OLD_VERSION ..."
mvn versions:revert
revert_verion tascreed-core/tascreed-infra/$VERSION_FILE
echo "version update reverted."
fi