forked from jbossas/archetypes
-
Notifications
You must be signed in to change notification settings - Fork 8
/
release-utils.sh
executable file
·174 lines (148 loc) · 4.23 KB
/
release-utils.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/bin/sh
set -o errexit
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
# DEFINE
ARCHETYPES="jboss-batch-archetype jboss-html5-mobile-archetype jboss-html5-mobile-blank-archetype jboss-javaee7-webapp-archetype jboss-javaee7-webapp-blank-archetype jboss-javaee7-webapp-ear-archetype jboss-javaee7-webapp-ear-blank-archetype jboss-spring-mvc-archetype"
SNAPSHOT_REPO_ID="jboss-snapshots-repository"
RELEASE_REPO_ID="jboss-releases-repository"
# SCRIPT
useenvrepo(){
if [[ -z "$RELEASE_REPO_URL" ]]; then
echo "You must set the RELEASE_REPO_URL environment variable to your local checkout of https://github.com/jboss-developer/temp-maven-repo"
exit
fi
}
usage()
{
HUMAN_READABLE_ARCHETYPES=""
i=0
for archetype in $ARCHETYPES
do
if [ $i -ne 0 ]
then
HUMAN_READABLE_ARCHETYPES="${HUMAN_READABLE_ARCHETYPES}, "
fi
echo ""
HUMAN_READABLE_ARCHETYPES="${HUMAN_READABLE_ARCHETYPES}${archetype}"
i=$[$i+1]
done
cat << EOF
usage: $0 options
This script aids with releases. Remember to generate new blank archetypes before release
OPTIONS:
-u Updates version numbers in all POMs, used with -o and -n
-c Clean Archetypes target Dir
-l Install all archetypes locally: $HUMAN_READABLE_ARCHETYPES.
-o Old version number to update from
-n New version number to update to
-s Deploy a snapshot of the archetypes
-r Deploy a release of the archetypes
-t Deploy a stage of the archetypes
-h Shows this message
EOF
}
clean()
{
for archetype in $ARCHETYPES
do
FILE=${archetype}/pom.xml
if [ -f $FILE ]; then
echo "\n**** Cleaning $archetype\n"
cmd="mvn clean -f ${archetype}/pom.xml"
fi
$cmd
done
}
update()
{
cd $DIR
echo "Updating versions from $OLDVERSION TO $NEWVERSION for all Java and XML files under $PWD"
perl -pi -e "s/${OLDVERSION}/${NEWVERSION}/g" `find . -name \*.xml -or -name \*.md -type f -maxdepth 3`
}
install()
{
for archetype in $ARCHETYPES
do
echo "\n**** Installing $archetype\n"
cmd="mvn clean install -f ${archetype}/pom.xml"
if [ -n $DEST ]; then
cmd="$cmd -Dmaven.repo.local=$DEST"
fi
$cmd
done
}
snapshot()
{
for archetype in $ARCHETYPES
do
echo "\n**** Deploying $archetype to ${SNAPSHOT_REPO_URL} \n"
mvn clean deploy -f ${archetype}/pom.xml -DaltDeploymentRepository=${SNAPSHOT_REPO_ID}::default::${SNAPSHOT_REPO_URL}
done
}
release()
{
if [[ -z "$USE_STAGE" ]]
then
useenvrepo
fi
for archetype in $ARCHETYPES
do
echo "\n**** Deploying $archetype to ${RELEASE_REPO_URL} \n"
mvn clean deploy -f ${archetype}/pom.xml -DaltDeploymentRepository=${RELEASE_REPO_ID}::default::${RELEASE_REPO_URL} -Prelease
done
}
stage()
{
rm -rf ./local-stage
for archetype in $ARCHETYPES
do
echo "\n**** Deploying $archetype to https://repository.jboss.org/nexus \n"
mvn -f ${archetype}/pom.xml deploy -DskipRemoteStaging=true -DaltDeploymentRepository="=local::default::file:./local-stage"
done
mvn -e org.sonatype.plugins:nexus-staging-maven-plugin:deploy-staged-repository -DrepositoryDirectory="./local-stage" -DstagingProfileId=2161b7b8da0080 -DnexusUrl=https://repository.jboss.org/nexus -DserverId=jboss-releases-repository -Prelease -Djava.net.preferIPv4Stack=true -Dhttp.connection.stalecheck=false -Dhttp.connection.timeout=0 -Dhttp.socket.timeout=0
}
OLDVERSION="1.0.0-SNAPSHOT"
NEWVERSION="1.0.0-SNAPSHOT"
CMD="usage"
DEST=""
while getopts “crl:uo:n:t” OPTION
do
case $OPTION in
u)
CMD="update"
;;
c)
CMD="clean"
;;
h)
usage
exit
;;
o)
OLDVERSION=$OPTARG
;;
n)
NEWVERSION=$OPTARG
;;
s)
CMD="snapshot"
;;
t)
CMD="stage"
;;
r)
CMD="release"
;;
l)
CMD="install"
eval DEST=$OPTARG
;;
[?])
usage
exit
;;
esac
done
$CMD