-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·58 lines (48 loc) · 1.51 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
#!/bin/bash
type=$1
if [[ $type != "major" ]] && [[ $type != "minor" ]] && [[ $type != "patch" ]]; then
echo "Type of release must be set(major, minor, patch). e.g. ./release.sh minor"
exit 1
fi
version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "version $version"
versionMajor=$(echo $version | cut -d. -f1)
versionMinor=$(echo $version | cut -d. -f2)
versionPatchAll=$(echo $version | cut -d. -f3)
versionPatch=$(echo $versionPatchAll | cut -d- -f1)
if [[ $type = "major" ]]; then
if [[ $versionMinor = 0 ]] && [[ $versionPatch = 0 ]]; then
newMajor=$versionMajor
else
newMajor=$((versionMajor+1))
fi
newMinor=0
newPatch=0
fi
if [[ $type = "minor" ]]; then
if [[ $versionPatch = 0 ]]; then
newMinor=$versionMinor
else
newMinor=$((versionMinor+1))
fi
newMajor=$versionMajor
newPatch=0
fi
if [[ $type = "patch" ]]; then
newMajor=$versionMajor
newMinor=$versionMinor
newPatch=$versionPatch
fi
newVersion="${newMajor}.${newMinor}.${newPatch}"
newSnapshot="${newMajor}.${newMinor}.$((newPatch+1))-SNAPSHOT"
echo "new version $newVersion"
echo "new snapshot version $newSnapshot"
mvn versions:set -DnewVersion=$newVersion versions:commit
git add pom.xml
git commit -m "move to release version $newVersion"
git tag -a "$newVersion" -m "version $newVersion"
mvn versions:set -DnewVersion=$newSnapshot versions:commit
git add pom.xml
git commit -m "move to snaphost $newSnapshot"
git push origin $newVersion
git push origin main