-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
mvn_release.sh
executable file
·75 lines (68 loc) · 2.51 KB
/
mvn_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
releaseVersion=""
skipTests="false"
usage="${PROGNAME} [-h] [-st] [-v] -- Release script for Occurrent
where:
-h, --help
Show this help text
-v, --version
The version to release (required)
-st, --skip-tests
Skip tests when releasing, default false"
if [ "$#" -ne 0 ]; then
while [ "$#" -gt 0 ]
do
case "$1" in
-h|--help)
echo "$usage"
exit 0
;;
-v|--version)
releaseVersion="$2"
;;
-st|--skip-tests)
skipTests="true"
;;
--)
break
;;
-*)
echo "Invalid option '$1'. Use --help to see the valid options" >&2
exit 1
;;
# an option mvn_cmd, continue
*) ;;
esac
shift
done
fi
if [ -z "${releaseVersion}" ]; then
echo "$usage"
exit 1
fi
echo "!!!!!DON'T FORGET TO SWITCH TO JAVA 17!!!!!"
echo You may also need to disable "Stay invisible at the local network" in NordVPN, see nordvpn.md.
echo "Preparing release of Occurrent ${releaseVersion} (skip tests=$skipTests)"
read -r -e -s -p "Enter sonatype password: " sonatypePassword
echo
echo
echo "Starting to release Occurrent $releaseVersion (skip tests=$skipTests)"
mavenArguments="-Dgpg.passphrase=${sonatypePassword} -DskipTests=${skipTests}"
versionBeforeRelease=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) && \
mvn release:prepare -Prelease -DautoVersionSubmodules=true -Dtag="occurrent-${releaseVersion}" -DreleaseVersion="${releaseVersion}" -Darguments="${mavenArguments}" && \
mvn release:perform -Prelease -Darguments="${mavenArguments}"
mavenReleaseStatus=$?
if [ $mavenReleaseStatus -eq 0 ]; then
echo "Release successful, will update version number for modules that were not included in release build." && \
git pull --rebase # Note that we don't use && here because we may already be up-to-date, and if so, pull returns an "error".
versionAfterRelease=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) && \
# We normalize versionAfterRelease by escaping dots with \. This is required for sed to work in find.
normalizedVersionBeforeRelease=$(echo "${versionBeforeRelease}" | sed 's/\./\\./g') && \
find . -name "pom.xml" -type f -exec sed -i "" "s/${normalizedVersionBeforeRelease}/${versionAfterRelease}/g" {} + && \
git commit -am "Updated version number for modules that were not included in release build to ${versionAfterRelease}" && \
git push && \
echo "Maven release of Occurrent $releaseVersion completed successfully"
else
echo "Maven release of Occurrent $releaseVersion failed"
exit $mavenReleaseStatus
fi