diff --git a/.travis.yml b/.travis.yml index 37803040fa..8472f0d4b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,22 @@ jdk: script: mvn verify -Pquality,linux cache: directories: - - ~/.m2/repository + - "~/.m2/repository" +deploy: +- provider: script + script: travis/deploy.sh + skip_cleanup: true + on: + branch: master +- provider: script + script: travis/deploy.sh + skip_cleanup: true + on: + tags: true +- provider: releases + api_key: $GIT_TOKEN + file_glob: true + file: "./distribution/target/styx-*.zip" + skip_cleanup: true + on: + tags: true \ No newline at end of file diff --git a/Makefile b/Makefile index 93a50d7014..161dec47e4 100644 --- a/Makefile +++ b/Makefile @@ -133,4 +133,4 @@ changelog: # Default configuration file: /styx/default-config/default.yml # docker-image: clean - mvn install -Prelease,linux,docker -Dmaven.test.skip=true + mvn install -Prelease,linux,docker -DskipTests=true -Dmaven.test.skip=true diff --git a/pom.xml b/pom.xml index 6a61573e34..928e1d67b7 100644 --- a/pom.xml +++ b/pom.xml @@ -154,7 +154,7 @@ 2.5.1 2.4 3.5 - 3.0.0-M1 + 3.1.1 2.6 2.4 2.6 @@ -1185,15 +1185,20 @@ sign - - - --pinentry-mode - loopback - - + + org.sonatype.plugins + nexus-staging-maven-plugin + ${nexus-staging-maven-plugin.version} + true + + central + https://oss.sonatype.org/ + true + + diff --git a/travis/deploy.sh b/travis/deploy.sh new file mode 100644 index 0000000000..23c07a8e6e --- /dev/null +++ b/travis/deploy.sh @@ -0,0 +1,57 @@ +#!/bin/bash -xe +# +# Copyright (C) 2013-2020 Expedia Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +set -xe +function deployRelease() { + +RELEASE_VARS='GPG_PUBLIC_KEYS GPG_SECRET_KEYS GPG_KEY_NAME GPG_PASSPHRASE DOCKER_USERNAME DOCKER_PASSWORD SONATYPE_JIRA_USERNAME SONATYPE_JIRA_PASSWORD' +for var in ${RELEASE_VARS[@]} +do + if [ -z ${!var} ] ; then + echo "Variable $var is not set. Cannot continue with release. Needed vars: $RELEASE_VARS" + exit 1 + fi +done + +export GPG_DIR="$(pwd)/gpg-temp" +mkdir -p $GPG_DIR +echo $GPG_PUBLIC_KEYS | base64 --decode >> ${GPG_DIR}/pubring.gpg +echo $GPG_SECRET_KEYS | base64 --decode >> ${GPG_DIR}/secring.gpg + +echo "Deploying Release to sonatype and docker hub" +#Ensure a correct version was configured in the pom files. +mvn versions:set -DnewVersion=$TRAVIS_TAG +#Deploy to sonatype +mvn deploy --settings travis/mvn-settings.xml -B -U -P sonatype-oss-release,linux -DskipTests=true -Dmaven.test.skip=true +#Deploy to dockerhub +echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin +mvn install -f distribution/pom.xml -B -U -P docker -Dstyxcore.docker.image=hotelsdotcom/styx +docker push hotelsdotcom/styx + +#Prepare macosx bundle for github releases +mvn install -B -U -P macosx,release -DskipTests=true -Dmaven.test.skip=true -Dgpg.skip=true +} + +function deploySnapshot() { + echo "Deploying snapshot to sonatype" + mvn deploy --settings travis/mvn-settings.xml -B -U -P sonatype-oss-release,linux -DskipTests=true -Dmaven.test.skip=true -Dgpg.skip=true +} + +if [[ -n "$TRAVIS_TAG" ]]; then + deployRelease +else + deploySnapshot +fi diff --git a/travis/mvn-settings.xml b/travis/mvn-settings.xml index 968e2a607e..f52e4a166b 100644 --- a/travis/mvn-settings.xml +++ b/travis/mvn-settings.xml @@ -1,4 +1,12 @@ + + + maven-central-mirror + Maven central mirror + https://maven-central.storage-download.googleapis.com/maven2/ + central + + central @@ -15,10 +23,10 @@ sonatype-oss-release - gpg2 false ${env.GPG_DIR}/pubring.gpg ${env.GPG_DIR}/secring.gpg + ${env.GPG_EXECUTABLE} ${env.GPG_KEY_NAME} ${env.GPG_PASSPHRASE}