-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish-javadocs.sh
executable file
·63 lines (45 loc) · 1.45 KB
/
publish-javadocs.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
63
#!/bin/bash
set -e
LOCAL_CLONE_DIR="temp/gh-pages"
JAVA_DOC_LOCATION="printer-driver-api/build/docs/javadoc/"
function exit_with_error {
echo "ERROR: $2"
exit $1
}
if [ ! -d $JAVA_DOC_LOCATION ]; then
exit_with_error 1 "Javadocs have not been built!"
fi
echo "Checking for on master branch"
if [ ${CIRCLE_BRANCH=local} != "master" ]; then
exit_with_error 1 "Not on master branch"
fi
remote=$(git config remote.origin.url)
rm -f -r $LOCAL_CLONE_DIR
mkdir -p $LOCAL_CLONE_DIR
cd $LOCAL_CLONE_DIR
git config --global user.name "CircleCI" > /dev/null 2>&1
git config --global user.email "brett@annalytics.co.uk" > /dev/null 2>&1
git init
echo "Get gh-pages from remote"
git remote add --fetch origin "$remote"
# switch into the the gh-pages branch
if git rev-parse --verify origin/gh-pages > /dev/null 2>&1
then
git checkout gh-pages
# delete any old site as we are going to replace it
rm -f -r *
else
git checkout --orphan gh-pages
fi
echo "Copy in latest javadocs"
cp -r ../../$JAVA_DOC_LOCATION javadoc/
echo "Commit and push javadoc to gh-pages"
# stage any changes and new files
git add -A
# now commit, ignoring branch gh-pages doesn't seem to work, so trying skip
git commit --allow-empty -m "Deploy to GitHub pages [ci skip]"
# and push, but send any output to /dev/null to hide anything sensitive
git push --force --quiet origin gh-pages
cd ../..
rm -rf $LOCAL_CLONE_DIR
echo "Finished - javadoc docs automatically updated"