forked from mikeric/rivets
-
Notifications
You must be signed in to change notification settings - Fork 14
/
doc.sh
executable file
·58 lines (46 loc) · 1.39 KB
/
doc.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
#!/usr/bin/env bash
set -e
STATUS=$(git status --porcelain 2>/dev/null)
BRANCH_NAME=$(git symbolic-ref HEAD 2>/dev/null)
BRANCH_NAME=${BRANCH_NAME##refs/heads/}
if [ -n "$STATUS" ]
then
echo "Dirty working tree; commit your changes then run me again." >&2
exit 1
fi
if [ -z "$MAIN_BRANCH" ]; then
MAIN_BRANCH="master"
fi
if [ "$BRANCH_NAME" != $MAIN_BRANCH ]
then
echo "Refusing to update documentation from non-main branch:" >&2
echo "expect branch $BRANCH_NAME == $MAIN_BRANCH" >&2
echo "If you want to view your rendered documentation run: " >&2
echo "" >&2
echo " harp server docs " >&2
echo "" >&2
exit 1
fi
# The docs should include the version when they build. At current it's just in
# the commit message.
export RIVETS_VERSION=$( \
grep 'version' package.json | \
awk -F'["]' '{print $4}' \
)
git checkout gh-pages 2>/dev/null 1>/dev/null
git checkout $MAIN_BRANCH -- docs 2>/dev/null
rm -rf _harp
mv docs _harp
harp compile _harp .
git add -A 2>/dev/null 1>/dev/null
set +e
git commit -a -m "Generate documentation for v$RIVETS_VERSION" 2>/dev/null 1>/dev/null
if [ $? -eq 0 ]
then
echo "documentation updated, publish via:" >&2
echo " git push origin gh-pages:gh-pages" >&2
else
echo "No changes to publish" >&2
fi
set -e
git checkout $MAIN_BRANCH 2>/dev/null 1>/dev/null