Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/miloyip/rapidjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorPhilipp A. Hartmann <pah@qo.cx>2014-07-08 20:55:55 +0400
committerPhilipp A. Hartmann <pah@qo.cx>2014-07-08 20:56:07 +0400
commit7c7eb1c5c04bbb9123b511bafb658defef25f6c1 (patch)
treed89eeb49c36889c8ea542f5f0802d570bf1719f3 /build
parent994fdf8f1ee05c02186697353c2e983be8d3e9d7 (diff)
Travis CI: build/update Doxygen from separate script
In this patch, a script 'build/travis-doxygen.sh' is added to build and push the Doxygen documentation to the GitHub pages at https://miloyip.githib.io/rapidjson. The script exits gracefully, if the build is requested for - a branch other than 'master' - a pull-request - a job (i.e. CI configuration) other than "1" In case the "secure variables" are not available, only the final upload is skipped, in order to allow testing of the script's basic functionality. Update .travis.yml to call the script.
Diffstat (limited to 'build')
-rwxr-xr-xbuild/travis-doxygen.sh97
1 files changed, 97 insertions, 0 deletions
diff --git a/build/travis-doxygen.sh b/build/travis-doxygen.sh
new file mode 100755
index 00000000..a85d7bae
--- /dev/null
+++ b/build/travis-doxygen.sh
@@ -0,0 +1,97 @@
+#!/bin/bash
+# Update Doxygen documentation after push to 'master'.
+# Author: @pah
+
+set -e
+
+SUDO=sudo
+DOXYGEN_VER=doxygen-1.8.7
+DOXYGEN_TAR=${DOXYGEN_VER}.linux.bin.tar.gz
+DOXYGEN_URL="http://ftp.stack.nl/pub/users/dimitri/${DOXYGEN_TAR}"
+DOXYGEN_BIN="/usr/local/bin/doxygen"
+
+GHPAGES_REPO="miloyip/rapidjson"
+GHPAGES_BASE="https://github.com/${GHPAGES_REPO}"
+# NOTE: not expanded here to hide GH_TOKEN
+GHPAGES_PUSH='https://${GH_TOKEN}@github.com/${GHPAGES_REPO}'
+
+skip() {
+ echo "$@" 1>&2
+ echo "Exiting..." 1>&2
+ exit 0
+}
+
+abort() {
+ echo "Error: $@" 1>&2
+ echo "Exiting..." 1>&2
+ exit 1
+}
+
+# TRAVIS_BUILD_DIR not set, exiting
+[ -d "${TRAVIS_BUILD_DIR-/nonexistent}" ] || \
+ abort '${TRAVIS_BUILD_DIR} not set or nonexistent.'
+
+# check for pull-requests
+[ "${TRAVIS_PULL_REQUEST}" = "false" ] || \
+ skip "Not running Doxygen for pull-requests."
+
+# check for branch name
+[ "${TRAVIS_BRANCH}" = "master" ] || \
+ skip "Running Doxygen only for updates on 'master' branch (current: ${TRAVIS_BRANCH})."
+
+# check for job number
+[ "${TRAVIS_JOB_NUMBER}" = "${TRAVIS_BUILD_NUMBER}.1" ] || \
+ skip "Running Doxygen only on first job of build ${TRAVIS_BUILD_NUMBER} (current: ${TRAVIS_JOB_NUMBER})."
+
+# install doxygen binary distribution
+doxygen_install()
+{
+ wget -O - "${DOXYGEN_URL}" | \
+ tar xz -C ${TMPDIR-/tmp} ${DOXYGEN_VER}/bin/doxygen
+ $SUDO install -m 755 ${TMPDIR-/tmp}/${DOXYGEN_VER}/bin/doxygen \
+ ${DOXYGEN_BIN};
+}
+
+doxygen_run()
+{
+ cd "${TRAVIS_BUILD_DIR}";
+ doxygen build/Doxyfile;
+}
+
+gh_pages_prepare()
+{
+ cd "${TRAVIS_BUILD_DIR}/doc";
+ [ ! -d "html" ] || \
+ abort "Doxygen target directory already exists."
+ git clone --single-branch -b gh-pages ${GHPAGES_BASE} html
+ cd html
+ # clean working dir
+ rm -f .git/index
+ git clean -df
+}
+
+gh_pages_commit() {
+ cd "${TRAVIS_BUILD_DIR}/doc/html";
+ git add --all;
+ git commit -m "Automatic doxygen build";
+}
+
+gh_pages_push() {
+ # check for secure variables
+ [ "${TRAVIS_SECURE_ENV_VARS}" = "true" ] || \
+ skip "Secure variables not available, not updating GitHub pages."
+ [ "${GH_TOKEN+set}" = set ] || \
+ skip "GitHub access token not available, not updating GitHub pages."
+
+ cd "${TRAVIS_BUILD_DIR}/doc/html";
+ # push to GitHub without printing GH_TOKEN even in "set -x" mode
+ ( echo "git push ${GHPAGES_PUSH} gh-pages" ; set +x; \
+ eval "git push ${GHPAGES_PUSH} gh-pages" )
+}
+
+doxygen_install
+gh_pages_prepare
+doxygen_run
+gh_pages_commit
+gh_pages_push
+