From 9fcdc155b68e6a8c32a7e066d9498cc67dedcacf Mon Sep 17 00:00:00 2001 From: Gregor Dschung Date: Tue, 14 Apr 2020 19:55:39 +0200 Subject: [PATCH] Use a Gradle property to differntiate between releases and snapshots Travis-CI is checking out a detached head --- .travis.yml | 2 +- gradle/versioning.gradle | 6 ++++-- scripts/{deploy.sh => deploy-release.sh} | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) rename scripts/{deploy.sh => deploy-release.sh} (89%) diff --git a/.travis.yml b/.travis.yml index 08ee2c7..b28cfbb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,4 +35,4 @@ after_success: - if [[ $TRAVIS_BRANCH == 'master' ]]; then ./scripts/publish-ghpages.sh; fi - if [[ $TRAVIS_BRANCH == 'master' ]]; then ./scripts/publish-sonarqube.sh; fi - if [[ $TRAVIS_BRANCH == 'master' ]]; then ./scripts/publish-codecov.sh; fi - - if [[ $TRAVIS_BRANCH == 'release' ]]; then ./scripts/deploy.sh; fi + - if [[ $TRAVIS_BRANCH == 'release' ]]; then ./scripts/deploy-release.sh; fi diff --git a/gradle/versioning.gradle b/gradle/versioning.gradle index 84ed75c..b7573f4 100644 --- a/gradle/versioning.gradle +++ b/gradle/versioning.gradle @@ -5,16 +5,18 @@ buildscript { import org.ajoberstar.grgit.* +setToDefaultIfNotExists('isRelease', false) + task initBuildMetadata { def major = 0 def minor = 4 def patch = 0 - def repo = Grgit.open(dir: project.file('.')) - if (repo.branch.current().name == 'release') { + if (project.isRelease.toBoolean()) { project.version = "${major}.${minor}.${patch}" } else { project.version = "${major}.${minor}.${patch}-SNAPSHOT" } + def repo = Grgit.open(dir: project.file('.')) project.ext.revision = repo.head().id project.ext.buildDate = new Date().toString() } diff --git a/scripts/deploy.sh b/scripts/deploy-release.sh similarity index 89% rename from scripts/deploy.sh rename to scripts/deploy-release.sh index 676758c..7858aac 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy-release.sh @@ -4,4 +4,5 @@ -Pgradle.publish.secret=$GRADLE_PUBLISH_SECRET \ -PbintrayUser=chkpnt \ -PbintrayApiKey=$BINTRAY_API_KEY \ + -PisRelease=true \ bintrayUpload publishPlugins