-
Notifications
You must be signed in to change notification settings - Fork 3
/
release.sh
executable file
·88 lines (68 loc) · 2.94 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
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
# (C) Copyright 2020 Netcentric - a Cognizant Digital Business. All rights reserved. This program
# and the accompanying materials are made available under the terms of the
# Eclipse Public License v1.0 which accompanies this distribution, and is available
# at http://www.eclipse.org/legal/epl-v10.html
# What does this script address:
# - Maven Release Plugin insists on creating a tag, and git-flow also wants to create a tag.
# - Secondly, the Maven Release Plugin updates the version number to the next SNAPSHOT release before you can
# merge the changes into master, so you end with the SNAPSHOT version number in master, and this is highly undesired.
#
# This script solves this by doing changes locally, only pushing at the end.
# All git commands are fully automated, without requiring any user input.
# See the required configuration options for the Maven Release Plugin to avoid unwanted pushs.
# Based on the excellent information found here: http://vincent.demeester.fr/2012/07/maven-release-gitflow/
# The version to be released
releaseVersion=""
# The next development version
developmentVersion=""
# Provide an optional comment prefix, e.g. for your bug tracking system
scmCommentPrefix='aem-security-checks release '
retrieveVersionNumbers() {
SHOULD_LOOP=true
while $SHOULD_LOOP; do
if [ -z $releaseVersion ]
then
read -p "Please enter the release version number: " releaseVersion
fi
if [ -z $developmentVersion ]
then
read -p "Please enter the development version number: " developmentVersion
fi
if [ -n $releaseVersion ] && [ -n $developmentVersion ]
then
SHOULD_LOOP=false
fi
done
}
executeRelease() {
# Start the release by creating a new release branch
git checkout -b release/$releaseVersion develop
# The Maven release
mvn --batch-mode release:prepare release:perform -DscmCommentPrefix="$scmCommentPrefix" -DreleaseVersion=$releaseVersion -DdevelopmentVersion=$developmentVersion -Prelease
# Clean up and finish
# get back to the develop branch
git checkout develop
# merge the version back into develop
git merge --no-ff -m "$scmCommentPrefix Merge release/$releaseVersion into develop" release/$releaseVersion
# go to the master branch
git checkout master
# merge the version back into master but use the tagged version instead of the release/$releaseVersion HEAD
git merge --no-ff -m "$scmCommentPrefix Merge previous version into master to avoid the increased version number" release/$releaseVersion~1
# Removing the release branch
git branch -D release/$releaseVersion
# Get back on the develop branch
git checkout develop
# Finally push everything
git push --all && git push --tags
}
retrieveVersionNumbers
echo "Starting release process with RELEASE VERSION: $releaseVersion and DEPLOYMENT_VERSION $developmentVersion"
read -p "Do you want to progress with the release [Y/n]: " agreed
if [ $agreed == 'Y' ]
then
echo "Starting the release"
executeRelease
else
echo "Release process cancelled"
fi