Skip to content

Commit

Permalink
fix #121: Improved scripts for snapshot deployment & auto-javadoc pub…
Browse files Browse the repository at this point in the history
…lication.

Also, openjdk7 and oraclejdk8 were removed from travis.yml to speedup builds
  • Loading branch information
pablormier committed Aug 27, 2015
1 parent b877615 commit 1f1ca4d
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 87 deletions.
14 changes: 6 additions & 8 deletions .config/deploy-artifacts.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

echo "Auto-deploying Hipster4j snapshots..."
echo "Current branch: $TRAVIS_BRANCH"

if [ "$TRAVIS_REPO_SLUG" == "citiususc/hipster" ] && [ "$TRAVIS_JDK_VERSION" == "oraclejdk7" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
echo "Running mvn deploy, current directory: `pwd`"
# Deploy to Sonatype Nexus OSS
mvn --settings .config/maven-settings.xml -P sonatype-nexus-snapshots deploy -DskipTests=true
else
echo "Skipping deployment for this build..."
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo "Skipping snapshot deployment for pull request"
exit
fi

echo "Running mvn deploy, current directory: `pwd`"
# Deploy to Sonatype Nexus OSS
mvn --settings .config/maven-settings.xml -P sonatype-nexus-snapshots deploy -DskipTests=true
echo "Deployment script finished."
74 changes: 0 additions & 74 deletions .config/deploy-site.sh

This file was deleted.

58 changes: 58 additions & 0 deletions .config/publish-javadocs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo "Skipping Javadoc publication for pull request"
exit
fi

if [ "$TRAVIS_TAG" == "" ]; then
echo "Current version is not a release, skipping Javadoc publication"
exit
fi

echo "Auto publishing latest javadocs..."
echo "TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG - TRAVIS_JDK_VERSION=$TRAVIS_JDK_VERSION - TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST"

# Decide the documentation version folder name depending on the branch and the version in the pom.xml
VERSION=`grep -m 1 "<hipster.version>" pom.xml | cut -d ">" -f 2 | cut -d "<" -f 1`

# Validate if the version is correct (example 1.0.0-SNAPSHOT, or 1.0.0-alpha-1)
VERSION_REGEX='^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9_]+(-[0-9]+)?)?$'
if [[ $VERSION =~ $VERSION_REGEX ]]; then
echo "Current version is $VERSION"
else
echo "Version error. Unrecognized version $VERSION"
exit 1
fi

echo "Deploying Hipster [$VERSION] javadocs to GitHub gh-pages"
echo "Current directory is: `pwd`"

echo "Building javadocs..."
# Generate Javadocs in target/apidocs
mvn javadoc:aggregate

# Clone Hipster4j GitHub gh-pages for Javadocs
git clone --quiet --branch=gh-pages https://github.com/citiususc/hipster.git gh-pages > /dev/null

# Overwrite the previous version with the new one
cp -Rf target/apidocs/* gh-pages/

# Create a new folder with the version number and copy the latest version to it
mkdir gh-pages/$VERSION
cp -Rf target/apidocs/* gh-pages/$VERSION/

# Now prepare for uploading the site to gh-pages
cd gh-pages

# Config git user and credentials
git config --global user.email "[email protected]"
git config --global user.name "travis-ci"
git config credential.helper "store --file=.git/credentials"
echo "https://${GITHUB_TOKEN}:@github.com" > .git/credentials

git add -A
git commit -a -m "auto-commit $TRAVIS_BRANCH Hipster4j Javadocs v$VERSION (build $TRAVIS_BUILD_NUMBER)"
git push -q origin gh-pages > /dev/null
echo "Finished"

6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
language: java
jdk:
- oraclejdk7
- oraclejdk8
- openjdk7
branches:
except:
- /^(?i:wip).*$/
sudo: false
after_success:
#- chmod +x .config/deploy-site.sh
#- .config/deploy-site.sh
- chmod +x .config/deploy-artifacts.sh
- .config/deploy-artifacts.sh
- .config/publish-javadocs.sh
- mvn clean cobertura:cobertura coveralls:report
env:
global:
Expand Down

0 comments on commit 1f1ca4d

Please sign in to comment.