-
Notifications
You must be signed in to change notification settings - Fork 7.6k
/
Copy pathpush_javadoc.sh
134 lines (104 loc) · 3.44 KB
/
push_javadoc.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
# ----------------------------------------------------------
# Automatically push back the generated JavaDocs to gh-pages
# ----------------------------------------------------------
# based on https://gist.github.com/willprice/e07efd73fb7f13f917ea
# specify the common address for the repository
targetRepo=github.com/ReactiveX/RxJava.git
# =======================================================================
# only for main pushes, for now
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo -e "Pull request detected, skipping JavaDocs pushback."
exit 0
fi
# only when on the 3.x branch and not tagged
if [ "$TRAVIS_BRANCH" != "3.x" ] && [ "$TRAVIS_TAG" == "" ]; then
echo -e "On a secondary branch '$TRAVIS_BRANCH', skipping JavaDocs pushback."
exit 0
fi
# get the current build tag if any
buildTag="$TRAVIS_TAG"
echo -e "Travis tag: '$buildTag'"
if [ "$buildTag" == "" ]; then
buildTag="snapshot"
else
buildTag="${buildTag:1}"
fi
echo -e "JavaDocs pushback for tag: $buildTag"
# check if the token is actually there
if [ "$GITHUB_TOKEN" == "" ]; then
echo -e "No access to GitHub, skipping JavaDocs pushback."
exit 0
fi
# prepare the git information
git config --global user.email "travis@travis-ci.org"
git config --global user.name "Travis CI"
# setup the remote
echo -e "Adding the target repository to git"
git remote add origin-pages https://${GITHUB_TOKEN}@${targetRepo} > /dev/null 2>&1
# stash changes due to chmod
echo -e "Stashing any local non-ignored changes"
git stash
# get the gh-pages
echo -e "Update branches and checking out gh-pages"
git fetch --all
git branch -a
git checkout -b gh-pages origin-pages/gh-pages
# releases should update 2 extra locations
if [ "$buildTag" != "snapshot" ]; then
# for releases, add a new directory with the new version
# and carefully replace the others
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# enable once 3.x is mainstream
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvv
# 1.) main javadoc
# ----------------
# remove the io subdir
#echo -e "Removing javadoc/io"
#rm -r javadoc/io
# remove the html files
#echo -e "Removing javadoc/*.html"
#rm javadoc/*.html
# copy the new doc
#echo -e "Copying to javadoc/"
#yes | cp -rf ./build/docs/javadoc/ .
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# enable once 3.x is mainstream
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# 2.) 3.x javadoc
# remove the io subdir
echo -e "Removing 3.x/javadoc/io"
rm -r 3.x/javadoc/io
# remove the html files
echo -e "Removing 3.x/javadoc/*.html"
rm 3.x/javadoc/*.html
# copy the new doc
echo -e "Copying to 3.x/javadoc/"
yes | cp -rf ./build/docs/javadoc/ 3.x/
fi
# 3.) create a version/snapshot specific copy of the docs
# clear the existing tag
echo -e "Removing to 3.x/javadoc/${buildTag}"
rm -r 3.x/javadoc/${buildTag}
# copy the new doc
echo -e "Copying to 3.x/javadoc/${buildTag}"
yes | cp -rf ./build/docs/javadoc/ 3.x/javadoc/${buildTag}/
# stage all changed and new files
echo -e "Staging new files"
git add *.html
git add *.css
git add *.js
git add *package-list*
# remove tracked but deleted files
echo -e "Removing deleted files"
git add -u
# commit all
echo -e "commit Travis build: $TRAVIS_BUILD_NUMBER for $buildTag"
git commit --message "Travis build: $TRAVIS_BUILD_NUMBER for $buildTag"
# debug file list
#find -name "*.html"
# push it
echo -e "Pushing back changes."
git push --quiet --set-upstream origin-pages gh-pages
# we are done
echo -e "JavaDocs pushback complete."