Skip to content

Commit

Permalink
Release artifacts from Travis (#594)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvlato authored Jan 29, 2020
1 parent ce6a5cf commit 21f557a
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 10 deletions.
20 changes: 19 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 12 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
<maven-install-plugin.version>2.5.1</maven-install-plugin.version>
<maven-jar-plugin.version>2.4</maven-jar-plugin.version>
<maven-pmd-plugin.version>3.5</maven-pmd-plugin.version>
<maven-javadoc-plugin.version>3.0.0-M1</maven-javadoc-plugin.version>
<maven-javadoc-plugin.version>3.1.1</maven-javadoc-plugin.version>
<maven-project-info-reports-plugin.version>2.6</maven-project-info-reports-plugin.version>
<maven-release-plugin.version>2.4</maven-release-plugin.version>
<maven-resources-plugin.version>2.6</maven-resources-plugin.version>
Expand Down Expand Up @@ -1192,15 +1192,20 @@
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>${nexus-staging-maven-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<serverId>central</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
<properties>
Expand Down
57 changes: 57 additions & 0 deletions travis/deploy.sh
Original file line number Diff line number Diff line change
@@ -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
10 changes: 9 additions & 1 deletion travis/mvn-settings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<settings>
<mirrors>
<mirror>
<id>maven-central-mirror</id>
<name>Maven central mirror</name>
<url>https://maven-central.storage-download.googleapis.com/maven2/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<servers>
<server>
<id>central</id>
Expand All @@ -15,10 +23,10 @@
<profile>
<id>sonatype-oss-release</id>
<properties>
<gpg.executable>gpg2</gpg.executable>
<gpg.defaultKeyring>false</gpg.defaultKeyring>
<gpg.publicKeyring>${env.GPG_DIR}/pubring.gpg</gpg.publicKeyring>
<gpg.secretKeyring>${env.GPG_DIR}/secring.gpg</gpg.secretKeyring>
<gpg.executable>${env.GPG_EXECUTABLE}</gpg.executable>
<gpg.keyname>${env.GPG_KEY_NAME}</gpg.keyname>
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
</properties>
Expand Down

0 comments on commit 21f557a

Please sign in to comment.