-
Notifications
You must be signed in to change notification settings - Fork 43
/
sphinx_to_gh_pages.sh
41 lines (36 loc) · 935 Bytes
/
sphinx_to_gh_pages.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
#!/bin/bash
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
buildDirectory=/tmp/_build
# get a clean master branch assuming
git checkout master
git pull origin master
git clean -df
git checkout -- .
git fetch --all
# build html docs from sphinx files
sphinx-apidoc -o . .
sphinx-build -b html . "$buildDirectory"
# create or use orphaned gh-pages branch
branch_name=gh-pages
if [ $(git branch --list "$branch_name") ]
then
git clean -d -fx .
git checkout $branch_name
git pull origin $branch_name
#git stash apply
# git checkout stash -- . # force git stash to overwrite added files
else
git checkout --orphan "$branch_name"
fi
if [ -d "$buildDirectory" ]
then
ls | grep -v _build | xargs rm -r
mv "$buildDirectory"/* . && rm -rf _build
git add .
git commit -m "new pages version $(date)"
git push origin $branch_name
else
echo "directory $buildDirectory does not exists"
fi