Skip to content

Commit 3caa227

Browse files
committed
Auto-deploy documentation
- deploy.sh script handles deploying: - updated development documentation - new tag/release documentation - when run outside tavis-ci, this will attempt to update development documentation for current branch - .travis.yml fixes - robodoc wasn't working, and the build/install was SLOW - found a .deb package to download and install instead, seems faster and works - cleaned up if statements
1 parent 8ab6a32 commit 3caa227

File tree

3 files changed

+80
-23
lines changed

3 files changed

+80
-23
lines changed

.travis.yml

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cache: apt
88
# Build matrix: Run the three build systems and tests in parallel
99
env:
1010
global:
11-
- DEPENDS=gfortran-4.9
11+
- DEPENDS="gfortran-4.9"
1212
matrix:
1313
# CMake build with unit tests, no documentation
1414
# Allow to fail for now until tests are fixed
@@ -33,34 +33,25 @@ env:
3333
FoBiS="no"
3434

3535
before_install:
36+
- if [[ $DOCS == [yY]* ]]; then export DEPENDS="$DEPENDS exuberant-ctags"; fi
3637
- sudo apt-add-repository -y ppa:ubuntu-toolchain-r/test
37-
- ([[ $SPECIFIC_DEPENDS == *cmake* ]] &&
38-
sudo apt-add-repository -y ppa:kalakris/cmake) ||
39-
[[ $SPECIFIC_DEPENDS != *cmake* ]]
40-
- ([[ $JLINT == [yY]* ]] &&
41-
curl -sL https://deb.nodesource.com/setup | sudo bash - ) ||
42-
([[ $JLINT != [yY]* ]] && sudo apt-get update -qq)
43-
- ([[ $DOCS == [yY]* ]] &&
44-
wget http://rfsber.home.xs4all.nl/Robo/robodoc-4.99.41.tar.gz) ||
45-
[[ $DOCS != [yY]* ]]
38+
- if [[ $SPECIFIC_DEPENDS == *cmake* ]]; then sudo apt-add-repository -y ppa:kalakris/cmake; fi
39+
- if [[ $JLINT == [yY]* ]]; then curl -sL https://deb.nodesource.com/setup | sudo bash -; else sudo apt-get update -qq; fi
40+
- if [[ $DOCS == [yY]* ]]; then wget http://launchpadlibrarian.net/70968359/robodoc_4.99.41-1_amd64.deb; fi
4641

4742
install:
4843
- sudo apt-get install -y $SPECIFIC_DEPENDS $DEPENDS
49-
- ([[ $JLINT == [yY]* ]] &&
50-
sudo npm install -g jsonlint)
51-
|| [[ $JLINT != [yY]* ]]
44+
- if [[ $JLINT == [yY]* ]]; then sudo npm install -g jsonlint; fi
5245
- sudo ln -fs /usr/bin/gfortran-4.9 /usr/bin/gfortran && gfortran --version
53-
- ([[ $FoBiS == [yY]* ]] &&
54-
sudo pip install FoBiS.py && FoBiS.py --version) ||
55-
[[ $FoBiS != [yY]* ]]
56-
- ([[ $DOCS == [yY]* ]] &&
57-
tar -xzvf robodoc-4.99.41.tar.gz &&
58-
cd robodoc-4.99.41 &&
59-
./configure && make -j 3 && cd $TRAVIS_BUILD_DIR &&
60-
export PATH="$TRAVIS_BUILD_DIR/robodoc-4.99.41/Source:$PATH") ||
61-
[[ $DOCS != [yY]* ]]
62-
46+
- if [[ $FoBiS == [yY]* ]]; then sudo -H pip install FoBiS.py && FoBiS.py --version; fi
47+
- if [[ $DOCS == [yY]* ]]; then sudo dpkg -i robodoc_4.99.41-1_amd64.deb && robodoc --version; fi
6348

6449
script:
6550
- echo $BUILD_SCRIPT
6651
- echo $BUILD_SCRIPT | bash -
52+
53+
after_success:
54+
- cd $TRAVIS_BUILD_DIR
55+
- git config --global user.name "TRAVIS-CI-for-$(git --no-pager show -s --format='%cn' $TRAVIS_COMMIT)"
56+
- git config --global user.email "$(git --no-pager show -s --format='%ce' $TRAVIS_COMMIT)"
57+
- ./deploy.sh #handles updating documentation for master branch as well as tags

build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#
1212

1313
# Set to 1 to use ifort, otherwise use gfortran
14+
set -e
1415
use_ifort=0
1516

1617
PROJECTNAME='jsonfortran' # project name for robodoc (example: jsonfortran_2.0.0)

deploy.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
# Script to deploy documentation after successfull build of master branch or tag
3+
# If running under travis-ci this will automatically deploy updates to the master branch's
4+
# documentation on build events for the master branch, and will add/update documentation for
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+
for f in ../documentation/*.*; do # add branch info to header and clean line endings
22+
sed '/[^#]robo_top_of_doc/ s;jsonfortran</a>;jsonfortran '"$BRANCH"'</a>;' $f | sed 's/ *$//' > "$BRANCH/${f##*/}"
23+
done
24+
git add "$BRANCH"
25+
git commit -m "Development documentation for $BRANCH updated for commit $REVISION"
26+
if egrep "\<${BRANCH}\>" index.html >/dev/null 2>&1 ; then
27+
echo "It appears that index.html knows about branch $BRANCH and likely does not require updating."
28+
git push origin gh-pages # assumes write access to jacobwilliams/json-fortran...
29+
# only true for @jacobwilliams
30+
else
31+
echo "index.html must be manually edited to add link to branch $BRANCH, then commit the changes and push manually."
32+
fi
33+
fi
34+
else #running under travis
35+
if $TRAVIS_SECURE_ENV_VARS ; then
36+
# only try to update master's development documentation
37+
if [ "$TRAVIS_BRANCH" = "master" ] && [ "$(ls -A $TRAVIS_BUILD_DIR/documentation)" ] ; then #not empty
38+
git clone --branch=gh-pages https://${GH_TOKEN}@github.com/$TRAVIS_REPO_SLUG gh-pages
39+
cd gh-pages
40+
[ -e master ] && rm -r master # wipe out docs if they exist
41+
mkdir master
42+
for f in ../documentation/*.*; do # add branch info to header and clean line endings
43+
sed '/[^#]robo_top_of_doc/ s;jsonfortran</a>;jsonfortran master</a>;' $f | sed 's/ *$//' > master/${f##*/}
44+
done
45+
git add master
46+
git commit -m "Development documentation updated by travis job $TRAVIS_JOB_NUMBER for commits $TRAVIS_COMMIT_RANGE"
47+
git push origin gh-pages
48+
fi
49+
# If publishing a new/updated tag, deploy it's documentation
50+
if [ "$TRAVIS_TAG" ] && [ "$(ls -A $TRAVIS_BUILD_DIR/documentation)" ] ; then #not empty
51+
git clone --branch=gh-pages https://${GH_TOKEN}@github.com/$TRAVIS_REPO_SLUG gh-pages
52+
cd gh-pages
53+
[ -e "$TRAVIS_TAG" ] && rm -r "$TRAVIS_TAG" # wipe out existing docs for tag if they exist
54+
mkdir "$TRAVIS_TAG"
55+
# Add an entry in index.html for the new tag, assume none exists
56+
awk '/<!--Next stable release goes here-->/{print "<a href=\"./'"$TRAVIS_TAG"'/masterindex.html\" class=\"indexitem\" >'"$TRAVIS_TAG"'</a>"}1' index.html > index2.html && mv index2.html index.html
57+
for f in ../documentation/*.*; do # add tag info to headers and clean line endings
58+
sed '/[^#]robo_top_of_doc/ s;jsonfortran</a>;jsonfortran '"$TRAVIS_TAG"'</a>;' $f | sed 's/ *$//' > "$TRAVIS_TAG/${f##*/}"
59+
done
60+
git add "$TRAVIS_TAG" index.html # don't forget to add the top level index!
61+
git commit -m "Tag/release documentation updated by travis job $TRAVIS_JOB_NUMBER for tag $TRAVIS_TAG $TRAVIS_COMMIT"
62+
git push origin gh-pages
63+
fi
64+
fi
65+
fi

0 commit comments

Comments
 (0)