on eaec028 help sign in
gogol/script/travis-documentation
80 lines 2.0 kB history raw
1#!/usr/bin/env bash
3set -e
5if [ "$TRAVIS_BRANCH" != "develop" ]; then
6 echo "Ignoring documentation build for branch '$TRAVIS_BRANCH'."
7 exit 0
8fi
10if [ -z "$DOC_TOKEN" ]; then
11 echo "Ignoring documentation build due to missing token."
12 exit 0
13fi
15DOC_REF=github.com/brendanhay/gogol-doc.git
16GHCVER=${GHCVER?"GHCVER needs to be set."}
17BUILD_ID=${TRAVIS_BUILD_ID?"TRAVIS_BUILD_ID needs to be set."}
18BUILD_NUMBER=${TRAVIS_BUILD_NUMBER?"TRAVIS_BUILD_NUMBER needs to be set."}
20path=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
22output=doc
23platform=x86_64-linux
24resolver=$(sed -n 's/^resolver: *\(.*\)$/\1/p' stack-$GHCVER.yaml)
26echo "Using resolver ${resolver}"
28databases=( $(stack --stack-yaml stack-$GHCVER.yaml path | sed -n 's/^.*-pkg-db: *\(.*\)$/\1/p') )
29databases=( "${databases[@]/#/--package-db }" )
31echo "Using resolver ${resolver}"
32echo "Using databases ${databases[@]}"
34$path/travis-timeout \
35 stack --no-terminal --skip-ghc-check --stack-yaml stack-$GHCVER.yaml install \
36 standalone-haddock \
37 hscolour
39$path/travis-timeout \
40 stack --no-terminal --skip-ghc-check --stack-yaml stack-$GHCVER.yaml build \
41 gogol-core gogol
43$path/travis-timeout \
44 standalone-haddock --hyperlink-source -o $output \
45 ${databases[@]} \
46 core gogol*
49 cat <<-HTML
50 <!DOCTYPE html>
51 <h2>Gogol Library Documentation</h2>
52 <h4>Build <a href="https://travis-ci.org/brendanhay/gogol/builds/${BUILD_ID}">#${BUILD_NUMBER}</a>, GHC ${GHCVER}</h4>
53 <ul>
54HTML
56 for dir in $(ls -d $output/*/); do
57 file=$(basename $dir)
58 cat <<-HTML
59 <li><a href="${file}/index.html">${file}</a></li>
60HTML
61 done
63 cat <<-HTML
64 </ul>
65HTML
66} > $output/index.html
68set -x
70cd $output
72git init
74git config user.name "Brendan Hay"
75git config user.email "brendan.g.hay@gmail.com"
77git add .
78git commit -m "Travis CI documentation deploy $BUILD_NUMBER"
80git push --force --quiet "https://${DOC_TOKEN}@${DOC_REF}" master:gh-pages > /dev/null 2>&1