diff --git a/.travis.yml b/.travis.yml index 5c65f3ff..683bcafb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,7 @@ language: java jdk: oraclejdk7 after_success: - - ./upload.sh \ No newline at end of file +- ./upload.sh +before_install: +- openssl aes-256-cbc -K $encrypted_35bfdf5ae630_key -iv $encrypted_35bfdf5ae630_iv + -in secring.gpg.enc -out secring.gpg -d diff --git a/build.gradle b/build.gradle index c9022244..a92aaeee 100644 --- a/build.gradle +++ b/build.gradle @@ -159,7 +159,7 @@ signing { uploadArchives { //Only upload if a git hash is supplied. On Travis only upload snapshots. - enabled = repoRevision.size()==40 && (System.getenv("TRAVIS_BUILD_ID")==null || version.endsWith("SNAPSHOT")) + enabled = repoRevision.size()==40 && System.getenv("TRAVIS_BUILD_ID")!=null repositories { mavenDeployer { if (isReleaseVersion) { @@ -200,4 +200,4 @@ uploadArchives { task wrapper(type: Wrapper) { gradleVersion = '2.12' -} \ No newline at end of file +} diff --git a/secring.gpg.enc b/secring.gpg.enc new file mode 100644 index 00000000..4dd2e92e Binary files /dev/null and b/secring.gpg.enc differ diff --git a/upload.sh b/upload.sh index 7400781d..586fd8d2 100755 --- a/upload.sh +++ b/upload.sh @@ -1,5 +1,5 @@ #!/bin/bash - +#version: 2016-05-27 branch=$TRAVIS_BRANCH if [ -z "$branch" ]; then @@ -10,9 +10,31 @@ pullrequest=$TRAVIS_PULL_REQUEST if [ -z "$pullrequest" ]; then pullrequest="false" fi + +version=`grep 'version=' gradle.properties | grep -E -o '[0-9\.]+.+$'` +if [[ $version == *SNAPSHOT ]]; then + is_release=false +else + is_release=true +fi + +if [ `git diff --name-only HEAD HEAD~ | grep gradle.properties -c` = 1 ]; then + prop_change="true" +else + prop_change="false" +fi echo "Branch: $branch" echo "Revision: $revision" echo "Pull request: $pullrequest" +echo "Is release: $is_release" +echo "Properties changed: $prop_change" + +if [ "$prop_change" = "false" ]; then + if [ "$is_release" = "true" ]; then + echo "No version change since last commit. Is this really a release?" + exit 1 + fi +fi if [ "$pullrequest" = "false" ]; then if [ $branch = "master" ]; then @@ -20,7 +42,7 @@ if [ "$pullrequest" = "false" ]; then if [ -n "$SONATYPE_USER" ]; then if [ -n "$SONATYPE_PASSWORD" ]; then echo "Starting upload..." - ./gradlew uploadArchives -PsonatypeUsername=$SONATYPE_USER -PsonatypePassword=$SONATYPE_PASSWORD -PrepositoryRevision=$revision + ./gradlew uploadArchives -PsonatypeUsername=$SONATYPE_USER -PsonatypePassword=$SONATYPE_PASSWORD -PrepositoryRevision=$revision -Psigning.keyId=$SIGNING_KEY -Psigning.password=$SIGNING_PASSWORD -Psigning.secretKeyRingFile=secring.gpg else echo "SONATYPE_PASSWORD not set. Skipping upload." fi