Skip to content

Commit

Permalink
Handle either/or of wrapper/locks
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulsom committed Jul 15, 2018
1 parent 9d9fc4a commit f214373
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions semaphore-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,28 @@ function commitNewCode() {
git push
}

WRAPPER_UPDATED=unknown
function updateGradleWrapper() {
set +e
local NEW_GRADLE=$(getLatestRelease gradle/gradle)
echo "Upgrading gradle to $NEW_GRADLE"
gw wrapper --gradle-version ${NEW_GRADLE} --distribution-type all
if [ $(git status --short| wc -l) != 0 ]; then
echo "New gradle found. Testing..."
gw check && codecov
echo "gradlew upgrade works... Checking in changes"
commitNewCode "Upgrade gradlew to $NEW_GRADLE"
if [ $? = 0 ]; then
echo "gradlew update works... Checking in changes"
commitNewCode "Upgrade gradlew to $NEW_GRADLE"
WRAPPER_UPDATED=yes
else
git reset --hard
WRAPPER_UPDATED=no
fi
else
echo "No gradlew upgrade available"
echo "No gradlew update available"
WRAPPER_UPDATED=no
fi
set -e
}

function updateDependencyLocks() {
Expand All @@ -71,15 +81,19 @@ function updateDependencyLocks() {
echo "Dependency changes found..."
gw check && codecov
echo "New dependencies work. Checking in changes"
commitNewCode "Upgrade dependency locks"
commitNewCode "Update dependency locks"
else
echo "No new dependencies found."
fi
}

function main() {
if [ "$SEMAPHORE_TRIGGER_SOURCE" = "scheduler" ]; then
updateGradleWrapper || updateDependencyLocks
updateGradleWrapper
WRAPPER_UPDATE_STATUS=$?
if [ ${WRAPPER_UPDATED} = no -o ${WRAPPER_UPDATE_STATUS} != 0 ]; then
updateDependencyLocks
fi
else
if [ "$PULL_REQUEST_NUMBER" != "" ]; then
gw check && codecov
Expand Down

0 comments on commit f214373

Please sign in to comment.