This repository has been archived by the owner on Feb 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
.travis.deploy.sh
54 lines (43 loc) · 1.63 KB
/
.travis.deploy.sh
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
#!/bin/bash
set -o errexit -o nounset
if [ "$TRAVIS_BRANCH" != "master" ]
then
echo "This commit was made against the $TRAVIS_BRANCH and not the master! No deploy!"
exit 0
fi
if [ -z "${GH_TOKEN}" ] ; then
echo "GH_TOKEN is not set. Exiting..."
exit 1
fi
[ "$TRAVIS_RUST_VERSION" = "stable" ] || exit 0
[ "$TRAVIS_PULL_REQUEST" = false ] || exit 0
rev=$(git rev-parse --short HEAD)
RELEASE="master"
CRATE_NAME="lockfreehashmap"
COMMIT_COMMENT="Update developer docs for commit ${rev}"
echo "Publishing documentation for $RELEASE"
if [ ! -d "target/doc/$CRATE_NAME" ]; then
echo "Cannot find target/doc/$CRATE_NAME"
exit 1
fi
git clone --depth=50 --branch=gh-pages "https://github.com/${TRAVIS_REPO_SLUG}.git" gh-pages
rm -Rf "gh-pages/${RELEASE}"
mkdir "gh-pages/${RELEASE}"
echo "<meta http-equiv=refresh content=0;url=${CRATE_NAME}/index.html>" > target/doc/index.html
cp -R target/doc/* "gh-pages/${RELEASE}/"
INDEX="gh-pages/index.html"
echo "<html><head><title>${TRAVIS_REPO_SLUG} API documentation</title></head><body>" > $INDEX
echo "<h1>API documentation for crate <a href='https://github.com/${TRAVIS_REPO_SLUG}'>${CRATE_NAME}</a></h1>" >> $INDEX
echo "<strong>Select a crate version :</strong><br/>" >> $INDEX
for entry in $(ls -1 gh-pages); do
[ -d "gh-pages/$entry" ] && echo "<a href='${entry}/index.html'>${entry}</a><br/>" >> $INDEX
done
echo "</body></html>" >> $INDEX
cd gh-pages || exit 1
git config user.name "travis-ci"
git config user.email "travis@travis-ci.org"
git add --all
git commit -m "$COMMIT_COMMENT"
git push -fq "https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git" gh-pages || exit 1
cd ..
rm -Rf "gh-pages"