|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# This script will publish the aggregated javadocs found in the project's "target" directory. |
| 4 | +# The javadocs are committed and pushed to the git repository's gh-pages branch. |
| 5 | +# Be sure to customize this file to reflect your SDK project's settings (git url, |
| 6 | + |
| 7 | +# Avoid publishing javadocs for a PR build |
| 8 | +if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" ]; then |
| 9 | + |
| 10 | + printf "\n>>>>> Publishing javadoc for release build: repo=%s branch=%s build_num=%s job_num=%s\n" ${TRAVIS_REPO_SLUG} ${TRAVIS_BRANCH} ${TRAVIS_BUILD_NUMBER} ${TRAVIS_JOB_NUMBER} |
| 11 | + |
| 12 | + printf "\n>>>>> Cloning repository's gh-pages branch into directory 'gh-pages'\n" |
| 13 | + rm -fr ./gh-pages |
| 14 | + git clone --branch=gh-pages https://${GH_TOKEN}@github.com/watson-developer-cloud/java-sdk.git gh-pages > /dev/null |
| 15 | + |
| 16 | + printf "\n>>>>> Finished cloning...\n" |
| 17 | + |
| 18 | + |
| 19 | + pushd gh-pages |
| 20 | + |
| 21 | + # Create a new directory for this branch/tag and copy the aggregated javadocs there. |
| 22 | + printf "\n>>>>> Copying aggregated javadocs to new tagged-release directory: %s\n" ${TRAVIS_BRANCH} |
| 23 | + rm -rf docs/${TRAVIS_BRANCH} |
| 24 | + mkdir -p docs/${TRAVIS_BRANCH} |
| 25 | + cp -rf ../target/site/apidocs/* docs/${TRAVIS_BRANCH} |
| 26 | + |
| 27 | + printf "\n>>>>> Generating gh-pages index.html...\n" |
| 28 | + ../build/generateJavadocIndex.sh > index.html |
| 29 | + |
| 30 | + # Update the 'latest' symlink to point to this branch if it's a tagged release. |
| 31 | + if [ -n "$TRAVIS_TAG" ]; then |
| 32 | + pushd docs |
| 33 | + rm latest |
| 34 | + ln -s ./${TRAVIS_TAG} latest |
| 35 | + printf "\n>>>>> Updated 'docs/latest' symlink:\n" |
| 36 | + ls -l latest |
| 37 | + popd |
| 38 | + fi |
| 39 | + |
| 40 | + printf "\n>>>>> Committing new javadoc...\n" |
| 41 | + git add -f . |
| 42 | + git commit -m "Javadoc for release ${TRAVIS_TAG} (${TRAVIS_COMMIT})" |
| 43 | + git push -f origin gh-pages |
| 44 | + |
| 45 | + popd |
| 46 | + |
| 47 | + printf "\n>>>>> Published javadoc for release build: repo=%s branch=%s build_num=%s job_num=%s\n" ${TRAVIS_REPO_SLUG} ${TRAVIS_BRANCH} ${TRAVIS_BUILD_NUMBER} ${TRAVIS_JOB_NUMBER} |
| 48 | + |
| 49 | +else |
| 50 | + |
| 51 | + printf "\n>>>>> Javadoc publishing bypassed for non-release build: repo=%s branch=%s build_num=%s job_num=%s\n" ${TRAVIS_REPO_SLUG} ${TRAVIS_BRANCH} ${TRAVIS_BUILD_NUMBER} ${TRAVIS_JOB_NUMBER} |
| 52 | + |
| 53 | +fi |
0 commit comments