Skip to content

Commit

Permalink
Update build script. Fixes #480.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Apr 3, 2018
1 parent 68ffafd commit d517c35
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
16 changes: 12 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@ before_install: yarn global add greenkeeper-lockfile@1
before_script: greenkeeper-lockfile-update
after_script: greenkeeper-lockfile-upload

# main
script:
- yarn run build
- yarn run test

after_success:
# send coverage to coveralls
- grunt coveralls
# update gh-page only for master and not pull requests
- if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
chmod +x ./resources/scripts/update-gh-pages.sh; "./resources/scripts/update-gh-pages.sh";
else echo "Not deploying artifacts for $TRAVIS_BRANCH"; fi
# update gh-page only if not a pull request and if branch master or develop
- if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
if [ "$TRAVIS_BRANCH" == "master" ] || [ "$TRAVIS_BRANCH" == "develop" ]; then
chmod +x ./resources/scripts/update-gh-pages.sh
"./resources/scripts/update-gh-pages.sh"
else echo "Not deploying artifacts for branch $TRAVIS_BRANCH"; fi
else echo "Not deploying artifacts for pull request"; fi
30 changes: 20 additions & 10 deletions resources/scripts/update-gh-pages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@
#Script to push build results on the repository gh-pages branch.

# we should be in /home/travis/build/ivmartel/dwv
echo -e "Starting to update gh-pages\n"
echo -e "Starting to update gh-pages...\n"

# build deploy version (result in ./build/dist)
yarn run build || exit 1
# create doc (result in ./build/doc)
yarn run doc
demodir=""
if [ "$TRAVIS_BRANCH" == "develop" ]; then
demodir="trunk"
elif [ "$TRAVIS_BRANCH" == "master" ]; then
demodir="stable"
# create doc (result in ./build/doc)
yarn run doc
else
echo "Cannot update gh-pages for branch $TRAVIS_BRANCH"
exit 0
fi

# go to home and setup git
cd $HOME
Expand All @@ -16,15 +23,18 @@ git config --global user.name "Travis"
# using token, clone gh-pages branch
git clone --quiet --branch=gh-pages https://${GH_TOKEN}@github.com/ivmartel/dwv.git gh-pages
# clean up
rm -Rf $HOME/gh-pages/demo/trunk/*
# copy new build and doc
cp -Rf $HOME/build/ivmartel/dwv/build/dist/* $HOME/gh-pages/demo/trunk
cp -Rf $HOME/build/ivmartel/dwv/build/doc $HOME/gh-pages/demo/trunk
rm -Rf $HOME/gh-pages/demo/$demodir/*
# copy new build
cp -Rf $HOME/build/ivmartel/dwv/build/dist/* $HOME/gh-pages/demo/$demodir
# copy doc for master
if [ "$TRAVIS_BRANCH" == "master" ]; then
cp -Rf $HOME/build/ivmartel/dwv/build/doc $HOME/gh-pages/demo/stable
fi
# move to root of repo
cd $HOME/gh-pages
# add, commit and push files
git add -Af .
git commit -m "Travis build $TRAVIS_BUILD_NUMBER pushed to gh-pages"
git push -fq origin gh-pages

echo -e "Done updating.\n"
echo -e "Done updating gh-pages.\n"

0 comments on commit d517c35

Please sign in to comment.