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 1f13bc8
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions semaphore-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,20 @@ function getLatestRelease() {
| sed -e "s/^v//g"
}

CODE_COMMITTED=no
function commitNewCode() {
git add .
git config --global user.email "[email protected]"
git config --global user.name "SemaphoreCI"
git commit -m "$1"
git push
CODE_COMMITTED=yes
}

function resetChanges () {
git reset --hard
CODE_COMMITTED=no
ERROR_IN="$ERROR_IN $1"
}

function updateGradleWrapper() {
Expand All @@ -57,29 +65,30 @@ function updateGradleWrapper() {
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"
gw check \
&& commitNewCode "Upgrade gradlew to $NEW_GRADLE" \
|| resetChanges update-gradlew
else
echo "No gradlew upgrade available"
echo "No gradlew update available"
fi
}

function updateDependencyLocks() {
gw resolveAndLockAll --write-locks
if [ $(git status --short| wc -l) != 0 ]; then
echo "Dependency changes found..."
gw check && codecov
echo "New dependencies work. Checking in changes"
commitNewCode "Upgrade dependency locks"
gw check \
&& commitNewCode "Update dependency locks" \
|| resetChanges resolveAndLockAll
else
echo "No new dependencies found."
fi
}

function main() {
if [ "$SEMAPHORE_TRIGGER_SOURCE" = "scheduler" ]; then
updateGradleWrapper || updateDependencyLocks
updateGradleWrapper
updateDependencyLocks
else
if [ "$PULL_REQUEST_NUMBER" != "" ]; then
gw check && codecov
Expand Down

0 comments on commit 1f13bc8

Please sign in to comment.