Skip to content

Commit

Permalink
Include github build script
Browse files Browse the repository at this point in the history
  • Loading branch information
oliemansm committed Oct 7, 2020
1 parent 896f3f2 commit 04c185d
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions github-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
set -ev

getVersion() {
./gradlew properties -q | grep "version:" | grep -v "kotlin_version:" | awk '{print $2}' | tr -d '[:space:]'
}

removeSnapshots() {
sed -i 's/-SNAPSHOT//' gradle.properties
}

commitRelease() {
local APP_VERSION=$(getVersion)
git commit -a -m "Update version for release"
git tag -a "v${APP_VERSION}" -m "Tag release version"
}

bumpVersion() {
echo "Bump version number"
local APP_VERSION=$(getVersion | xargs)
local SEMANTIC_REGEX='^([0-9]+)\.([0-9]+)(\.([0-9]+))?$'
if [[ ${APP_VERSION} =~ ${SEMANTIC_REGEX} ]]; then
if [[ ${BASH_REMATCH[4]} ]]; then
nextVersion=$((BASH_REMATCH[4] + 1))
nextVersion="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${nextVersion}-SNAPSHOT"
else
nextVersion=$((BASH_REMATCH[2] + 1))
nextVersion="${BASH_REMATCH[1]}.${nextVersion}-SNAPSHOT"
fi

echo "Next version: ${nextVersion}"
sed -i -E "s/^version(\s)?=.*/version=${nextVersion}/" gradle.properties
else
echo "No semantic version and therefore cannot publish to maven repository: '${APP_VERSION}'"
fi
}

commitNextVersion() {
git commit -a -m "Update version for release"
}

git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"

echo "Deploying release to Bintray"
removeSnapshots

./gradlew clean assemble && ./gradlew bintrayUpload -x check --info

commitRelease
bumpVersion
commitNextVersion
git push --follow-tags

0 comments on commit 04c185d

Please sign in to comment.