-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding subdirectories for versioned docs.
Fixes #472.
- Loading branch information
Showing
3 changed files
with
53 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"""Simple script to get the gcloud version.""" | ||
from pkg_resources import get_distribution | ||
print get_distribution('gcloud').version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,27 +16,59 @@ | |
|
||
set -ev | ||
|
||
# Build new docset in docs/_build from master. | ||
tox -e docs | ||
# Adding GitHub pages branch. `git submodule add` checks it | ||
# out at HEAD. | ||
GH_PAGES_DIR="ghpages" | ||
git submodule add -b gh-pages \ | ||
"https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME}" \ | ||
ghpages | ||
cp -R docs/_build/html/* ghpages/ | ||
cd ghpages | ||
# allow "git add" to fail if there aren't new files. | ||
set +e | ||
${GH_PAGES_DIR} | ||
|
||
# Determine if we are building a new tag or are building docs | ||
# for master. Then build new docset in docs/_build from master. | ||
if [[ -z "${TRAVIS_TAG}" ]]; then | ||
SPHINX_RELEASE=$(git log -1 --pretty=%h) tox -e docs | ||
else | ||
# Sphinx will use the package version by default. | ||
tox -e docs | ||
fi | ||
|
||
# Get the current version. Assumes the PWD is the root of the git repo. | ||
# We run this after `tox -e docs` to make sure the `docs` env is | ||
# set up. | ||
CURRENT_VERSION=$(.tox/docs/bin/python scripts/get_version.py) | ||
|
||
# Update gh-pages with the created docs. | ||
cd ${GH_PAGES_DIR} | ||
if [[ -z "${TRAVIS_TAG}" ]]; then | ||
git rm -fr master/ | ||
cp -R ../docs/_build/html/ master/ | ||
else | ||
if [[ -d ${CURRENT_VERSION} ]]; then | ||
echo "The directory ${CURRENT_VERSION} already exists." | ||
exit 1 | ||
fi | ||
git rm -fr latest/ | ||
# Put the new release in latest and with the actual version. | ||
cp -R ../docs/_build/html/ latest/ | ||
cp -R ../docs/_build/html/ "${CURRENT_VERSION}/" | ||
fi | ||
|
||
# Update the files push to gh-pages. | ||
git add . | ||
set -e | ||
git status | ||
|
||
# H/T: https://github.com/dhermes | ||
if [[ -n "$(git status --porcelain)" ]]; then | ||
# Commit to gh-pages branch to apply changes. | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "travis-ci" | ||
git commit -m "Update docs after merge to master." | ||
git push \ | ||
"https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME}" \ | ||
HEAD:gh-pages | ||
else | ||
if [[ -z "$(git status --porcelain)" ]]; then | ||
echo "Nothing to commit. Exiting without pushing changes." | ||
exit | ||
fi | ||
|
||
# Commit to gh-pages branch to apply changes. | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "travis-ci" | ||
git commit -m "Update docs after merge to master." | ||
# NOTE: This may fail if two docs updates (on merges to master) | ||
# happen in close proximity. | ||
git push \ | ||
"https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME}" \ | ||
HEAD:gh-pages |