Skip to content

Commit

Permalink
Auto-deploy snapshots to Sonatype
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Reznik committed May 19, 2015
1 parent af3748f commit 33b77ef
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 39 deletions.
26 changes: 26 additions & 0 deletions .buildscript/deploy_snapshot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
#
# Deploy a jar, source jar, and javadoc jar to Sonatype's snapshot repo.
#
# Adapted from https://coderwall.com/p/9b_lfq and
# http://benlimmer.com/2013/12/26/automatically-publish-javadoc-to-gh-pages-with-travis-ci/

SLUG="contentful/contentful.java"
JDK="oraclejdk8"
BRANCH="master"

set -e

if [ "$TRAVIS_REPO_SLUG" != "$SLUG" ]; then
echo "Skipping snapshot deployment: wrong repository. Expected '$SLUG' but was '$TRAVIS_REPO_SLUG'."
elif [ "$TRAVIS_JDK_VERSION" != "$JDK" ]; then
echo "Skipping snapshot deployment: wrong JDK. Expected '$JDK' but was '$TRAVIS_JDK_VERSION'."
elif [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo "Skipping snapshot deployment: was pull request."
elif [ "$TRAVIS_BRANCH" != "$BRANCH" ]; then
echo "Skipping snapshot deployment: wrong branch. Expected '$BRANCH' but was '$TRAVIS_BRANCH'."
else
echo "Deploying snapshot..."
mvn clean source:jar javadoc:jar deploy --settings=".buildscript/settings.xml" -Dmaven.test.skip=true
echo "Snapshot deployed!"
fi
9 changes: 9 additions & 0 deletions .buildscript/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<settings>
<servers>
<server>
<id>sonatype-nexus-snapshots</id>
<username>${env.CI_DEPLOY_USERNAME}</username>
<password>${env.CI_DEPLOY_PASSWORD}</password>
</server>
</servers>
</settings>
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
.idea/
*.iml
target/
settings.xml
16 changes: 11 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
language: java
install: mvn install -DskipTests=true -Dgpg.skip=true
sudo: false

jdk:
- oraclejdk7
- oraclejdk8

after_success:
- .buildscript/deploy_snapshot.sh
- mvn clean cobertura:cobertura coveralls:report

env:
global:
- secure: ZkYu76rxDUUgoUSIz12CReNZHd2c5O2LBWCHnuQpqfJfcCXBr1J24F7WftiFXH+9Od43qHdF4hQ9Vy0vWEHSJ1hxZnCIy5yYsvqV4GJ94DIJhvNqmo48QPkA3tFUsqd48rEeBXMUsON30m89KDp1se2+l3UJaX+R27RUi47nraU=
- secure: jKXD1hYVgJypaQHRSm4gshxMhB+T+UibaLDLCSfGWSaGzogDsWnPXf9qqG3jtozKHyH0BkANaaO6rRgNQNfbaklm4jopL1bdRkd47JO/nibNwuVcG07TQyCPQR6jv/WoRAkxXOGdMSwwS2+puM7FJqLarbzY7uBEJtNsZn5JT48=

sudo: false

branches:
except:
- gh-pages

after_success:
- mvn clean cobertura:cobertura coveralls:report
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ or Gradle:
compile 'com.contentful.java:java-sdk:2.0.2'
```

Snapshots of the development version are available in [Sonatype's `snapshots` repository][snap].

The SDK requires at minimum Java 6 or Android 2.3.

### Default Client
Expand Down Expand Up @@ -212,3 +214,4 @@ Copyright (c) 2015 Contentful GmbH. See [LICENSE.txt][6] for further details.
[6]: LICENSE.txt
[7]: https://github.com/contentful/contentful.java/wiki/2.0-Migration
[8]: pom.xml
[snap]: https://oss.sonatype.org/content/repositories/snapshots/
65 changes: 32 additions & 33 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,40 +248,39 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>

<configuration>
<useAgent>true</useAgent>
</configuration>

<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>sonatype.oss.snapshots</id>
<name>Sonatype OSS Snapshot Repository</name>
<url>http://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<profiles>
<profile>
<id>release</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>

<configuration>
<useAgent>true</useAgent>
</configuration>

<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

0 comments on commit 33b77ef

Please sign in to comment.