👷 Add Travis' GitHub deployment steps.

Changed API documentation deployment to gh_pages to Travis's GitHub Pages
deployment.
Also add Travis GitHub Release Deployment step to offer API
documentation.
Both steps are optional and need to be activated in Travis by setting
GH_TOKEN.
This commit is contained in:
Klaus Weidenbach 2017-03-10 01:01:35 +01:00
parent 4a85726e55
commit 5c080ca4e8
2 changed files with 27 additions and 50 deletions

View File

@ -17,6 +17,8 @@ branches:
only: only:
- master - master
- dev - dev
# whitelist our tags for release deployments e.g. 2.2
- /^\d+\.\d+(\.\d+)?(-\S*)?$/
# Install additional software # Install additional software
addons: addons:
@ -45,7 +47,6 @@ env:
global: global:
# used for doxygen deployment script # used for doxygen deployment script
- DOXYFILE: $TRAVIS_BUILD_DIR/util/Doxyfile - DOXYFILE: $TRAVIS_BUILD_DIR/util/Doxyfile
- GHP_REPO_REF: github.com/redmatrix/hubzilla.git
# Uncomment if a newer/specific version of Doxygen should be used # Uncomment if a newer/specific version of Doxygen should be used
#- DOXY_VER: 1.8.12 #- DOXY_VER: 1.8.12
# Code Coverage is slow, no need to have it in every build # Code Coverage is slow, no need to have it in every build
@ -123,15 +124,26 @@ after_success:
- ./tests/travis/gen_apidocs.sh - ./tests/travis/gen_apidocs.sh
#after_failure: #after_failure:
# Deploying a release to GitHub when tagging in master # Deploying release and API documentation to GitHub
# Waiting for upcoming 'Build Stages' Q1/Q2 2017 to make generation of API docs
# and release packages cleaner. https://github.com/travis-ci/travis-ci/issues/929
#before_deploy: #before_deploy:
#deploy: deploy:
# skip_cleaning: true - provider: pages
# provider: releases skip_cleanup: true
# on: local_dir: $TRAVIS_BUILD_DIR/doc/html
# tags: true github_token: $GH_TOKEN
on:
repo: redmatrix/hubzilla
branch: master
condition: '(-n "$GH_TOKEN") && ("$TRAVIS_JOB_NUMBER" == "${TRAVIS_BUILD_NUMBER}.1")'
# add API documentation to release, could also be used to provide full packages if we want to drop vendor from our repo
- provider: releases
skip_cleanup: true
api_key: $GH_TOKEN
file: 'doc/hubzilla-api-documentation.zip'
on:
repo: redmatrix/hubzilla
tags: true
condition: '(-n "$GH_TOKEN") && ("$TRAVIS_JOB_NUMBER" == "${TRAVIS_BUILD_NUMBER}.1")'
#after_deploy: #after_deploy:
#after_script: #after_script:

View File

@ -56,48 +56,13 @@ mkdir -p ./doc/html
# Redirect stderr and stdout to log file and console to be able to review documentation errors # Redirect stderr and stdout to log file and console to be able to review documentation errors
doxygen $DOXYFILE 2>&1 | tee ./doc/html/doxygen.log doxygen $DOXYFILE 2>&1 | tee ./doc/html/doxygen.log
# Check if Doxygen successfully created the documentation
# There is no sane way yet, to prevent missuse of the push tokens in our workflow.
# We would need a way to limit a token to only push to gh-pages or a way to prevent
# manipulations to travis scripts which is not possible because we want it to run
# for pull requests.
# There are protected branches in GitHub, but they do not work for forced pushes.
exit
# Only continue for master branch pushes
if [[ "$TRAVIS_EVENT_TYPE" != "push" ]] || [[ "$TRAVIS_BRANCH" != "master" ]]; then
echo "Conditions not met to build API documentation."
echo "We are finished ..."
# exit
fi
# Check if GitHub token is configured in Travis to be able to push to the repo
if [ -z "$GHP_TOKEN" ]; then
echo "No GitHub token configured in Travis, can not deploy to gh-pages ..."
echo "Add Environment Variable 'GHP_TOKEN' in Travis CI project settings"
echo "with a 'Personal access token' from GitHub with 'repo:public_repo'."
exit
fi
# Upload the API documentation to the gh-pages branch of the GitHub repository.
# Only upload if Doxygen successfully created the documentation.
if [ -d "doc/html" ] && [ -f "doc/html/index.html" ]; then if [ -d "doc/html" ] && [ -f "doc/html/index.html" ]; then
echo "Uploading API documentation to the gh-pages branch ..." echo "API documentation generated"
if [ -n "${TRAVIS_TAG}" ]; then
# Add the new API documentation as a Git commit echo "Generate API documentation archive for release deployment ..."
cd ./doc/html zip -9 -r -q doc/hubzilla-api-documentation.zip doc/html/
fi
# Create and configure a new git repo for committing to gh-pages
git init
# Add a fake Travis CI user
git config user.name "Travis CI"
git config user.email "travis@travis-ci.org"
# Add the generated API documentation
git add --all
git commit -q -m "API documentation generated by Travis build: ${TRAVIS_BUILD_NUMBER}" -m "From commit: ${TRAVIS_COMMIT}"
# No need for a history, force push to the remote gh-pages branch
git push -f "https://${GHP_TOKEN}@${GHP_REPO_REF}" master:gh-pages > /dev/null 2>&1
else else
echo "No API documentation files have been found" >&2 echo "No API documentation files have been found" >&2
exit 1 exit 1