forked from atlasmap/atlasmap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·131 lines (109 loc) · 4.2 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
# Exit if any error occurs
set -e
BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Save global script args
ARGS="$@"
# Display a help message.
function displayHelp() {
echo "This script helps you to perform AtlasMap release."
echo "The available options are:"
echo " --docker-user Docker user for Docker Hub."
echo " --docker-password Docker password for Docker Hub."
echo " --release-version Version number to be used for release."
echo " --development-version Version number to be used for next development iteration."
echo " --help Displays this help message."
}
#
# Checks if a flag is present in the arguments.
function hasflag() {
filter=$1
for var in "${@:2}"; do
if [ "$var" = "$filter" ]; then
echo 'true'
break;
fi
done
}
#
# Read the value of an option.
function readopt() {
filter=$1
next=false
for var in "${@:2}"; do
if $next; then
echo $var
break;
fi
if [ "$var" = "$filter" ]; then
next=true
fi
done
}
# ======================================================
# Build functions
function init_options() {
HELP=$(hasflag --help $ARGS 2> /dev/null)
RELEASE_VERSION=$(readopt --release-version $ARGS 2> /dev/null)
DEVELOPMENT_VERSION=$(readopt --development-version $ARGS 2> /dev/null)
DOCKER_USER=$(readopt --docker-user $ARGS 2> /dev/null)
DOCKER_PASSWORD=$(readopt --docker-password $ARGS 2> /dev/null)
# Internal variable default values
OC_OPTS=""
MAVEN_PARAMETERS="--batch-mode -Dfabric8.mode=kubernetes -Pfabric8,release,community-release"
MAVEN_CMD="${MAVEN_CMD:-${BASEDIR}/mvnw}"
}
# ============================================================================
# Main loop
init_options
if [ -n "$HELP" ]; then
displayHelp
exit 0
fi
echo "=========================================================="
echo "Building artifacts ...."
echo "=========================================================="
"${MAVEN_CMD}" $MAVEN_PARAMETERS clean install
pushd docs
"${MAVEN_CMD}" $MAVEN_PARAMETERS -f pom-javadoc.xml javadoc:aggregate
popd
echo "=========================================================="
echo "Performing Maven Release ...."
echo "=========================================================="
"${MAVEN_CMD}" $MAVEN_PARAMETERS -Dtag=atlasmap-${RELEASE_VERSION} \
-DreleaseVersion=${RELEASE_VERSION} \
-DdevelopmentVersion=${DEVELOPMENT_VERSION} \
release:prepare
"${MAVEN_CMD}" $MAVEN_PARAMETERS -Dtag=atlasmap-${RELEASE_VERSION} \
-DreleaseVersion=${RELEASE_VERSION} \
-DdevelopmentVersion=${DEVELOPMENT_VERSION} \
release:perform
# Push the branch release changes and the tag.
git push origin HEAD
git push origin atlasmap-${RELEASE_VERSION}
# tag the major/minor version and docker push it
echo "=========================================================="
echo "Pushing docker images to Docker Hub...."
echo "=========================================================="
ATLASMAP_IMAGE="atlasmap/atlasmap"
MAJOR_MINOR_VERSION=$(echo $RELEASE_VERSION | cut -f1,2 -d'.')
if [ -n "$DOCKER_USER" ] && [ -n "$DOCKER_PASSWORD" ]; then
echo "==== Login to Docker Hub"
docker login -u "$DOCKER_USER" -p "$DOCKER_PASSWORD"
fi
docker tag "${ATLASMAP_IMAGE}:${RELEASE_VERSION}" "${ATLASMAP_IMAGE}:${MAJOR_MINOR_VERSION}"
docker push "${ATLASMAP_IMAGE}:${RELEASE_VERSION}"
docker push "${ATLASMAP_IMAGE}:${MAJOR_MINOR_VERSION}"
echo "=========================================================="
echo "Publishing NPM package of AtlasMap UI...."
echo "=========================================================="
pushd ui/dist/lib
npm version ${RELEASE_VERSION}
npm publish
popd
echo "=========================================================="
echo "Publishing Release Notes to GitHub...."
echo "=========================================================="
yarn add github-release-notes
./node_modules/.bin/gren release --tags atlasmap-${RELEASE_VERSION} --override
./node_modules/.bin/gren changelog --tags=all --generate --override