-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpublish.sh
executable file
·62 lines (51 loc) · 1.28 KB
/
publish.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
55
56
57
58
59
60
61
62
#! /bin/bash
set -e
rootdir=$(cd $(dirname "$0") && pwd)
workdir="$rootdir/gh-pages"
origin=$(git config --get "remote.origin.url")
user_name=$(git config --get "user.name")
user_email=$(git config --get "user.email")
fail() {
echo "FATAL ERROR:" "$@"
exit 1
}
set_user() {
git config --local --replace-all "user.name" "$user_name"
git config --local --replace-all "user.email" "$user_email"
}
init() {
rm -rf $workdir
git clone -q "$origin" $workdir
pushd $workdir
git checkout --orphan gh-pages
git rm -rf .
set_user
echo >.nojekyll "Sphinx generated"
git add .nojekyll
git commit -a -m 'Initialized by publish init'
git push origin gh-pages
popd
}
publish() {
set -x
rm -rf $workdir
mkdir $workdir
htmldir="$rootdir/build/html"
test ! -d "$htmldir" || rm -rf "$htmldir"
doc/Makefile html
pushd $workdir
git init
set_user
git remote add -t gh-pages -f origin "$origin"
git checkout gh-pages
cp -frpl "$htmldir"/{,.}??* .
git add .
# Push it!
git status
git commit -m 'Docs published'
git push origin gh-pages
git status
popd
}
which sphinx-build >/dev/null || fail "'sphinx-build' not found, need to activate a virtualenv?"
test "$1" == "init" && init || publish