forked from Blizzard/node-rdkafka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_docs.sh
executable file
·47 lines (31 loc) · 1014 Bytes
/
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
#!/bin/bash
if [[ `git status --porcelain` ]]; then
# changes
>&2 echo "You have unstaged changes. Please commit before you run this."
exit 1
fi
make docs
# 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 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 checkout $CURRENT_BRANCH