forked from opdt/keycloak-extension-bundid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·70 lines (56 loc) · 1.72 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
#!/bin/bash
set -e
bump_type=$1
if [[ -z $bump_type ]]; then
read -p "Enter the version bump type (major, minor, patch): " bump_type
if [[ "$bump_type" != "major" && "$bump_type" != "minor" && "$bump_type" != "patch" ]]; then
echo "Invalid bump type. Please enter 'major', 'minor', or 'patch'."
exit 1
fi
fi
if [[ -z $MAVEN_SETTINGS ]]; then
CONFIGURED_MVN="mvn"
else
CONFIGURED_MVN="mvn --settings $MAVEN_SETTINGS"
fi
# Remove -SNAPSHOT from the version if it is there
current_version=$($CONFIGURED_MVN help:evaluate -Dexpression=project.version -q -DforceStdout)
base_version=${current_version/-SNAPSHOT/}
# Split ba-version and keycloak-version
IFS='-' read -ra base_version_parts <<< "$base_version"
ba_version=${base_version_parts[0]}
keycloak_version=${base_version_parts[1]}
# Treat the version as SemVer and update major, minor, or patch (user choice)
IFS='.' read -ra version_parts <<< "$ba_version"
major=${version_parts[0]}
minor=${version_parts[1]}
patch=${version_parts[2]}
case $bump_type in
major)
major=$((major+1))
minor=0
patch=0
;;
minor)
minor=$((minor+1))
patch=0
;;
patch)
patch=$((patch))
;;
esac
new_version="$major.$minor.$patch-$keycloak_version"
$CONFIGURED_MVN versions:set -DnewVersion="$new_version"
# Commit the changes and create a git tag
git add .
git commit -m "chore(release): release version $new_version"
git tag "v$new_version"
git push
git push --tags
# Set the next SNAPSHOT version
next_snapshot_version="$major.$minor.$((patch+1))-$keycloak_version-SNAPSHOT"
$CONFIGURED_MVN versions:set -DnewVersion="$next_snapshot_version"
# Commit and push the changes
git add .
git commit -m "chore(mvn): set version to $next_snapshot_version"
git push