Skip to content

Commit d70d8ca

Browse files
committed
Updated deploy.sh to work with FORD docs
1 parent 861dcad commit d70d8ca

File tree

2 files changed

+19
-56
lines changed

2 files changed

+19
-56
lines changed

.travis.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,17 @@ env:
3434
- >
3535
BUILD_SCRIPT="mkdir cmake-build &&
3636
cd cmake-build &&
37-
cmake -DCMAKE_BUILD_TYPE=COVERAGE .. &&
37+
cmake .. &&
3838
make -j 4 check"
39+
CODE_COVERAGE="no"
40+
DEPLOY_DOCUMENTATION="no"
3941
4042
# build with build.sh, make documentation, run unit tests and perform coverage analysis
4143
- >
4244
BUILD_SCRIPT="./build.sh --coverage --skip-documentation &&
4345
./build.sh --coverage --enable-unicode"
4446
CODE_COVERAGE="yes"
47+
DEPLOY_DOCUMENTATION="yes"
4548
4649
install:
4750
- |
@@ -89,7 +92,7 @@ after_success:
8992
- cd $TRAVIS_BUILD_DIR
9093
- git config --global user.name "TRAVIS-CI-for-$(git --no-pager show -s --format='%cn' $TRAVIS_COMMIT)"
9194
- git config --global user.email "$(git --no-pager show -s --format='%ce' $TRAVIS_COMMIT)"
92-
#broken for now# - ./deploy.sh #handles updating documentation for master branch as well as tags
95+
- [[ $DEPLOY_DOCUMENTATION == [yY]* ]] && ./deploy.sh #publish docs for master branch and tags
9396
- (yes | rm -r doc gh-pages) || true # wipe out doc dirs to avoid confusing codecov
9497
- |
9598
if [[ $CODE_COVERAGE == [yY]* ]]; then

deploy.sh

Lines changed: 14 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,70 +3,30 @@
33
# If running under travis-ci this will automatically deploy updates to the master branch's
44
# documentation on build events for the master branch, and will add/update documentation for
55
# 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
387
if $TRAVIS_SECURE_ENV_VARS ; then
398
# 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
4112
git clone --branch=gh-pages https://${GH_TOKEN}@github.com/$TRAVIS_REPO_SLUG gh-pages
4213
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
5218
git commit -m "Development documentation updated by travis job $TRAVIS_JOB_NUMBER for commits $TRAVIS_COMMIT_RANGE"
5319
git push origin gh-pages
5420
fi
5521
# 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"
5724
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
5828
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/
7030
git commit -m "Tag/release documentation updated by travis job $TRAVIS_JOB_NUMBER for tag $TRAVIS_TAG $TRAVIS_COMMIT"
7131
git push origin gh-pages
7232
fi

0 commit comments

Comments
 (0)