Permalink
Browse files

chore: introduce release via Travis

This provides an option to deploy pgjdbc releases to Maven Central via push to `release/master` branch
  • Loading branch information...
vlsi committed Jan 6, 2018
1 parent 1be8a9e commit acb9bddf36a8af6d1dd09857a6a05014c3e8849a
Showing with 170 additions and 10 deletions.
  1. +37 −6 .travis.yml
  2. BIN .travis/secrets.tar.enc
  3. +1 −1 .travis/travis_deploy.sh
  4. +102 −0 .travis/travis_release.sh
  5. +25 −2 CONTRIBUTING.md
  6. +5 −1 settings.xml
@@ -2,6 +2,19 @@ sudo: false
language: java
dist: trusty
stages:
- name: test
if: not branch =~ ^release/.*$ AND not branch =~ ^tmp/.*$
- name: release
# releases pgjdbc for Java 8
# It does set release tag and update pom.xml versions
if: branch =~ ^release/.*$ AND not branch =~ ^tmp/.*$
- name: release_prev
# releases pgjdbc for Java 6, Java 7
# pgjdbc-jreX requires release pom.xml versions of the main project, so pgjdbc-jreX should be
# released after the release of the main version, thus second stage
if: branch =~ ^release/.*$ AND not branch =~ ^tmp/.*$
before_script:
- test $(grep "after_n_builds" codecov.yml | tr -d '[:space:]' | cut -d":" -f2) -eq $(grep -e "COVERAGE=Y$" .travis.yml | wc -l) || exit 1
- export PG_DATADIR="/etc/postgresql/${PG_VERSION}/main"
@@ -16,14 +29,12 @@ before_script:
- test "x$REPLICATION" == 'x' || psql -U postgres -c "alter user test with replication;"
- psql -c 'create database test owner test;' -U postgres
- test "x$REPLICATION" == 'x' || ./.travis/travis_create_slaves.sh
- echo "MAVEN_OPTS='-Xmx1g -Dgpg.skip=true'" > ~/.mavenrc
- if [[ $TRAVIS_BRANCH == release/* ]]; then echo "MAVEN_OPTS='-Xmx1g'" > ~/.mavenrc; else echo "MAVEN_OPTS='-Xmx1g -Dgpg.skip=true'" > ~/.mavenrc; fi
- test "x$PG_VERSION" == 'x' || test "x$NO_HSTORE" == 'xY' || psql test -c 'CREATE EXTENSION hstore;' -U postgres
- test "x$PG_VERSION" == 'x' || test "x$CREATE_PLPGSQL" == 'x' || createlang -U postgres plpgsql test
env:
global:
- secure: "3HRd+UJQzXoxmBAiJ8SLFuYK8NvMVgIs0erfcPdgvtfFGTPkH3XMONfNr2VE2uz6qwUB5GWkVzvS4c9CPbnnft9QhyYeeUINiqQMN5+6AN5re3C2D7VQMm3NSB+T2R6zS/18UZW5tIoTJILgl5oRCQFI7RSpqhvZ8nqPxJ4gptI="
- secure: "VrNgbyKQi5HjSMZfkt/zwG+AHk1NW1b+f3Jo1ZH7DCqcgLApwvp4MNsw+XamqHxudjj3Z8+4bYBxG2H6zIOobIyYhBvxUwMq7HTjM4jH8m5phqvQIWZOzZzqguYNNS7JJQUpIMwR7wTuHqucVfMxljoSuXQbs+0BUxo4Eh+FScQ="
- secure: "NI+aqwRLLVt2feJdk/2ZEZnsaPyu+vOx8MahVxjz0UUVvRHVqxM5O1M0R53NJfEeIjflOzgZJwRLqgyl6dkdfjytRhaHWGptQdehV4cwNb+4epnn8WlpRzMac65zTQqnbGVtw9jissDQv6/Zl/+D+DMcU65BbFZkix40whILXG0="
before_install:
@@ -43,7 +54,7 @@ script:
- envsubst < toolchains.xml > ~/.m2/toolchains.xml
- test ${JDK} -eq 9 || jdk_switcher use oraclejdk8 # Run Maven with Java 8, build with Toolchains.
- test -z "${ZULU_JDK}" || export TRAVIS_JDK_VERSION=zulujdk${ZULU_JDK} # trick codecov to use correct jdk version
- ./.travis/travis_build.sh
- if [[ $TRAVIS_BRANCH == release/* ]]; then .travis/travis_release.sh; else ./.travis/travis_build.sh; fi
- ./.travis/travis_check_postgres_health.sh
# To avoid useless S3 cache updates (https://github.com/travis-ci/travis-ci/issues/1441#issuecomment-67607074)
#- mkdir /tmp/cache-trick
@@ -68,7 +79,8 @@ cache:
matrix:
fast_finish: true
include:
- jdk: oraclejdk8
- stage: test
jdk: oraclejdk8
env: RUN_CHECKSTYLE=true
script: mvn checkstyle:check
- env:
@@ -195,7 +207,26 @@ matrix:
env:
- PG_VERSION=9.4
- NO_WAFFLE_NO_OSGI=Y
- stage: release
jdk: oraclejdk8
env:
- PG_VERSION=9.6
- stage: release_prev
jdk: openjdk7
sudo: required
addons:
postgresql: "9.2"
env:
- PG_VERSION=9.2
- ZULU_JDK=7
- stage: release_prev
jdk: openjdk6
sudo: required
addons:
postgresql: "9.1"
env:
- PG_VERSION=9.1
- ZULU_JDK=6
# Deploy snapshots to Maven Central
after_success:
Binary file not shown.
@@ -13,5 +13,5 @@ then
cd pgjdbc-jre7
mvn ${MVN_ARGS} -P release-artifacts,release,skip-unzip-jdk
else
mvn ${MVN_ARGS} -P release-artifacts,release
mvn ${MVN_ARGS} -P release-artifacts,release -Dskip.unzip-jdk-src=false
fi
@@ -0,0 +1,102 @@
#!/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 "pgsql-jdbc@postgresql.org"
# 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
CURRENT_VERSION=$(mvn -B -N org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v '\[')
RELEASE_VERSION=${CURRENT_VERSION/-SNAPSHOT}
ORIGINAL_BRANCH=${TRAVIS_BRANCH#release/}
REPO=$TRAVIS_REPO_SLUG
JRE=
if [[ "${TRAVIS_JDK_VERSION}" == *"jdk7"* ]]; then
JRE=-jre7
elif [[ "${TRAVIS_JDK_VERSION}" == *"jdk6"* ]]; then
JRE=-jre6
fi
# Remove tmp branch if exists
git push git@github.com:$TRAVIS_REPO_SLUG$JRE.git ":$TMP_BRANCH" || true
set -x
RELEASE_TAG=REL$RELEASE_VERSION
if [[ "x$JRE" == "x" ]]; then
# Note: release should be a fast-forward for the "master" branch
# If push dry-run fails, the script just terminates
git push --dry-run git@github.com:$TRAVIS_REPO_SLUG.git "HEAD:$ORIGINAL_BRANCH"
git checkout -b "$TMP_BRANCH"
else
git fetch --unshallow
# Use RELx.y.z.jreN
RELEASE_TAG=$RELEASE_TAG.${JRE#-}
# The following updates pgjdbc submodule of pgjdbc-jreX to the relevant RELx.y.z release tag
git clone -b "$ORIGINAL_BRANCH" --depth=50 https://github.com/$TRAVIS_REPO_SLUG$JRE.git pgjdbc$JRE
cd pgjdbc$JRE
# Use tmp branch for the release, so mvn release would use that
git checkout -b "$TMP_BRANCH"
git submodule update --init
# Force relevant version for jreN repository
mvn -DnewVersion=$RELEASE_VERSION.${JRE#-}-SNAPSHOT versions:set versions:commit
# Add all known pom.xml files in the repository
git add -u \*pom.xml
cd pgjdbc
git fetch
git checkout "$ORIGINAL_BRANCH"
git reset --hard REL$RELEASE_VERSION
cd ..
git add pgjdbc
git commit -m "Update pgjdbc to $RELEASE_VERSION"
# Note: we are IN pgjdbc-jreX sub-folder, and the subsequent release would release "jre-specific" version
fi
# Remove release tag if exists just in case
git push git@github.com:$TRAVIS_REPO_SLUG$JRE.git :$RELEASE_TAG || true
# -Darguments here is for maven-release-plugin
MVN_SETTINGS=$(pwd)/settings.xml
mvn -B --settings settings.xml -Darguments="--settings '${MVN_SETTINGS}'" -Dskip.unzip-jdk-src=false release:prepare release:perform
# Point "master" branch to "next development snapshot commit"
git push git@github.com:$TRAVIS_REPO_SLUG$JRE.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 git@github.com:$TRAVIS_REPO_SLUG$JRE.git ":$TMP_BRANCH"
@@ -149,7 +149,29 @@ Prerequisites:
[copr web page](https://copr.fedorainfracloud.org/coprs/g/pgjdbc/pgjdbc-travis/builds/) -
possibly bump `parent poms` or `pgjdbc` versions in RPM [spec file](packaging/rpm/postgresql-jdbc.spec).
Procedure:
### Release via Travis
To release a branch via Travis, perform the following:
TL;DR:
git checkout -B release/master origin/master
git push origin release/master
1. Check if `pom.xml` includes proper `-SNAPSHOT` versions (release versions would be the ones without `-SNAPSHOT`)
1. Push `release/master` branch to pointing to the commit you want to release.
Note: `master..release/master` should be a fast-forward or both branches should point to the same commit.
Travis would build new version, create a tag, update `pom.xml` to the next snapshot versions, and update `master` branch accordingly.
Note: .jre6 and .jre7 builds will be built and staged to Maven Central automatically
Note: the artifacts will not be visible in Maven Central before you manually release them.
1. Navigate to [Sonatype Nexus Repository Manager](https://oss.sonatype.org/#stagingRepositories), find staging `orgpostgresql` repository there and release it
### Manual release procedure
Release a version for JDK8
- From a root folder, perform `mvn release:clean release:prepare`. That will ask you new version, update pom.xml, commit and push it to git.
@@ -196,7 +218,8 @@ If staged artifacts look fine, release it
mvn nexus-staging:release -DstagingRepositoryId=orgpostgresql-1082
```
Update changelog:
### Updating changelog
- run `./release_notes.sh`, edit as desired
## Dependencies
@@ -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>

0 comments on commit acb9bdd

Please sign in to comment.