1# see http://benlimmer.com/2013/12/26/automatically-publish-javadoc-to-gh-pages-with-travis-ci/ for details 2 3set -eu 4 5if [ "$TRAVIS_REPO_SLUG" == "google/dagger" ] && \ 6 [ "$TRAVIS_JDK_VERSION" == "$JDK_FOR_PUBLISHING" ] && \ 7 [ "$TRAVIS_PULL_REQUEST" == "false" ] && \ 8 [ "$TRAVIS_BRANCH" == "master" ]; then 9 echo -e "Publishing javadoc...\n" 10 bazel build //:user-docs.jar 11 JAVADOC_JAR="$(pwd)/bazel-bin/user-docs.jar" 12 13 cd $HOME 14 git clone --quiet --branch=gh-pages https://${GH_TOKEN}@github.com/google/dagger gh-pages > /dev/null 15 16 cd gh-pages 17 git config --global user.email "travis@travis-ci.org" 18 git config --global user.name "travis-ci" 19 git rm -rf api/latest 20 mkdir -p api 21 unzip "$JAVADOC_JAR" -d api/latest 22 rm -rf api/latest/META-INF/ 23 git add -f api/latest 24 git commit -m "Latest javadoc on successful travis build $TRAVIS_BUILD_NUMBER auto-pushed to gh-pages" 25 git push -fq origin gh-pages > /dev/null 26 27 echo -e "Published Javadoc to gh-pages.\n" 28else 29 echo -e "Not publishing docs for jdk=${TRAVIS_JDK_VERSION} and branch=${TRAVIS_BRANCH}" 30fi 31