]> git.proxmox.com Git - ceph.git/blob - ceph/src/rapidjson/travis-doxygen.sh
update sources to v12.1.0
[ceph.git] / ceph / src / rapidjson / travis-doxygen.sh
1 #!/bin/bash
2 # Update Doxygen documentation after push to 'master'.
3 # Author: @pah
4
5 set -e
6
7 DOXYGEN_VER=doxygen-1.8.7
8 DOXYGEN_TAR=${DOXYGEN_VER}.linux.bin.tar.gz
9 DOXYGEN_URL="http://ftp.stack.nl/pub/users/dimitri/${DOXYGEN_TAR}"
10 DOXYGEN_BIN="/usr/local/bin/doxygen"
11
12 : ${GITHUB_REPO:="miloyip/rapidjson"}
13 GITHUB_HOST="github.com"
14 GITHUB_CLONE="git://${GITHUB_HOST}/${GITHUB_REPO}"
15 GITHUB_URL="https://${GITHUB_HOST}/${GITHUB_PUSH-${GITHUB_REPO}}"
16
17 # if not set, ignore password
18 #GIT_ASKPASS="${TRAVIS_BUILD_DIR}/gh_ignore_askpass.sh"
19
20 skip() {
21 echo "$@" 1>&2
22 echo "Exiting..." 1>&2
23 exit 0
24 }
25
26 abort() {
27 echo "Error: $@" 1>&2
28 echo "Exiting..." 1>&2
29 exit 1
30 }
31
32 # TRAVIS_BUILD_DIR not set, exiting
33 [ -d "${TRAVIS_BUILD_DIR-/nonexistent}" ] || \
34 abort '${TRAVIS_BUILD_DIR} not set or nonexistent.'
35
36 # check for pull-requests
37 [ "${TRAVIS_PULL_REQUEST}" = "false" ] || \
38 skip "Not running Doxygen for pull-requests."
39
40 # check for branch name
41 [ "${TRAVIS_BRANCH}" = "master" ] || \
42 skip "Running Doxygen only for updates on 'master' branch (current: ${TRAVIS_BRANCH})."
43
44 # check for job number
45 # [ "${TRAVIS_JOB_NUMBER}" = "${TRAVIS_BUILD_NUMBER}.1" ] || \
46 # skip "Running Doxygen only on first job of build ${TRAVIS_BUILD_NUMBER} (current: ${TRAVIS_JOB_NUMBER})."
47
48 # install doxygen binary distribution
49 doxygen_install()
50 {
51 wget -O - "${DOXYGEN_URL}" | \
52 tar xz -C ${TMPDIR-/tmp} ${DOXYGEN_VER}/bin/doxygen
53 export PATH="${TMPDIR-/tmp}/${DOXYGEN_VER}/bin:$PATH"
54 }
55
56 doxygen_run()
57 {
58 cd "${TRAVIS_BUILD_DIR}";
59 doxygen ${TRAVIS_BUILD_DIR}/build/doc/Doxyfile;
60 doxygen ${TRAVIS_BUILD_DIR}/build/doc/Doxyfile.zh-cn;
61 }
62
63 gh_pages_prepare()
64 {
65 cd "${TRAVIS_BUILD_DIR}/build/doc";
66 [ ! -d "html" ] || \
67 abort "Doxygen target directory already exists."
68 git --version
69 git clone -b gh-pages "${GITHUB_CLONE}" html
70 cd html
71 # setup git config (with defaults)
72 git config user.name "${GIT_NAME-travis}"
73 git config user.email "${GIT_EMAIL-"travis@localhost"}"
74 # clean working dir
75 rm -f .git/index
76 git clean -df
77 }
78
79 gh_pages_commit() {
80 cd "${TRAVIS_BUILD_DIR}/build/doc/html";
81 echo "rapidjson.org" > CNAME
82 git add --all;
83 git diff-index --quiet HEAD || git commit -m "Automatic doxygen build";
84 }
85
86 gh_setup_askpass() {
87 cat > ${GIT_ASKPASS} <<EOF
88 #!/bin/bash
89 echo
90 exit 0
91 EOF
92 chmod a+x "$GIT_ASKPASS"
93 }
94
95 gh_pages_push() {
96 # check for secure variables
97 [ "${TRAVIS_SECURE_ENV_VARS}" = "true" ] || \
98 skip "Secure variables not available, not updating GitHub pages."
99 # check for GitHub access token
100 [ "${GH_TOKEN+set}" = set ] || \
101 skip "GitHub access token not available, not updating GitHub pages."
102 [ "${#GH_TOKEN}" -eq 40 ] || \
103 abort "GitHub token invalid: found ${#GH_TOKEN} characters, expected 40."
104
105 cd "${TRAVIS_BUILD_DIR}/build/doc/html";
106 # setup credentials (hide in "set -x" mode)
107 git remote set-url --push origin "${GITHUB_URL}"
108 git config credential.helper 'store'
109 # ( set +x ; git config credential.username "${GH_TOKEN}" )
110 ( set +x ; [ -f ${HOME}/.git-credentials ] || \
111 ( echo "https://${GH_TOKEN}:@${GITHUB_HOST}" > ${HOME}/.git-credentials ; \
112 chmod go-rw ${HOME}/.git-credentials ) )
113 # push to GitHub
114 git push origin gh-pages
115 }
116
117 doxygen_install
118 gh_pages_prepare
119 doxygen_run
120 gh_pages_commit
121 gh_pages_push
122