Skip to content

Commit

Permalink
Merge pull request #268 from nats-io/travis_deploy
Browse files Browse the repository at this point in the history
Travis deploy
  • Loading branch information
sasbury authored Aug 31, 2019
2 parents 8b52053 + f010f14 commit c54f54f
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 85 deletions.
20 changes: 16 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ dist: trusty
language: java
sudo: required
jdk:
- oraclejdk8
- oraclejdk9
- openjdk8
- openjdk9
- openjdk10
- openjdk11
- oraclejdk8
- oraclejdk9
before_script:
- wget "https://github.com/nats-io/nats-server/releases/download/$nats_server_version/nats-server-$nats_server_version-linux-amd64.zip"
-O tmp.zip
Expand All @@ -20,6 +20,7 @@ install:
- "./gradlew assemble -x signArchives"
script:
- "./gradlew check"
#for testing - "./gradlew build -x test"
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
Expand All @@ -29,8 +30,19 @@ cache:
- "$HOME/.gradle/wrapper/"
after_success:
- "./gradlew test jacocoTestReport coveralls"
- test ${TRAVIS_BRANCH} != 'master' && test ${TRAVIS_JDK_VERSION} == 'oraclejdk8' && "./gradlew uploadArchives" # Disable master for now, it fails due to ip address issues
#Disable for now, upload archives fails because of IP address changes - "test ${TRAVIS_PULL_REQUEST} != 'true' && test ${TRAVIS_BRANCH} = 'master' && ./gradlew closeAndReleaseRepository"
- |
if [ "${TRAVIS_BRANCH}" == "travis_deploy" ] && [ -z "${TRAVIS_TAG}" ] && [ "${TRAVIS_JDK_VERSION}" == "oraclejdk8" ]; then
./gradlew -i sign publishToSonatype
fi
- |
if [ "${TRAVIS_BRANCH}" == "master" ] && [ -z "${TRAVIS_TAG}" ] && [ "${TRAVIS_JDK_VERSION}" == "oraclejdk8" ]; then
./gradlew -i sign publishToSonatype
fi
- |
if [ "${TRAVIS_BRANCH}" == "master" ] && [ ! -z "${TRAVIS_TAG}" ] && [ "${TRAVIS_JDK_VERSION}" == "oraclejdk8" ]; then
./gradlew -i sign publishToSonatype closeAndReleaseRepository
fi
env:
global:
- nats_server_version=v2.0.4
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

# Change Log

## Version 2.6.2
## Version 2.6.2 & 2.6.3

* [FIXED] - problem with jars being built with jdk 11
* [ADDED] - Automated deploy

## Version 2.6.1

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ The java-nats client is provided in a single jar file, with a single external de

### Downloading the Jar

You can download the latest jar at [https://search.maven.org/remotecontent?filepath=io/nats/jnats/2.6.2/jnats-2.6.2.jar](https://search.maven.org/remotecontent?filepath=io/nats/jnats/2.6.2/jnats-2.6.2.jar).
You can download the latest jar at [https://search.maven.org/remotecontent?filepath=io/nats/jnats/2.6.3/jnats-2.6.3.jar](https://search.maven.org/remotecontent?filepath=io/nats/jnats/2.6.3/jnats-2.6.3.jar).

The examples are available at [https://search.maven.org/remotecontent?filepath=io/nats/jnats/2.6.2/jnats-2.6.2-examples.jar](https://search.maven.org/remotecontent?filepath=io/nats/jnats/2.6.2/jnats-2.6.2-examples.jar).
The examples are available at [https://search.maven.org/remotecontent?filepath=io/nats/jnats/2.6.3/jnats-2.6.3-examples.jar](https://search.maven.org/remotecontent?filepath=io/nats/jnats/2.6.3/jnats-2.6.3-examples.jar).

To use NKeys, you will need the ed25519 library, which can be downloaded at [https://repo1.maven.org/maven2/net/i2p/crypto/eddsa/0.3.0/eddsa-0.3.0.jar](https://repo1.maven.org/maven2/net/i2p/crypto/eddsa/0.3.0/eddsa-0.3.0.jar).

Expand All @@ -64,7 +64,7 @@ The NATS client is available in the Maven central repository, and can be importe

```groovy
dependencies {
implementation 'io.nats:jnats:2.6.2'
implementation 'io.nats:jnats:2.6.3'
}
```

Expand All @@ -90,7 +90,7 @@ The NATS client is available on the Maven central repository, and can be importe
<dependency>
<groupId>io.nats</groupId>
<artifactId>jnats</artifactId>
<version>2.6.2</version>
<version>2.6.3</version>
</dependency>
```

Expand Down
73 changes: 41 additions & 32 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,27 @@ plugins {
id 'java'
id 'jacoco'
id 'maven'
id 'maven-publish'
id 'signing'
id 'com.github.kt3k.coveralls' version '2.6.3'
id "io.codearte.nexus-staging" version "0.11.0"
id 'com.github.kt3k.coveralls' version '2.8.4'
id 'osgi'
id 'io.codearte.nexus-staging' version '0.21.0'
id "de.marcphilipp.nexus-publish" version "0.3.0"
}

// Update version here, repeated check-ins not into master will have snapshot on them
// Be sure to update Nats.java with the latest version, the change log and the package-info.java
def versionMajor = 2
def versionMinor = 6
def versionPatch = 2
def versionPatch = 3
def versionModifier = ""
def jarVersion = "2.6.2"
def jarVersion = "2.6.3"
def branch = System.getenv("TRAVIS_BRANCH");
def tag = System.getenv("TRAVIS_TAG");
def travisTestBranch = "travis_deploy"

def getVersionName = { ->
if ("true".equals(System.getenv("TRAVIS_PULL_REQUEST")) || !"master".equals(branch)) {
if (!"master".equals(branch) || tag == "") {
versionModifier = "-SNAPSHOT"
}

Expand All @@ -45,7 +49,7 @@ if (System.getenv('SONATYPE_USERNAME') != null) {
}

tasks.withType(Sign) {
onlyIf { "master".equals(branch) }
onlyIf { "master".equals(branch) || travisTestBranch.equals(branch) }
}

repositories {
Expand Down Expand Up @@ -173,28 +177,24 @@ signing {
sign configurations.archives
}

uploadArchives {
repositories {
mavenDeployer {
if (project.hasProperty("local_archives") || ("true".equals(System.getenv("TRAVIS_PULL_REQUEST")))) {
repository(url: "file://$buildDir/repos")
} else if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: project.getProperty('ossrhUsername'), password: project.getProperty('ossrhPassword'))
}

snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: project.getProperty('ossrhUsername'), password: project.getProperty('ossrhPassword'))
}
}

pom.project {
name 'jnats'
packaging 'jar'
description 'Client library for working with the NATS messaging system.'
url 'https://github.com/nats-io/nats.java'
nexusStaging {
packageGroup = group
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact examplesJar
artifact javadocJar
pom {
name = 'jnats'
packaging = 'jar'
groupId = group
artifactId = archivesBaseName
description = 'Client library for working with the NATS messaging system.'
url = 'https://github.com/nats-io/nats.java'
licenses {
license {
name = 'The Apache License, Version 2.0'
Expand All @@ -203,10 +203,10 @@ uploadArchives {
}
developers {
developer {
id="synadia"
name "Synadia"
email "[email protected]"
url "https://nats.io"
id = "synadia"
name = "Synadia"
email = "[email protected]"
url = "https://nats.io"
}
}
scm {
Expand All @@ -215,4 +215,13 @@ uploadArchives {
}
}
}

nexusPublishing {
repositories {
sonatype {
username = project.getProperty('ossrhUsername')
password = project.getProperty('ossrhPassword')
}
}
}
}
80 changes: 39 additions & 41 deletions .travis/deploying.md → deploying.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@

## Introduction

There are currently two steps to the deployment, travis + sonatype, with a few random extra bits of knowledge.

Travis doesn't support sonatype deploy correctly. There is an issue where the various artifacts get split across multiple repositories. That code has been deleted from the travis file and manual releases are required.

~~Travis will either deploy a snapshot or a release based on the version in build.gradle. If you deploy a release build, you will need to manually go to sonatype to release it. Those builds are found in the staging area. (We need to try to automate this in the future.)~~

## Important note about release repositories

The gradle close and release process will fail if there is more than one repository staged. You may need to manually drop repositories from staging during testing on a single version number.
There are currently two pieces to the deployment, travis + sonatype, with a few random extra bits of knowledge.

## Before you Release

Expand All @@ -20,7 +12,24 @@ The gradle close and release process will fail if there is more than one reposit
3. Check dependency versions.
4. Check that the changelog.md is ready

## Manually Deploying
## Automated release

As of 2.6.3 the release is automated using gradle nexus plugins. See the build.gradle file for details. To do a release, simply update values in "before you release" and tag a release on master.

The travis file uses two items to decide to deploy to sonatype/nexus:

* The branch is master
* There is a tag value

Pushing to master without a tag will result in a snapshot deployment, these can override each other.

The Java repository/build will have issues if you try to tag non-releases that have the same version number as an existing release. The gradle close and release process will fail if there is more than one repository staged. You may need to manually drop repositories from staging during testing on a single version number. These are in the sonatype UI under staging repositories and will start with io.nats.

If a release fails from travis, you can release manually, by clearing any staging repositories and following the steps below.

Also, keep in mind that repositories on sonatype are readonly so if you mess up, you may have to bump the release number just to try again.

## Manually Releasing

You can deploy manually by setting up your gradle.properties to have:

Expand All @@ -31,22 +40,35 @@ signing.secretKeyRingFile=<PATH TO THE KEYRING>
ossrhUsername=<YOUR_JIRA_USER_NAME>
ossrhPassword=<YOUR_JIRA_PASSWORD>
#local_archives=true
```

the last line, if uncommented, will cause the deploy to go to your build folder, so that you can manually check it. Once you have the properties set up, simple type

```bash
> export TRAVIS_BRANCH=master
> ./gradlew uploadArchives
> export TRAVIS_TAG=<version>
> ./gradlew publishToSonatype
```

to upload to the repo.
to upload to the repo. This will require you to go to sonatype to perform the actual close/release of your archive in the staging repositories tab. You can also perform the full release using:

## Automating the travis deploy
```bash
> export TRAVIS_BRANCH=master
> export TRAVIS_TAG=<version>
> ./gradlew publishToSonatype closeAndReleaseRepository
```

See [https://rishikeshdarandale.github.io/build/deploying-to-oss-sonatype-using-travis/](https://rishikeshdarandale.github.io/build/deploying-to-oss-sonatype-using-travis/) and [https://central.sonatype.org/pages/gradle.html](https://central.sonatype.org/pages/gradle.html)
## Manually Deploying a Snapshot

To deploy a snapshot you just want to have the branch and tag not set. So:

```bash
> ./gradlew publishToSonatype
```

You also don't need to close and release snapshots, and they can be written over.

## Automating the travis deploy and PGP

The global/secure values are used to deploy, they can be regenerated/created by someone with access to
the sonatype repository
Expand Down Expand Up @@ -81,30 +103,6 @@ Update the before install as instructed

NOTE - if your password has special characters to BASH - which may be required by sonatype, you need to escape them before you encrypt them. If you do not then bash will mess them up when Travis tries to set them.

## Releasing

### Using Gradle

I found the [gradle-nexus-staging-plugin](https://github.com/Codearte/gradle-nexus-staging-plugin/) which can release from staging.

From the readme, you can use the three tasks:

* closeRepository - closes an open repository with the uploaded artifacts. There should be just one open repository available in the staging profile (possible old/broken repositories can be dropped with Nexus GUI)
* releaseRepository - releases a closed repository (required to put artifacts to Maven Central aka The Central Repository)
* closeAndReleaseRepository - closes and releases a repository (an equivalent to closeRepository releaseRepository)

This last one will fail if the repo already exists using the specified version number

### Manual release

Once the uploadArchives completes, your artifact will be staged with Sonatype, but you need to verify it all looks good before it’s released from the staging area. To do this, you need to follow these steps:

1. Log into Sonatype Pro
2. Click “Staging Repositories” and scroll to the bottom of the list, look for ionats
3. Check the contents in the tab
4. Click “Close” at the top of the list
5. Click “Release”! at the top of the list

## The signing key

The key is encrypted into github using the above instructions. The public key was uploaded to a central site by exporting it:
Expand All @@ -122,4 +120,4 @@ then manually uploading at `http://keys.gnupg.net:11371/`. So that sonatype can
> gpg --keyserver pgp.mit.edu --send-keys <keyid>
```

The entire key process is very very painful, and seems to take time to propagate
The entire key process is very very painful, and seems to take time to propagate
6 changes: 3 additions & 3 deletions src/main/java/io/nats/client/Nats.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class Nats {
/**
* Current version of the library - {@value #CLIENT_VERSION}
*/
public static final String CLIENT_VERSION = "2.6.2";
public static final String CLIENT_VERSION = "2.6.3";

/**
* Current language of the library - {@value #CLIENT_LANGUAGE}
Expand All @@ -89,7 +89,7 @@ public class Nats {
*
* <p>If the connection fails, an IOException is thrown
*
* <p>See {@link connect(Options) connect(Options)} for more information on exceptions.
* <p>See {@link Nats#connect(Options) connect(Options)} for more information on exceptions.
*
* @throws IOException if a networking issue occurs
* @throws InterruptedException if the current thread is interrupted
Expand Down Expand Up @@ -119,7 +119,7 @@ public static Connection connect() throws IOException, InterruptedException {
*
* <p>If the connection fails, an IOException is thrown
*
* <p>See {@link connect(Options) connect(Options)} for more information on exceptions.
* <p>See {@link Nats#connect(Options) connect(Options)} for more information on exceptions.
*
* @param url the url of the server, ie. nats://localhost:4222
* @throws IOException if a networking issue occurs
Expand Down

0 comments on commit c54f54f

Please sign in to comment.