Skip to content

Commit bae9947

Browse files
Magesh Chandramouliashishagg
authored andcommitted
fixing build / release process (#87)
1 parent 5fa3d4d commit bae9947

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

.travis/deploy.sh

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,41 @@
11
#!/bin/bash
22
cd `dirname $0`/..
33

4-
if [ "${TRAVIS_BRANCH}" == 'master' -a "${TRAVIS_PULL_REQUEST}" == 'false' ] || [ -n "${TRAVIS_TAG}" ]; then
5-
if [[ -z "${SONATYPE_USERNAME}" || -z "${SONATYPE_PASSWORD}" ]]; then
4+
BRANCH=${TRAVIS_BRANCH}
5+
PULL_REQUEST=${TRAVIS_PULL_REQUEST}
6+
USERNAME=${SONATYPE_USERNAME}
7+
PASSWORD=${SONATYPE_PASSWORD}
8+
SHA=${TRAVIS_COMMIT}
9+
10+
# Only if this is a master branch and it is not a PR - meaning, this commit
11+
# is from master branch most merge
12+
if [[ "${BRANCH}" == 'master' && "${PULL_REQUEST}" == 'false' ]]; then
13+
if [[ -z "${USERNAME}" || -z "${PASSWORD}" ]]; then
614
echo "ERROR! Please set SONATYPE_USERNAME and SONATYPE_PASSWORD environment variable"
715
exit 1
816
fi
917

10-
TAG_NAME=`git describe ${TRAVIS_COMMIT} --tags`
11-
echo "Tag associated with the current commit ${TRAVIS_COMMIT} is ${TAG_NAME}"
12-
13-
if [ ! -z "${TRAVIS_TAG}" ]; then
14-
echo "travis tag is set -> updating pom.xml <version> attribute to ${TRAVIS_TAG}"
15-
./mvnw --batch-mode --settings .travis/settings.xml -DskipTests=true -DreleaseVersion=${TRAVIS_TAG} release:clean release:prepare release:perform
18+
# if the current commit has a tag and if the tag matches the semantic versioning pattern `x.y.z`
19+
# then release it
20+
TAG_NAME=`git describe ${SHA} --tags`
21+
echo "Tag associated with the current commit ${SHA} is ${TAG_NAME}"
22+
23+
if [[ ! -z "${TAG_NAME}" && ${TAG_NAME} =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
24+
echo "travis tag is set -> updating pom.xml <version> attribute to ${TAG_NAME}"
25+
./mvnw --batch-mode --settings .travis/settings.xml -DskipTests=true -DreleaseVersion=${TAG_NAME} release:clean release:prepare release:perform
1626
SUCCESS=$?
1727
else
1828
echo "no travis tag is set, hence keeping the snapshot version in pom.xml"
1929
./mvnw --batch-mode --settings .travis/settings.xml clean deploy -DskipTests=true -B -U
2030
SUCCESS=$?
2131
fi
2232

23-
if [ ${SUCCESS} -eq 0 ]; then
33+
if [[ ${SUCCESS} -eq 0 ]]; then
2434
echo "successfully deployed the jars to nexus"
2535
fi
2636

2737
exit ${SUCCESS}
2838
else
29-
echo "Skipping artifact deployment for branch ${TRAVIS_BRANCH} with PR=${TRAVIS_PULL_REQUEST} and TAG=${TRAVIS_TAG}"
39+
echo "Skipping artifact deployment for branch ${BRANCH}, commit ${SHA} with PR=${PULL_REQUEST}"
40+
exit 0
3041
fi
31-
32-
exit 0

0 commit comments

Comments
 (0)