-
Notifications
You must be signed in to change notification settings - Fork 6
/
release.sh
executable file
·108 lines (83 loc) · 2.43 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
#!/bin/ksh
echo "Starting to sign and deploy..."
which mvn
function fn_promptForContinue {
read CONTINUE?"Continue (y/n)?"
if [ "" == "${CONTINUE}" -o "y" == "${CONTINUE}" -o "Y" == "${CONTINUE}" ] ; then
echo "continuing.."
else
exit 1
fi
}
function fn_exitOnError {
if [ $? -ne 0 ] ; then
echo "Failed to $1"
exit 1
fi
}
read VERSION?"What version are we releasing?"
echo ${VERSION}
fn_promptForContinue
if [ -z "`git status | grep release-chorus-${VERSION}`" ] ; then
echo "You should already have created a tag chorus-${VERSION}"
echo "Going to checkout tag chorus-${VERSION} to a new branch and switch to the tagged branch, continue?"
fn_promptForContinue
git checkout -B release-chorus-${VERSION} chorus-${VERSION}
fn_exitOnError "Failed to checkout branch from tag chorus-${VERSION}"
fi
echo "Cleaning"
mvn clean
fn_exitOnError "Failed to clean"
echo "Building packages"
mvn install
fn_exitOnError "Failed to install"
echo "Building javadoc"
mvn javadoc:jar
fn_exitOnError "Failed to create javadoc jars"
echo "Generating release script.."
function fn_genReleaseScript {
echo "Generating release script for $1"
COMMAND="mvn gpg:sign-and-deploy-file \
-Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ \
-DrepositoryId=sonatype-nexus-staging -DpomFile=${1}/pom.xml \
-Dfile=${1}/target/${1}-${VERSION}.jar \
-Dfiles=${1}/target/${1}-${VERSION}-sources.jar,${1}/target/${1}-${VERSION}-javadoc.jar \
-Dclassifiers=sources,javadoc
-Dtypes=jar,jar"
echo ${COMMAND} >> releaseScript.sh
}
if [ -f ./releaseScript.sh ] ; then
rm ./releaseScript.sh
fi
fn_genReleaseScript chorus
fn_genReleaseScript chorus-spring
echo "Generated release script in ./releaseScript.sh"
echo "Now creating tar.gz and zip for release.."
function fn_addToTar {
tar -rf ${TARFILE} $1
zip ${ZIPFILE} $1
}
function fn_addArtifactsToTar {
basedir=`pwd`
cd ${basedir}/$1/target
fn_addToTar $1-${VERSION}.jar
fn_addToTar $1-${VERSION}-javadoc.jar
fn_addToTar $1-${VERSION}-sources.jar
cd ${basedir}
}
TARFILE=`pwd`/chorus-${VERSION}.tar
ZIPFILE=`pwd`/chorus-${VERSION}.zip
if [ -f "${TARFILE}" ] ; then
rm ${TARFILE}
fi
if [ -f "${TARFILE}.gz" ] ; then
rm ${TARFILE}.gz
fi
if [ -f "${ZIPFILE}" ] ; then
rm ${ZIPFILE}
fi
fn_addArtifactsToTar chorus
fn_addArtifactsToTar chorus-spring
fn_addToTar changelist.xml
fn_addToTar changelist.xsl
gzip ${TARFILE}