|
3 | 3 | # If running under travis-ci this will automatically deploy updates to the master branch's
|
4 | 4 | # documentation on build events for the master branch, and will add/update documentation for
|
5 | 5 | # any new/updated tags that are pushed.
|
6 |
| -# The script may also be used to manually deploy the current branch's documentation, |
7 |
| -# although for branch's other than master, index.html will likely need to be manually |
8 |
| -# edited to add an entry for the current branch. Also, this may be inadvisable, since the |
9 |
| -# the documentation can be published before the branch's code is published. Use it to add |
10 |
| -# new branch's development documentation, preferably immediately after pushing that branch |
11 |
| -# to github. |
12 |
| -set -ev # Echo what we're doing and fail on any errors |
13 |
| -if [ ! "$TRAVIS" ]; then #not on travis, try a sane deploy of current branch's documentation |
14 |
| - if [ "$(ls -A ./documentation)" ]; then #not empty |
15 |
| - REVISION="$(git rev-parse HEAD)" |
16 |
| - BRANCH="$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')" |
17 |
| - git clone --branch=gh-pages [email protected]:jacobwilliams/json-fortran.git gh-pages |
18 |
| - cd gh-pages |
19 |
| - [ -e "$BRANCH" ] && rm -r "$BRANCH" # wipe out old docs if they exist |
20 |
| - mkdir "$BRANCH" |
21 |
| - mkdir "$BRANCH/tests" |
22 |
| - mkdir "$BRANCH/tests/introspection" |
23 |
| - FILES=$(find ../documentation -name '*.*') #get all the files (including in subdirectories) |
24 |
| - for f in $FILES; do # add branch info to header and clean line endings |
25 |
| - sed '/[^#]robo_top_of_doc/ s;jsonfortran</a>;jsonfortran '"$BRANCH"'</a>;' $f | sed 's/ *$//' > "$BRANCH/${f##*documentation/}" |
26 |
| - done |
27 |
| - git add "$BRANCH" |
28 |
| - git commit -m "Development documentation for $BRANCH updated for commit $REVISION" |
29 |
| - if egrep "\<${BRANCH}\>" index.html >/dev/null 2>&1 ; then |
30 |
| - echo "It appears that index.html knows about branch $BRANCH and likely does not require updating." |
31 |
| - git push origin gh-pages # assumes write access to jacobwilliams/json-fortran... |
32 |
| - # only true for @jacobwilliams |
33 |
| - else |
34 |
| - echo "index.html must be manually edited to add link to branch $BRANCH, then commit the changes and push manually." |
35 |
| - fi |
36 |
| - fi |
37 |
| -else #running under travis |
| 6 | +if [ "$TRAVIS" ]; then #running under travis |
38 | 7 | if $TRAVIS_SECURE_ENV_VARS ; then
|
39 | 8 | # only try to update master's development documentation
|
40 |
| - if [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$(ls -A $TRAVIS_BUILD_DIR/documentation)" ] ; then #not empty |
| 9 | + if [ "$TRAVIS_BRANCH" = "master" ] && \ |
| 10 | + [ "$TRAVIS_PULL_REQUEST" = "false" ] && \ |
| 11 | + [ "$(ls -A $TRAVIS_BUILD_DIR/doc)" ] ; then #not empty |
41 | 12 | git clone --branch=gh-pages https://${GH_TOKEN}@github.com/$TRAVIS_REPO_SLUG gh-pages
|
42 | 13 | cd gh-pages
|
43 |
| - [ -e master ] && rm -r master # wipe out docs if they exist |
44 |
| - mkdir master |
45 |
| - mkdir master/tests |
46 |
| - mkdir master/tests/introspection |
47 |
| - FILES=$(find ../documentation -name '*.*') #get all the files (including in subdirectories) |
48 |
| - for f in $FILES; do # add branch info to header and clean line endings |
49 |
| - sed '/[^#]robo_top_of_doc/ s;jsonfortran</a>;jsonfortran master</a>;' $f | sed 's/ *$//' > master/${f##*documentation/} |
50 |
| - done |
51 |
| - git add master |
| 14 | + rm -r css favicon.png fonts index.html interface js lists media module page proc \ |
| 15 | + program search.html sourcefile src tipuesearch type |
| 16 | + cp -r "$TRAVIS_BUILD_DIR"/doc/* . |
| 17 | + git add -A # Add all the new files |
52 | 18 | git commit -m "Development documentation updated by travis job $TRAVIS_JOB_NUMBER for commits $TRAVIS_COMMIT_RANGE"
|
53 | 19 | git push origin gh-pages
|
54 | 20 | fi
|
55 | 21 | # If publishing a new/updated tag, deploy it's documentation
|
56 |
| - if [ "$TRAVIS_TAG" ] && [ "$(ls -A $TRAVIS_BUILD_DIR/documentation)" ] ; then #not empty |
| 22 | + if [ "$TRAVIS_TAG" ] && [ "$(ls -A $TRAVIS_BUILD_DIR/doc)" ] ; then #not empty |
| 23 | + cd "$TRAVIS_BUILD_DIR" |
57 | 24 | git clone --branch=gh-pages https://${GH_TOKEN}@github.com/$TRAVIS_REPO_SLUG gh-pages
|
| 25 | + sed "1 s/^/version: ${TRAVIS_TAG}\n/" json-fortran.md > json-fortran.tagged.md |
| 26 | + # rebuild FORD documentation without pages, with version info, wiping out any existing tag folder |
| 27 | + ford -o "gh-pages/$TRAVIS_TAG" json-fortran.tagged.md |
58 | 28 | cd gh-pages
|
59 |
| - [ -e "$TRAVIS_TAG" ] && rm -r "$TRAVIS_TAG" # wipe out existing docs for tag if they exist |
60 |
| - mkdir "$TRAVIS_TAG" |
61 |
| - mkdir "$TRAVIS_TAG/tests" |
62 |
| - mkdir "$TRAVIS_TAG/tests/introspection" |
63 |
| - # Add an entry in index.html for the new tag, assume none exists |
64 |
| - awk '/<!--Next stable release goes here-->/{print "<a href=\"./'"$TRAVIS_TAG"'/json_module_F90.html\" class=\"indexitem\" >'"$TRAVIS_TAG"'</a>"}1' index.html > index2.html && mv index2.html index.html |
65 |
| - FILES=$(find ../documentation -name '*.*') #get all the files (including in subdirectories) |
66 |
| - for f in $FILES; do # add tag info to headers and clean line endings |
67 |
| - sed '/[^#]robo_top_of_doc/ s;jsonfortran</a>;jsonfortran '"$TRAVIS_TAG"'</a>;' $f | sed 's/ *$//' > "$TRAVIS_TAG/${f##*documentation/}" |
68 |
| - done |
69 |
| - git add "$TRAVIS_TAG" index.html # don't forget to add the top level index! |
| 29 | + git add -A # add all new files in $TRAVIS_TAG/ |
70 | 30 | git commit -m "Tag/release documentation updated by travis job $TRAVIS_JOB_NUMBER for tag $TRAVIS_TAG $TRAVIS_COMMIT"
|
71 | 31 | git push origin gh-pages
|
72 | 32 | fi
|
|
0 commit comments