Skip to content

Commit 5dfb215

Browse files
author
Magesh Chandramouli
authored
Update deploy.sh
1 parent f1c578e commit 5dfb215

File tree

1 file changed

+13
-28
lines changed

1 file changed

+13
-28
lines changed

.travis/deploy.sh

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,31 @@ PULL_REQUEST=${TRAVIS_PULL_REQUEST}
66
USERNAME=${SONATYPE_USERNAME}
77
PASSWORD=${SONATYPE_PASSWORD}
88
SHA=${TRAVIS_COMMIT}
9+
TAG_NAME=${TRAVIS_TAG}
910

10-
#!/usr/bin/env bash
11-
function fix_git {
12-
echo "Fixing git setup for ${BRANCH}"
13-
git checkout ${BRANCH}
14-
git branch -u origin/${BRANCH}
15-
git config branch.${BRANCH}.remote origin
16-
git config branch.${BRANCH}.merge refs/heads/${BRANCH}
17-
}
18-
19-
# Only if this is a master branch and it is not a PR - meaning, this commit
20-
# is from master branch most merge
21-
if [[ "${BRANCH}" == 'master' && "${PULL_REQUEST}" == 'false' ]]; then
22-
if [[ -z "${USERNAME}" || -z "${PASSWORD}" ]]; then
11+
if [[ -z "${USERNAME}" || -z "${PASSWORD}" ]]; then
2312
echo "ERROR! Please set SONATYPE_USERNAME and SONATYPE_PASSWORD environment variable"
2413
exit 1
25-
fi
26-
27-
# if the current commit has a tag and if the tag matches the semantic versioning pattern `x.y.z`
28-
# then release it
29-
TAG_NAME=`git describe ${SHA} --tags`
30-
echo "Tag associated with the current commit ${SHA} is ${TAG_NAME}"
14+
fi
3115

32-
if [[ ! -z "${TAG_NAME}" && ${TAG_NAME} =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
33-
echo "travis tag is set -> updating pom.xml <version> attribute to ${TAG_NAME}"
34-
fix_git
35-
./mvnw --batch-mode --settings .travis/settings.xml -DskipTests=true -DreleaseVersion=${TAG_NAME} release:clean release:prepare release:perform
36-
SUCCESS=$?
16+
if [[ "${BRANCH}" == 'master' && "${PULL_REQUEST}" == 'false' ]] || [[ -n "${TAG_NAME}" ]]; then
17+
if [[ ! -z "${TAG_NAME}" ]]; then
18+
echo "Ensuring that pom <version> matches ${TAG_NAME}"
19+
./mvnw org.codehaus.mojo:versions-maven-plugin:2.5:set -DnewVersion=${TAG_NAME}
3720
else
3821
echo "no travis tag is set, hence keeping the snapshot version in pom.xml"
39-
./mvnw --batch-mode --settings .travis/settings.xml clean deploy -DskipTests=true -B -U
40-
SUCCESS=$?
4122
fi
4223

24+
echo "Uploading to oss repo and GitHub"
25+
./mvnw deploy --settings .travis/settings.xml -DskipTests=true --batch-mode --update-snapshots -Prelease
26+
SUCCESS=$?
4327
if [[ ${SUCCESS} -eq 0 ]]; then
4428
echo "successfully deployed the jars to nexus"
4529
fi
4630

4731
exit ${SUCCESS}
4832
else
49-
echo "Skipping artifact deployment for branch ${BRANCH}, commit ${SHA} with PR=${PULL_REQUEST}"
50-
exit 0
33+
echo "Skipping artifact deployment for branch ${BRANCH} with PR=${PULL_REQUEST} and TAG=${TAG_NAME}"
5134
fi
35+
36+
exit 0

0 commit comments

Comments
 (0)