-
Notifications
You must be signed in to change notification settings - Fork 16
/
release.sh
78 lines (62 loc) · 1.66 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
76
77
78
#!/usr/bin/env bash
showHelp() {
echo "Usage:"
echo "./release.sh <release number> <next release number>"
echo ""
}
assertCleanWorkspace() {
if [ `git status --short | grep -v '??' | wc -l` -ne 0 ]; then
echo "Workspace is not clean. Cannot prepare a release."
exit 1
fi
}
updateVersionNumber() {
version="$1"
echo "UPDATING VERSION NUMBER TO $version"
mvn org.codehaus.mojo:versions-maven-plugin:2.15.0:set -DnewVersion=$version -DgenerateBackupPoms=false || exit 1
git add -u || exit 1
}
tagReleaseAndPush() {
version="release-$1"
echo "TAGGING VERSION AS $version"
git tag "$version" || exit 1
git push --tags || exit 1
}
commitNoPush() {
message="$1"
echo "COMMITTING CHANGES $message"
git commit -m "$message" || exit 1
}
commitAndPush() {
message="$1"
echo "COMMITTING AND PUSHING CHANGES $message"
git commit -m "$message" || exit 1
git push || exit 1
}
checkoutAndDeploy() {
version="release-$1"
echo "CHECKING OUT $version"
git checkout "$version" || exit 1
echo "BUILDING AND DEPLOYING $version"
mvn clean deploy -DskipTests=true -Dmaven.deploy.skip=true || exit 1
}
checkoutMaster() {
echo "CHECKING OUT master"
git checkout master || exit 1
}
############################################################
if [ "$#" -ne 2 ]; then
showHelp
exit 1
fi
releaseNumber="$1"
nextReleaseNumber="$2"
assertCleanWorkspace
updateVersionNumber "$releaseNumber"
commitNoPush "Prepare release $releaseNumber"
tagReleaseAndPush "$releaseNumber"
updateVersionNumber "$nextReleaseNumber"
commitAndPush "Prepare for next development iteration $nextReleaseNumber"
checkoutAndDeploy "$releaseNumber"
checkoutMaster
echo "DONE"