From 741c510b91cd425127754e6f443011c5f16ef115 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Wed, 1 Jun 2016 15:30:15 +0200 Subject: [PATCH] TRAVIS: automatic gh-pages pushing --- .travis.yml | 8 ++++++++ update-gh-pages.sh | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 update-gh-pages.sh diff --git a/.travis.yml b/.travis.yml index 9aa357b..bec2f8d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,10 @@ matrix: allow_failures: - env: CABALVER=head GHCVER=head +env: + global: + - secure: q++z4DGwOHYjmed00oxMnGhBTzOBzKYunXvVcnCEmvmzW3qZERtXj3B7CLW4vRtmBlo3SiM0fb25NeYao+ByzTjo8jk9noiBVZvffwRmlKCeVwYx7T4/rsDhfV97k2JOeahBSgxWNuTkt+5gv07HpKdTiIxJsiv/QdBxQeq6/Ly6dyRskmCt+VuFvQg+cqPMugxIXtY6F7eZ1zgl/LxlamWjO3E4lX0Myf4o8+SU1HRDVkkVe+ytnRcVcYI2FHuFV/sSoDMTweXQToA9roVjOkfhq4rGlPCuXJkBPyZW2otLXgAV7I2kjwgxqmS5Yw752CcFjMMbG6R1u8sEAcGrJNKHfx8sKqBwI0AVoq4CJn+nKSElTDl0KI1mqazmazK4/mddkD9NGIVXCFmw4b+YGf1uDj8FAR94UmOiEFkEObGkQxG1XK/uzDaUJ1tO3MYXjPPEIE89BJORo+ZskmKFEoqbrBR/vEjbXxJHWP7SaaoM+mWpMiSssEFb/Z5mDBFPb2P/2f7nO4ZDfOYp/9hZdBvDaVM8FmTQfzF6jIUIOFmeeiSZWIBAHoDfdZDRrM/hC5JzqfMumW9frwllsQtYytkAsUqlNnCW86jlc5/5L6D8eY2NERFI2DRqrBi7bP2AfYXsozY0gMO1RL5+iQSQVKlPhk6IyAJYCWCYnrA+dz4= + before_install: - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH @@ -34,6 +38,7 @@ script: - cabal test - cabal check - cabal sdist + - cabal haddock --hyperlink-source --html-location=https://hackage.haskell.org/package/\$pkg-\$version/docs/ # check that the generated source-distribution can be built & installed - export SRC_TGZ=$(cabal info . | awk '{print $2 ".tar.gz";exit}') ; cd dist/; @@ -45,6 +50,9 @@ script: exit 1; fi +after_script: + - ./update-gh-pages.sh + notifications: email: - hasufell@posteo.de diff --git a/update-gh-pages.sh b/update-gh-pages.sh new file mode 100644 index 0000000..7d9df0c --- /dev/null +++ b/update-gh-pages.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +SOURCE_BRANCH="master" +TARGET_BRANCH="gh-pages" +REPO="https://${GH_TOKEN}@github.com/hasufell/hpath" +DOC_LOCATION="/dist/doc/html/hpath" + + +# Pull requests and commits to other branches shouldn't try to deploy, +# just build to verify +if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then + echo "Skipping docs deploy." + exit 0 +fi + + +cd "$HOME" +git config --global user.email "travis@travis-ci.org" +git config --global user.name "travis-ci" +git clone --branch=${TARGET_BRANCH} ${REPO} ${TARGET_BRANCH} || exit 1 + +# If there are no changes to the compiled out (e.g. this is a README update) +# then just bail. +if [ -z `git diff --exit-code` ]; then + echo "No changes to the output on this push; exiting." + exit 0 +fi + +# docs +cd ${TARGET_BRANCH} || exit 1 +echo "Removing old docs." +git rm -rf . +echo "Adding new docs." +cp -rf "${TRAVIS_BUILD_DIR}${DOC_LOCATION}"/* . || exit 1 +git add * + +if [[ -e ./index.html ]] ; then + echo "Commiting docs." + git commit -m "Lastest docs updated + +travis build: $TRAVIS_BUILD_NUMBER +commit: $TRAVIS_COMMIT +auto-pushed to gh-pages" + + git push origin $TARGET_BRANCH + echo "Published docs to gh-pages." +else + echo "Error docs are empty." + exit 1 +fi +