Skip to content

Commit ccfc1c3

Browse files
committed
Add release script
1 parent a748b54 commit ccfc1c3

File tree

2 files changed

+192
-0
lines changed

2 files changed

+192
-0
lines changed

release-utils.sh

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/bin/sh
2+
3+
set -o errexit
4+
5+
SOURCE="${BASH_SOURCE[0]}"
6+
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
7+
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
8+
9+
# DEFINE
10+
11+
SNAPSHOT_REPO_URL="https://repository.jboss.org/nexus/content/repositories/snapshots/"
12+
SNAPSHOT_REPO_ID="jboss-snapshots-repository"
13+
RELEASE_REPO_URL="https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/"
14+
RELEASE_REPO_ID="jboss-releases-repository"
15+
16+
# SCRIPT
17+
18+
usage()
19+
{
20+
21+
HUMAN_READABLE_ARCHETYPES=""
22+
i=0
23+
for archetype in $ARCHETYPES
24+
do
25+
if [ $i -ne 0 ]
26+
then
27+
HUMAN_READABLE_ARCHETYPES="${HUMAN_READABLE_ARCHETYPES}, "
28+
fi
29+
echo ""
30+
HUMAN_READABLE_ARCHETYPES="${HUMAN_READABLE_ARCHETYPES}${archetype}"
31+
i=$[$i+1]
32+
done
33+
34+
35+
cat << EOF
36+
usage: $0 options
37+
38+
This script aids with releases of the CDI API.
39+
40+
OPTIONS:
41+
-u Updates version numbers in all POMs, used with -o and -n
42+
-o Old version number to update from
43+
-n New version number to update to
44+
-s Deploy a snapshot of the CDI API
45+
-r Deploy a release of the CDI API
46+
-h Shows this message
47+
48+
EOF
49+
}
50+
51+
update()
52+
{
53+
cd $DIR
54+
echo "Updating versions from $OLDVERSION TO $NEWVERSION for all Java and XML files under $PWD"
55+
perl -pi -e "s/${OLDVERSION}/${NEWVERSION}/g" `find . -name \*.xml -or -name \*.java`
56+
}
57+
58+
snapshot()
59+
{
60+
echo "\n**** Deploying $archetype to ${SNAPSHOT_REPO_URL} \n"
61+
mvn clean javadoc:jar deploy -f api/pom.xml -DaltDeploymentRepository=${SNAPSHOT_REPO_ID}::default::${SNAPSHOT_REPO_URL}
62+
}
63+
64+
release()
65+
{
66+
echo "\n**** Deploying $archetype to ${RELEASE_REPO_URL} \n"
67+
mvn clean javadoc:jar deploy -f api/pom.xml -DaltDeploymentRepository=${RELEASE_REPO_ID}::default::${RELEASE_REPO_URL}
68+
}
69+
70+
OLDVERSION="1.0.0-SNAPSHOT"
71+
NEWVERSION="1.0.0-SNAPSHOT"
72+
CMD="usage"
73+
DEST=""
74+
75+
while getopts “sruo:n:” OPTION
76+
77+
do
78+
case $OPTION in
79+
u)
80+
CMD="update"
81+
;;
82+
h)
83+
usage
84+
exit
85+
;;
86+
o)
87+
OLDVERSION=$OPTARG
88+
;;
89+
n)
90+
NEWVERSION=$OPTARG
91+
;;
92+
s)
93+
CMD="snapshot"
94+
;;
95+
r)
96+
CMD="release"
97+
;;
98+
[?])
99+
usage
100+
exit
101+
;;
102+
esac
103+
done
104+
105+
$CMD
106+

release.sh

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/bin/sh
2+
3+
# Require BASH 3 or newer
4+
5+
REQUIRED_BASH_VERSION=3.0.0
6+
7+
if [[ $BASH_VERSION < $REQUIRED_BASH_VERSION ]]; then
8+
echo "You must use Bash version 3 or newer to run this script"
9+
exit
10+
fi
11+
12+
# Canonicalise the source dir, allow this script to be called anywhere
13+
DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
14+
15+
# DEFINE
16+
17+
# SCRIPT
18+
19+
usage()
20+
{
21+
cat << EOF
22+
usage: $0 options
23+
24+
This script performs a release of the CDI API
25+
26+
OPTIONS:
27+
-s Snapshot version number to update from
28+
-n New snapshot version number to update to, if undefined, defaults to the version number updated from
29+
-r Release version number
30+
EOF
31+
}
32+
33+
release()
34+
{
35+
echo "Releasing CDI API version $RELEASEVERSION"
36+
$DIR/release-utils.sh -u -o $SNAPSHOTVERSION -n $RELEASEVERSION
37+
git commit -a -m "Prepare for $RELEASEVERSION release"
38+
git tag -a $RELEASEVERSION -m "Tag $RELEASEVERSION"
39+
$DIR/release-utils.sh -r
40+
$DIR/release-utils.sh -u -o $RELEASEVERSION -n $NEWSNAPSHOTVERSION
41+
git commit -a -m "Prepare for development of $NEWSNAPSHOTVERSION"
42+
echo "***** CDI API released"
43+
}
44+
45+
SNAPSHOTVERSION="UNDEFINED"
46+
RELEASEVERSION="UNDEFINED"
47+
NEWSNAPSHOTVERSION="UNDEFINED"
48+
49+
while getopts “n:r:s:” OPTION
50+
51+
do
52+
case $OPTION in
53+
h)
54+
usage
55+
exit
56+
;;
57+
s)
58+
SNAPSHOTVERSION=$OPTARG
59+
;;
60+
r)
61+
RELEASEVERSION=$OPTARG
62+
;;
63+
n)
64+
NEWSNAPSHOTVERSION=$OPTARG
65+
;;
66+
[?])
67+
usage
68+
exit
69+
;;
70+
esac
71+
done
72+
73+
if [ "$NEWSNAPSHOTVERSION" == "UNDEFINED" ]
74+
then
75+
NEWSNAPSHOTVERSION=$SNAPSHOTVERSION
76+
fi
77+
78+
if [ "$SNAPSHOTVERSION" == "UNDEFINED" -o "$RELEASEVERSION" == "UNDEFINED" ]
79+
then
80+
echo "\nMust specify -r and -s\n"
81+
usage
82+
else
83+
release
84+
fi
85+
86+

0 commit comments

Comments
 (0)