Repository navigation
Expand file tree
/
Copy pathbump-version.sh
More file actions
executable file
·68 lines (55 loc) · 1.62 KB
/
Copy pathbump-version.sh
File metadata and controls
executable file
·68 lines (55 loc) · 1.62 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
#!/usr/bin/env bash
# exit if command fails
set -e
if [ -z "$1" ]
then
echo 'Version parameter not given. Invoke as e.g. ./bump-version.sh 1.0.0'.
exit 1
fi
# function to read `y` (yes) or `n` (no).
function yes_or_no {
while true; do
read -p "$* [y/n]: " yn
case $yn in
[Yy]*) return 1 ;;
[Nn]*) echo "Aborted" ; return 0 ;;
esac
done
}
VERSION=$1
# A release version is X.Y.Z; the next development version is derived from it.
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ && $VERSION != testrelease-* ]]; then
echo "Version must be X.Y.Z or testrelease-*, got: $VERSION"
exit 1
fi
echo "Changing version to $VERSION"
echo 'Updating pom.xml...'
mvn versions:set -DnewVersion=$VERSION -DgenerateBackupPoms=false
echo 'Updating README.md...'
sed -i -e "s|<version>.*<\/version>|<version>$VERSION</version>|" README.md
if [ ! "$(yes_or_no 'Do you also want to add the version to CHANGELOG.md?')" ]
then
changefrog -n $VERSION
fi
if [[ $VERSION == testrelease-* ]] ; then
tagname=$VERSION
else
tagname="v$VERSION"
fi
if [ ! "$(yes_or_no Do you also want to commit the changes, create a git tag $tagname and push it?)" ]
then
git add CHANGELOG.md README.md pom.xml
git commit -m "Update version to $VERSION"
git push origin
git tag $tagname
git push origin $tagname
# Prepare for the next development cycle, so a local build is
# distinguishable from the release.
if [[ $VERSION != testrelease-* ]] ; then
NEXT="${VERSION%.*}.$((${VERSION##*.} + 1))-SNAPSHOT"
mvn versions:set -DnewVersion=$NEXT -DgenerateBackupPoms=false
git add pom.xml
git commit -m "Prepare for next development cycle"
git push origin
fi
fi