-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathprepare-version.sh
More file actions
executable file
·48 lines (38 loc) · 1.14 KB
/
prepare-version.sh
File metadata and controls
executable file
·48 lines (38 loc) · 1.14 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
#!/bin/bash
# fail fast and safely:
# -e : exit immediately if a command fails
# -u : treat unset variables as errors
# -o pipefail : catch errors in pipelines (fail if any command fails, not just the last one)
set -euo pipefail
cd "$(dirname "$0")"
version=$1
if [ -z "$version" ]; then
echo "Provide target version!"
exit 1
fi
# update pom.xml with release version
sed -i "0,/<version>.*<\/version>/s//<version>$version<\/version>/" pom.xml
git add pom.xml
git commit -m "prepare release $version"
git tag "$version"
git push --tags
# increase version (bump patch by default)
IFS='.' read -r major minor patch <<< "$version"
if [[ -z "$patch" ]]; then
# If version has only major.minor, default patch=0
patch=0
fi
newVersion="$major.$minor.$((patch+1))"
# update pom.xml with new snapshot version
sed -i "0,/<version>.*<\/version>/s//<version>$newVersion-SNAPSHOT<\/version>/" pom.xml
git add pom.xml
git commit -m "restore pom after release"
git push origin development
# merge into master
git checkout master
git merge "$version"
git push origin master
mvn clean install
# switch back to development
git checkout development
mvn clean install