-
Notifications
You must be signed in to change notification settings - Fork 58
/
release.sh
78 lines (68 loc) · 2.58 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
#!/usr/bin/env bash
#
# Copyright (c) 2014-2021 All Rights Reserved by the RWS Group for and on behalf of its affiliates and subsidiaries.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# See https://dzone.com/articles/how-to-publish-artifacts-to-maven-central for help on releasing from GitHub
#
###
### A bash script to simplify Maven releases.
###
# Make sure no pending change is on the working directory
modified_count=`git status --porcelain | wc -l`
if [[ "${modified_count}" -ne "0" ]]; then
echo "Your working directoy contains uncommitted changes."
exit 1
fi
# Make sure no pull can be made before release
LOCAL_ORIGIN=$(git rev-parse @)
REMOTE_ORIGIN=$(git rev-parse @{u})
if [[ "${LOCAL_ORIGIN}" != "${REMOTE_ORIGIN}" ]]; then
echo "Your local branch is not synchronized with its remote branch."
exit 1
fi
# How to use the script
function usage {
echo "Release using Apache Maven"
echo ""
echo "Usage:"
echo " release.sh REL_VERSION DEV_VERSION [GPG_KEYNAME] [GPG_PASS]"
echo ""
echo " REL_VERSION The version to use for the release"
echo " DEV_VERSION The version to use for the development"
echo " GPG_KEYNAME The GPG key name (optional)"
echo " GPG_PASS The GPG passphrase (optional)"
echo ""
}
if [[ $# -lt "2" ]]; then
usage
exit 1
fi
REL_VERSION="$1"
DEV_VERSION="$2"
REL_TAG="v${REL_VERSION}"
EXTRA_ARGS=""
if [[ $# -eq 4 ]]; then
GPG_KEYNAME="$3"
GPG_PASS="$4"
EXTRA_ARGS="-Dgpg.passphrase=${GPG_PASS} -Dgpg.keyname=${GPG_KEYNAME}"
fi
mvn clean
mvn --batch-mode --no-transfer-progress -Prelease release:prepare -DreleaseVersion="${REL_VERSION}" -DdevelopmentVersion="${DEV_VERSION}" -Dtag=${REL_TAG} -Darguments="${EXTRA_ARGS}"
mvn --batch-mode --no-transfer-progress -Prelease release:perform -DreleaseVersion="${REL_VERSION}" -DdevelopmentVersion="${DEV_VERSION}" -Dtag=${REL_TAG} -Darguments="${EXTRA_ARGS}"
mvn --batch-mode --no-transfer-progress -Prelease deploy ${EXTRA_ARGS}
echo "Released version: ${REL_VERSION}"
echo "Release tag: ${REL_TAG}"
echo "Development version: ${DEV_VERSION}"