forked from sgilda/maven-qstools-plugin
-
Notifications
You must be signed in to change notification settings - Fork 7
/
release-utils.sh
executable file
·110 lines (91 loc) · 2.62 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
#!/bin/sh
# Require BASH 3 or newer
REQUIRED_BASH_VERSION=3.0.0
if [[ $BASH_VERSION < $REQUIRED_BASH_VERSION ]]; then
echo "You must use Bash version 3 or newer to run this script"
exit
fi
# Canonicalise the source dir, allow this script to be called anywhere
DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
# DEFINE
SNAPSHOT_REPO_URL="https://repository.jboss.org/nexus/content/repositories/snapshots/"
SNAPSHOT_REPO_ID="jboss-snapshots-repository"
RELEASE_REPO_URL="https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/"
RELEASE_REPO_ID="jboss-releases-repository"
# SCRIPT
usage()
{
cat << EOF
usage: $0 options
This script aids in releasing the BOMs
OPTIONS:
-u Updates version numbers in all POMs, used with -o and -n
-o Old version number to update from
-n New version number to update to
-m Generate html versions of markdown readmes
-s Deploy a snapshot of the BOMs
-r Deploy a release of the BOMs
-h Shows this message
EOF
}
update()
{
cd $DIR
echo "Updating versions from $OLDVERSION TO $NEWVERSION for all Java, Markdown and XML files under $PWD"
perl -pi -e "s/${OLDVERSION}/${NEWVERSION}/g" `find . -name \*.xml -or -name \*.java -or -name \*.md`
}
snapshot()
{
mvn clean deploy -DaltDeploymentRepository=${SNAPSHOT_REPO_ID}::default::${SNAPSHOT_REPO_URL}
}
markdown_to_html()
{
cd $DIR
readmes=`find . -iname readme.md -or -iname contributing.md`
echo $readmes
for readme in $readmes
do
output_filename=${readme//.md/.html}
output_filename=${output_filename//.MD/.html}
markdown $readme -f $output_filename
done
}
release()
{
mvn clean source:jar package -e -DaltDeploymentRepository=${RELEASE_REPO_ID}::default::${RELEASE_REPO_URL} org.sonatype.plugins:nexus-staging-maven-plugin:deploy org.sonatype.plugins:nexus-staging-maven-plugin:release -DnexusUrl=https://repository.jboss.org/nexus -DserverId=jboss-releases-repository -Prelease -Dautomatic=true -DtargetRepositoryId=releases
}
OLDVERSION="1.0.0-SNAPSHOT"
NEWVERSION="1.0.0-SNAPSHOT"
CMD="usage"
while getopts “muo:n:rs” OPTION
do
case $OPTION in
u)
CMD="update"
;;
h)
usage
exit
;;
o)
OLDVERSION=$OPTARG
;;
n)
NEWVERSION=$OPTARG
;;
m)
CMD="markdown_to_html"
;;
s)
CMD="snapshot"
;;
r)
CMD="release"
;;
[?])
usage
exit
;;
esac
done
$CMD