Skip to content

Commit 4053587

Browse files
committed
Build documentation automatically using Travis CI
1 parent 67bdf5d commit 4053587

File tree

5 files changed

+80
-1
lines changed

5 files changed

+80
-1
lines changed

.ci/push_key.enc

3.17 KB
Binary file not shown.

.ci/travis-build-docs.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
3+
# Based on https://gist.github.com/domenic/ec8b0fc8ab45f39403dd
4+
5+
set -e -x
6+
7+
SOURCE_BRANCH="master"
8+
TARGET_BRANCH="gh-pages"
9+
DOC_BUILD_DIR="_build/html/"
10+
11+
if [ "${TRAVIS_OS_NAME}" != "linux" ]; then
12+
echo "Skipping documentation build on non-linux."
13+
exit 0
14+
fi
15+
16+
pip install -r docs/requirements.txt
17+
make htmldocs
18+
19+
if [ "${TRAVIS_PULL_REQUEST}" != "false" \
20+
-o "${TRAVIS_BRANCH}" != "${SOURCE_BRANCH}" \
21+
-o "${TRAVIS_OS_NAME}" != "linux" ]; then
22+
echo "Skipping documentation deploy."
23+
exit 0
24+
fi
25+
26+
27+
REPO=$(git config remote.origin.url)
28+
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
29+
COMMITISH=$(git rev-parse --verify HEAD)
30+
AUTHOR=$(git show --format="%aN <%aE>" "${COMMITISH}")
31+
32+
git clone "${REPO}" docs/gh-pages
33+
cd docs/gh-pages
34+
git checkout "${TARGET_BRANCH}" || git checkout --orphan "${TARGET_BRANCH}"
35+
cd ..
36+
37+
rm -r gh-pages/devel/
38+
rsync -a "${DOC_BUILD_DIR}/" gh-pages/devel/
39+
40+
if [ -n "${TRAVIS_TAG}" ]; then
41+
rm -r gh-pages/current/
42+
rsync -a "${DOC_BUILD_DIR}/" gh-pages/current/
43+
fi
44+
45+
cd gh-pages
46+
47+
if git diff --quiet --exit-code; then
48+
echo "No changes to documentation."
49+
exit 0
50+
fi
51+
52+
git add .
53+
git commit -m "Automatic documentation update" --author="${AUTHOR}"
54+
55+
set +x
56+
echo "Decrypting push key..."
57+
ENCRYPTED_KEY_VAR="encrypted_${DOCS_PUSH_KEY_LABEL}_key"
58+
ENCRYPTED_IV_VAR="encrypted_${DOCS_PUSH_KEY_LABEL}_iv"
59+
ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
60+
ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
61+
openssl aes-256-cbc -K "${ENCRYPTED_KEY}" -iv "${ENCRYPTED_IV}" \
62+
-in "${TRAVIS_BUILD_DIR}/.ci/push_key.enc" \
63+
-out "${TRAVIS_BUILD_DIR}/.ci/push_key" -d
64+
set -x
65+
chmod 600 "${TRAVIS_BUILD_DIR}/.ci/push_key"
66+
eval `ssh-agent -s`
67+
ssh-add "${TRAVIS_BUILD_DIR}/.ci/push_key"
68+
69+
git push "${SSH_REPO}" "${TARGET_BRANCH}"
70+
rm "${TRAVIS_BUILD_DIR}/.ci/push_key"
71+
72+
cd "${TRAVIS_BUILD_DIR}"
73+
rm -rf docs/gh-pages

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ env:
1313
global:
1414
- PYMODULE=asyncpg
1515
- PYPI_USER=magicstack-ci
16+
- DOCS_PUSH_KEY_LABEL=0760b951e99c
1617
- secure: "XEUUpzRZeesmMUfImKbCJm1D1LmWXkCW6ywtquuLEp6vRboH+URW8XtOhPehj47kn+/D4LpS9DR7GTBQ2DJR6kb07uqMu4b3WhTj8gewc8T5A0bxbdkkxHDfUCw7RF+EYLoN+n8xdqgBHImLLeuY/iRf+/IUJxGBARC4OZkejXhqJktNkXNO7aDcFfl9jcU0s1azaGbgeaShSAnnQPcdnJQ5tn7qHPPjTMWWly09A0K6CGqFK9bXUlD/hLGyC6NjOc8zMhv6vt4rI/zkjtSf219t4svivTjZsWWP6LMoWNWvwbOVfr8MThU4449lfplTWkmvEP6cQAJrvLjBOKOfwvV1MhqCMLGUMxeagYq7bHwSKQQ7t+r4a3jX94go+3Y1AQ0z9Yun+UW4qxrmHeIR5tLh2cePQylkIiTaWePZNPsVl3xF9HJtWcVgNgij4r+EU6WC9EqlV4DJyISjsptSa69CLBieWrzPYNxCPr6cTXYKKu6svRj3uho2q+c3Iavzjt4e5VEgppeduXIrvqMsaAa/E+j7b3QmC0HfZ4k8U5J2evtell5gh70Vf20A9LsOF06m+I0mSDwrpGasSFCNrWH4n3cUDTlGzc93Zqw5eAmg0yYxLKWk1sHNLOB3hNn+NLSIkS6Drcrsya+Fp5k93I4qDIXvC9n7ODLMirAJ76o="
1718

1819
matrix:
@@ -44,6 +45,7 @@ script:
4445
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then eval "$(pyenv init -)"; fi
4546
- make && make test
4647
- make debug && make test
48+
- .ci/travis-build-docs.sh
4749

4850
before_deploy:
4951
- .ci/travis-build-and-upload.sh

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ release: clean compile test
5050
$(PYTHON) setup.py sdist upload
5151

5252

53+
htmldocs:
54+
$(MAKE) -C docs html
55+
56+
5357
# Script to patch Cython 'async def' coroutines to have a 'tp_iter' slot,
5458
# which makes them compatible with 'yield from' without the
5559
# `asyncio.coroutine` decorator.

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Documentation
1818
-------------
1919

2020
The project documentation can be found
21-
`here <https://magicstack.github.io/asyncpg/>`_.
21+
`here <https://magicstack.github.io/asyncpg/current/>`_.
2222

2323

2424
Performance

0 commit comments

Comments
 (0)