From ce65a4111021dfabc5ab0dcecff13b32a0ce0401 Mon Sep 17 00:00:00 2001 From: Robert Hajek Date: Thu, 4 Oct 2018 16:33:26 +0200 Subject: [PATCH] - added automated SNAPSHOT publishing to Maven Central repository --- .maven-settings.xml | 27 +++++++++++++++++++++++++++ .travis.yml | 18 ++++++++++++++++-- deploy-snapshot.sh | 26 ++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 .maven-settings.xml create mode 100755 deploy-snapshot.sh diff --git a/.maven-settings.xml b/.maven-settings.xml new file mode 100644 index 000000000..864a9ec04 --- /dev/null +++ b/.maven-settings.xml @@ -0,0 +1,27 @@ + + + + + ossrh + ${env.SONATYPE_USERNAME} + ${env.SONATYPE_PASSWORD} + + + + + + ossrh + + true + + + ${env.GPG_EXECUTABLE} + ${env.GPG_PASSPHRASE} + + + + + diff --git a/.travis.yml b/.travis.yml index 9b2b74fde..1ca2e344c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,15 +6,29 @@ services: # We test against all influxdb versions with the most actual JDK. # Test only the most recent influxdb version with JDK8 which will be legacy soon. env: + global: + - secure: aCFuNNixYILZZfcOp0jI66om4w8Cbr+qtz1FUOVgbxeipFA93y7KLoXtFajkE1qmbHOdz8SvPcloY5q6HKIOYuqv4/6at+OaTogXELfrR+oKfxf2t5PfB1D+1RxM90+wjsEPGQh+HmFOEnGCnJ8ZUfcx76Afs+mPzbpjzKeNz7w= + - secure: dAJK41xM2dN3q3xJMqAOP6uvrOvpjjUzmHr8mYNyepER8Lpms9/GqVUxqJv12wzCBqv1XZk/CXxrv3iBc2XjlxlrzIJGQChTinwDEigv0BMl/Gh0821ja7gwzMEUmg9f79m5tJxIFQ306cWz1gyRDqM3fLzskvM2ayzvynsNc/w= + + matrix: - MAVEN_JAVA_VERSION=3-jdk-10-slim INFLUXDB_VERSION=1.6 - MAVEN_JAVA_VERSION=3-jdk-10-slim INFLUXDB_VERSION=1.5 - MAVEN_JAVA_VERSION=3-jdk-10-slim INFLUXDB_VERSION=1.4 - MAVEN_JAVA_VERSION=3-jdk-10-slim INFLUXDB_VERSION=1.3 - MAVEN_JAVA_VERSION=3-jdk-10-slim INFLUXDB_VERSION=1.2 - MAVEN_JAVA_VERSION=3-jdk-10-slim INFLUXDB_VERSION=1.1 - - MAVEN_JAVA_VERSION=3-jdk-8-slim INFLUXDB_VERSION=1.6 + - MAVEN_JAVA_VERSION=3-jdk-8-slim INFLUXDB_VERSION=1.6 SNAPSHOT=Y + +script: "./compile-and-test.sh" -script: ./compile-and-test.sh +deploy: + provider: script + script: "./deploy-snapshot.sh" + skip_cleanup: true + on: + repo: influxdata/influxdb-java + condition: $SNAPSHOT == "Y" && $DEPLOY_SNAPSHOT == "Y" + branch: master after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/deploy-snapshot.sh b/deploy-snapshot.sh new file mode 100755 index 000000000..f413424d8 --- /dev/null +++ b/deploy-snapshot.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +set -e + +#Parse project version from pom.xml +export PROJECT_VERSION=`xmllint --xpath "//*[local-name()='project']/*[local-name()='version']/text()" pom.xml` +echo "Project version: $PROJECT_VERSION" + +#Skip if not *SNAPSHOT +if [[ $PROJECT_VERSION != *SNAPSHOT ]]; then + echo "$PROJECT_VERSION is not SNAPSHOT - skip deploy."; + exit; +fi + + +DEFAULT_MAVEN_JAVA_VERSION="3-jdk-8-slim" +MAVEN_JAVA_VERSION="${MAVEN_JAVA_VERSION:-$DEFAULT_MAVEN_JAVA_VERSION}" +echo "Deploy snapshot with maven:${MAVEN_JAVA_VERSION}" + +docker run -it --rm \ + --volume ${PWD}:/usr/src/mymaven \ + --volume ${PWD}/.m2:/root/.m2 \ + --workdir /usr/src/mymaven \ + --env SONATYPE_USERNAME=${SONATYPE_USERNAME} \ + --env SONATYPE_PASSWORD=${SONATYPE_PASSWORD} \ + maven:${MAVEN_JAVA_VERSION} mvn -s .maven-settings.xml -DskipTests=true clean package deploy