forked from gooddata/gooddata-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.sh
executable file
·75 lines (64 loc) · 1.49 KB
/
release.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
#!/bin/bash
usage(){
echo "Usage: $0 -v <desired version> -g <gpg password>"
echo "Or if you want to be asked fro GPG password without printing to console: $0 -v <desired version>"
exit 1
}
while getopts ":hv:g:" opt
do
case ${opt} in
v)
version=${OPTARG}
;;
g)
gpg_pass=${OPTARG}
;;
h)
usage
exit 0
;;
\?)
echo -e "Invalid option: -${OPTARG}"
exit 1
;;
:)
echo -e "Option -${OPTARG} require argument."
exit 2
;;
esac
done
shift $(( ${OPTIND} - 1 ))
if [ $# -ne 0 ]
then
echo "There are unexpected parameters!" 1>&2
usage
exit 1
fi
if [ -z "${version}" ]
then
echo "No version given!"
usage
exit 1
fi
if [ -z "${gpg_pass}" ]
then
echo "Enter gpg password: "
read -s gpg_pass
if [ -z "${gpg_pass}" ]
then
echo "No gpg password given!"
usage
exit 1
fi
fi
sed -i.bak "s/\(<version>\)[0-9]*\.[0-9]*\.[0-9]*\(<\/version>\)/\1${version}\2/" README.md && rm -f README.md.bak
git commit -a -m "bump version"
mvn --batch-mode release:prepare release:perform -DreleaseVersion=${version} -Darguments="-Dgpg.passphrase=${gpg_pass}"
mvnRetVal=$?
if [ $mvnRetVal -ne 0 ]; then
echo "Mvn build failed - please fix it and try to release again"
echo "Removing last commit '$(git log -1 --pretty="%h %s")'"
git reset --hard HEAD~1
exit $mvnRetVal
fi
git push origin --tags HEAD