forked from brendanhay/amazonka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtravis-documentation
executable file
·80 lines (59 loc) · 1.99 KB
/
travis-documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env bash
set -e
if [ "$TRAVIS_BRANCH" != "develop" ]; then
echo "Ignoring documentation build for branch '$TRAVIS_BRANCH'."
exit 0
fi
if [ -z "$DOC_TOKEN" ]; then
echo "Ignoring documentation build due to missing token."
exit 0
fi
DOC_REF=github.com/brendanhay/amazonka-doc.git
GHCVER=${GHCVER?"GHCVER needs to be set."}
BUILD_ID=${TRAVIS_BUILD_ID?"TRAVIS_BUILD_ID needs to be set."}
BUILD_NUMBER=${TRAVIS_BUILD_NUMBER?"TRAVIS_BUILD_NUMBER needs to be set."}
path=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
output=doc
platform=x86_64-linux
resolver=$(sed -n 's/^resolver: *\(.*\)$/\1/p' stack-$GHCVER.yaml)
echo "Using resolver ${resolver}"
databases=( $(stack --stack-yaml stack-$GHCVER.yaml path | sed -n 's/^.*-pkg-db: *\(.*\)$/\1/p') )
databases=( "${databases[@]/#/--package-db }" )
echo "Using resolver ${resolver}"
echo "Using databases ${databases[@]}"
$path/travis-timeout \
stack --no-terminal --skip-ghc-check --stack-yaml stack-$GHCVER.yaml install \
standalone-haddock \
hscolour
$path/travis-timeout \
stack --no-terminal --skip-ghc-check --stack-yaml stack-$GHCVER.yaml build \
amazonka-core amazonka amazonka-s3-encryption
$path/travis-timeout \
standalone-haddock --hyperlink-source -o $output \
${databases[@]} \
core amazonka*
{
cat <<-HTML
<!DOCTYPE html>
<h2>Amazonka Library Documentation</h2>
<h4>Build <a href="https://travis-ci.org/brendanhay/amazonka/builds/${BUILD_ID}">#${BUILD_NUMBER}</a>, GHC ${GHCVER}</h4>
<ul>
HTML
for dir in $(ls -d $output/*/); do
file=$(basename $dir)
cat <<-HTML
<li><a href="${file}/index.html">${file}</a></li>
HTML
done
cat <<-HTML
</ul>
HTML
} > $output/index.html
set -x
cd $output
git init
git config user.name "Brendan Hay"
git config user.email "[email protected]"
git add .
git commit -m "Travis CI documentation deploy $BUILD_NUMBER"
git push --force --quiet "https://${DOC_TOKEN}@${DOC_REF}" master:gh-pages > /dev/null 2>&1