Skip to content
This repository has been archived by the owner on Sep 15, 2020. It is now read-only.

Commit

Permalink
Introduce Travis releases
Browse files Browse the repository at this point in the history
  • Loading branch information
vlsi committed Jan 7, 2018
1 parent fdda24e commit 9b37ead
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
*.xml text
*.yaml text
*.yml text
*.enc binary
26 changes: 21 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,35 @@ language: java
jdk:
- oraclejdk8

env:
global:
- secure: "RyEaEKa8dqco4MmEiEx7ka4c/QXYRHJQKVAyO2c9riDHlGQEp1gvlvO+62leZOOKiJhGARbSwbZN2kKdG22V0Hu49tEW1TKEdcZ+F0s9SrCf8QdEMzLAWQePIojZvzS67ggEAPPS5xmLujpWT1eyhXz93qJz08ShgTX0eLhgw8VE1/6+ucgPNK9KHDppYcgKfY2uOwp+2mwj+ltcWT/az3ky6TM4TTxhyNE2pSIKYBpxe3Ga3Hd31MzNolhsdzZvL1pPexEpUt+4Ps4SRXotUjmkM1zS8/pbQZ6HC1dGj0AVUbeyUVKEaoV9lhMFFT7PKSktAjw9FNpS1F6NsPbvQvBqt42k05QWwu1OoJQixFsPWb0klW7I7YQyHHUZexh0wQPf7drlw+kho4CXPFLbERMVw1X4TSyOalUuoBcKaiH8ZQL2rVYf9bMVF7YIw9aUfvPYYWLbboDRd3ln1TPiGywCGShWg6ubKB7ZxEtYQr23JHbWM2VlF3ddOwrRa1++L8ut/9yV2aj/WOT8Al/SiMYQ/4bhQSEQlTrpPRsj//ECltfyRHoWxVR9jWhRhz0VbrYueNGHZ9dR4d1t0VkydyfqWHSk1KGW34YYm86zAL0NnXxrK/Irck5K7STRs3oK9UEYVcbO1Pd45mWx+y/mdD8TRg318rqlEb4WJ5rWrF4="
- secure: "Il4G1ShT8971ThTwTHwrZHuV/XTwIufe4ZBcj7t+LSclikXxgsDPY83GSDeMVBihn6ZLDkT3V0PvTRT6XqwOprrSeBvAGng+nR4/iazZfrxcMHqLUQzu6w6UQLT5LT+L8ofRC8hFeRhcf704gtaIn44BI5IlKAFBqacYymEEFWC3W9FpvrYKAXvmhnmmIg5A/JGiTbGjENcV3evaENPBYbGtI8d80cqWfofg+RodJzgFBzslw4dtuiwWJWMHmWzRQi/6M53tx8OmJyd7YavInXc9KaaJvwcF2n/9AzF26tSlzKu9I3V01+k0wWVvXnMsC/PYP4Kx6MboRwoDNm2firOF0oI/HB6fs4Wvg/IjBo0JFnqwmypJerWicZ6SKWo6l0oplJg3FrX18UjsJqCnjxCXJjgavcLooOR+omVvvdK9Nt4eGo/K5YVemOmi45FlAiO9omVo1E5yEemg27ArQC9x+J7W6ISXAT9E5VotBFWt/Bl+bhnkf5OO/y51x2jIIETZ4QVIpSXFFcWvkemefjnwrg30I+ud4HchQUbAA2MVDFSYFC18D88p9aVXcVbXKAjEzm1LxcErdQ5e4AOu1Eajj/EFDUpol9dvESQKgFqhWr8ykmsxKi/K+izziF0CKEGwQJfzT5Dze+QkqJ3TAt57BEdKr0ckTEkawrYvdUo="
stages:
- name: test
if: not branch =~ ^release/.*$ AND not branch =~ ^tmp/.*$
- name: publish
if: branch =~ ^release/.*$ AND not branch =~ ^tmp/.*$

before_cache:
# No sense in caching current build artifacts
rm -rf $HOME/.m2/repository/org/postgresql

before_install:
- test -d "${JDK6_HOME}" || export JDK6_HOME=$(jdk_switcher home openjdk6)
- test -d "${JDK7_HOME}" || export JDK7_HOME=$(jdk_switcher home openjdk7)
- test -d "${JDK8_HOME}" || export JDK8_HOME=$(jdk_switcher home oraclejdk8)
- test -d "${JDK9_HOME}" || export JDK9_HOME=$(jdk_switcher home oraclejdk9)
- test -d "${JDK9_HOME}" || export JDK9_HOME=$(jdk_switcher home oraclejdk8) # JDK9 missing on precise, fallback to JDK8
- envsubst < .travis/toolchains.xml > ~/.m2/toolchains.xml

cache:
directories:
- '$HOME/.m2/repository'

matrix:
include:
- stage: test
- stage: publish
install: true # skip mvn install
script: .travis/deploy.sh

# Deploy snapshots to Maven Central
after_success:
- "[[ $TRAVIS_BRANCH == 'master' ]] && mvn clean deploy --settings settings.xml"
- "[[ $TRAVIS_BRANCH == 'master' ]] && mvn clean deploy --settings .travis/settings.xml"
50 changes: 50 additions & 0 deletions .travis/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash

# Fail script on error
set -e

cd .travis
mkdir secrets

# GPG is required for artifact signing
openssl aes-256-cbc -k "$SUPER_SECRET_KEY" -in secrets.tar.enc -out secrets/secrets.tar -d

cd secrets
tar xvf secrets.tar

gpg --import gpg-secret.key
gpg --import-ownertrust gpg-ownertrust

# Decrypt GitHub SSH key
chmod 600 github_deploy
eval $(ssh-agent -s)
ssh-add ./github_deploy

cd ..
rm -rf ./secrets

cd ..

git config --global user.name "pgjdbc CI"
git config --global user.email "[email protected]"

# By default Travis checks out commit, and maven-release-plugin wants to know branch name
# On top of that, maven-release-plugin publishes branch, and it would terminate Travis job (current one!),
# so we checkout a non-existing branch, so it won't get published
# Note: at the end, we need to update "master" branch accordingly" (see $ORIGINAL_BRANCH)
TMP_BRANCH=tmp/$TRAVIS_BRANCH
git checkout -b "$TMP_BRANCH"

# Remove tmp branch if exists
git push [email protected]:$TRAVIS_REPO_SLUG.git ":$TMP_BRANCH" || true

set -x
# -Darguments here is for maven-release-plugin
MVN_SETTINGS=$(pwd)/.travis/settings.xml
mvn -B --settings .travis/settings.xml -Darguments="--settings '${MVN_SETTINGS}'" release:prepare release:perform

# Point "master" branch to "next development snapshot commit"
ORIGINAL_BRANCH=${TRAVIS_BRANCH#release/}
git push [email protected]:$TRAVIS_REPO_SLUG.git "HEAD:$ORIGINAL_BRANCH"
# Removal of the temporary branch is a separate command, so it left behind for the analysis in case "push to master" fails
git push [email protected]:$TRAVIS_REPO_SLUG.git ":$TMP_BRANCH"
Binary file added .travis/secrets.tar.enc
Binary file not shown.
6 changes: 5 additions & 1 deletion settings.xml → .travis/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<!-- Deploy only snapshots from Travis -->
<id>ossrh</id>
<username>${env.SONATYPE_USERNAME}</username>
<password>${env.SONATYPE_PASSWORD}</password>
</server>
<server>
<id>ossrh-snapshots</id>
<username>${env.SONATYPE_USERNAME}</username>
<password>${env.SONATYPE_PASSWORD}</password>
Expand Down
52 changes: 52 additions & 0 deletions .travis/toolchains.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF8"?>
<toolchains>
<!--
JDK toolchains to be used to build PgJDBC for JRE6 or JDR7.
Note: in order to release PgJDBC, you need all three JDK to be set via toolchains.
The file should be placed to ~/.m2/toolchains.xml
Default locations are:
Mac OS: /Library/Java/JavaVirtualMachines/jdk1.7.0_XY.jdk/Contents/Home
Ubuntu: /usr/lib/jvm/java-7-openjdk-amd64
-->
<toolchain>
<type>jdk</type>
<provides>
<version>1.6</version>
<vendor>oracle</vendor>
</provides>
<configuration>
<jdkHome>${JDK6_HOME}</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>1.7</version>
<vendor>oracle</vendor>
</provides>
<configuration>
<jdkHome>${JDK7_HOME}</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>1.8</version>
<vendor>oracle</vendor>
</provides>
<configuration>
<jdkHome>${JDK8_HOME}</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>1.9</version>
<vendor>oracle</vendor>
</provides>
<configuration>
<jdkHome>${JDK9_HOME}</jdkHome>
</configuration>
</toolchain>
</toolchains>

0 comments on commit 9b37ead

Please sign in to comment.