Skip to content

Commit

Permalink
Adds automatic uploading of releases from Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Håkansson committed Jun 20, 2016
1 parent b21dfee commit a7e7cec
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
language: java
jdk: oraclejdk7
after_success:
- ./upload.sh
- ./upload.sh
before_install:
- openssl aes-256-cbc -K $encrypted_35bfdf5ae630_key -iv $encrypted_35bfdf5ae630_iv
-in secring.gpg.enc -out secring.gpg -d
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -200,4 +200,4 @@ uploadArchives {

task wrapper(type: Wrapper) {
gradleVersion = '2.12'
}
}
Binary file added secring.gpg.enc
Binary file not shown.
26 changes: 24 additions & 2 deletions upload.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

#version: 2016-05-27

branch=$TRAVIS_BRANCH
if [ -z "$branch" ]; then
Expand All @@ -10,17 +10,39 @@ 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
echo "On master branch."
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
Expand Down

0 comments on commit a7e7cec

Please sign in to comment.