-
Notifications
You must be signed in to change notification settings - Fork 397
/
make_docs.sh
executable file
·57 lines (37 loc) · 1.26 KB
/
make_docs.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
#!/bin/bash
if [[ `git status --porcelain` ]]; then
# changes
>&2 echo "You have unstaged changes. Please commit before you run this."
exit 1
fi
# [email protected]:Blizzard/node-rdkafka.git
REPO=https://github.com/Blizzard/node-rdkafka.git
git remote add deploy $REPO
# Get the most recent stuff if we don't have it
git fetch deploy gh-pages || exit $?
make docs || exit $?
# Get package version and save to variable
PACKAGE=$(node -pe 'require("./package.json").name.split("/")[1]')
VERSION=$(node -pe 'require("./package.json").version')
# Make a temporary folder
TEMPDIR=$(mktemp -d)
VERSIONDIR="$TEMPDIR/$VERSION"
cp -r docs $VERSIONDIR
# Now, checkout the gh-pages, but first get current checked out branch
#
CURRENT_BRANCH=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)
COMMIT_MESSAGE=$(git log --pretty='format:%B' -1)
COMMIT_AUTHOR=$(git log --pretty='format:%aN <%aE>' -1)
if [[ `git checkout --quiet -b gh-pages deploy/gh-pages` ]]; then
>&2 echo "Could not checkout gh-pages"
exit 1
fi
rm -rf current
rm -rf $VERSION
cp -r $VERSIONDIR $VERSION
cp -r $VERSIONDIR current
git add --all
git commit --author="$COMMIT_AUTHOR" -m "Updated docs for '$COMMIT_MESSAGE'"
rm -rf $TEMPDIR
git push $REPO gh-pages || exit $?
git checkout $CURRENT_BRANCH