Skip to content

Commit

Permalink
Auto-deploy snapshots from Travis CI to Sonatype.
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWharton committed Dec 20, 2014
1 parent a708dc0 commit c67000d
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 11 deletions.
24 changes: 24 additions & 0 deletions .buildscript/deploy_snapshot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/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="square/spoon"
JDK="oraclejdk8"
BRANCH="master"

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>
35 changes: 24 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
language: java
language: android

android:
components:
- build-tools-20.0.0
- android-16

jdk:
- oraclejdk7
- oraclejdk8

after_success:
- .buildscript/deploy_snapshot.sh

env:
global:
- secure: "GiRZ29ScIYHiKjsYAA6WG+q5O5UdaNl5lcT3EJRea4aFjnZ8ar0xEWkoFXyMNeKTcx/cq4Yi1cRrW7vMnUNhTOYLANKpEY+p2V9b9oK4FzYGj25h+LwoYpzcQr+RtdLciseyu7mSuAkiOR6Ijxy3whOtk/cR807+wcNe+KwR444="
- secure: "A8h+gO/vwQ+bkBoGopu6gJsAysVxL9o4NG1U43B+4rRMCSzwYX8PlVSPfhpuD+hTWgMucDujebNy9RXqpfdP6143W0m6qC2Y0MB5zgnT+3LjGRRctqkSAF42T2kGyXMldCDEYukn3wvJw6/6BlnNkacDfA4KK8RI8DOwa6zJ0Es="

branches:
excludes:
except:
- gh-pages

notifications:
email: false

before_install:
- wget http://dl.google.com/android/android-sdk_r21.0.1-linux.tgz
- tar -zxf android-sdk_r21.0.1-linux.tgz
- export ANDROID_HOME=~/builds/square/spoon/android-sdk-linux
- export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
- TOOLS=$(android list sdk --no-ui | grep "Android SDK Platform-tools" | cut -d"-" -f1)
- android update sdk --filter "$TOOLS" --no-ui --force
- SDK=$(android list sdk --no-ui | grep ", API 16," | cut -d"-" -f1)
- android update sdk --filter "$SDK" --no-ui --force
sudo: false

cache:
directories:
- $HOME/.m2
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ via Maven:
</dependency>
```

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



Execution
Expand Down Expand Up @@ -171,3 +173,5 @@ License

[1]: https://search.maven.org/remote_content?g=com.squareup.spoon&a=spoon-runner&v=LATEST&c=jar-with-dependencies
[2]: https://search.maven.org/remote_content?g=com.squareup.spoon&a=spoon-client&v=LATEST
[snap]: https://oss.sonatype.org/content/repositories/snapshots/

0 comments on commit c67000d

Please sign in to comment.