-
Notifications
You must be signed in to change notification settings - Fork 663
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3da643f
commit feaf8a0
Showing
5 changed files
with
134 additions
and
5 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,72 @@ | ||
#!/bin/bash | ||
# Deploying docs from travis-ci. | ||
# See https://github.com/MDAnalysis/mdanalysis/issues/386 | ||
# Script based on https://github.com/steveklabnik/automatically_update_github_pages_with_travis_example | ||
|
||
# Run this script from the top-level of the checked out git | ||
# repository. A github OAuth token must be available in the evironment | ||
# variable GH_TOKEN and is set up through the .travis.yml | ||
# env:global:secure parameter (encrypted with travis-ci's public key)/ | ||
# | ||
# Additional environment variables set in .travis.yml | ||
# GH_REPOSITORY repo to full from and push to | ||
# GH_DOC_BRANCH branch from which the docs are built | ||
# GIT_CI_USER name of the user to push docs as | ||
# GIT_CI_EMAIL email of the user to push docs as | ||
# MDA_DOCDIR path to the docdir from top of repo | ||
# MAINTAIN_DIR path to maintainer/ | ||
# | ||
# NOTE: If any of these environment variables are not set or | ||
# empty then the script will exit with and error (-o nounset). | ||
|
||
set -o errexit -o nounset | ||
|
||
function die () { | ||
local msg="$1" err=${2:-1} | ||
echo "ERROR: $msg [$err]" | ||
exit $err | ||
} | ||
|
||
rev=$(git rev-parse --short HEAD) | ||
|
||
# the following tests should be superfluous because of -o nounset | ||
test -n "${GH_TOKEN}" || die "GH_TOKEN is empty: need OAuth GitHub token to continue" 100 | ||
test -n "${GH_REPOSITORY}" || die "GH_REPOSITORY must be set in .travis.yml" 100 | ||
test -n "${MDA_DOCDIR}" || die "MDA_DOCDIR must be set in .travis.yml" 100 | ||
test -n "${MAINTAIN_DIR}" || die "MAINTAIN_DIR must be set in .travis.yml" 100 | ||
test -n "${VERSION}" || die "VERSION must be set in .travis.yml" 100 | ||
|
||
|
||
cd ${MDA_DOCDIR} || die "Failed to 'cd ${MDA_DOCDIR}'. Run from the top level of the repository" | ||
|
||
# move into $version subdirectory | ||
mkdir ../${VERSION} && mv * ../${VERSION} | ||
|
||
git init | ||
git config user.name "${GIT_CI_USER}" | ||
git config user.email "${GIT_CI_EMAIL}" | ||
|
||
mv ../${VERSION} $VERSION | ||
|
||
git remote add upstream "https://${GH_TOKEN}@${GH_REPOSITORY}" | ||
git fetch --depth 50 upstream ${GH_DOC_BRANCH} gh-pages | ||
git reset upstream/gh-pages | ||
|
||
touch . | ||
touch .nojekyll | ||
|
||
echo $VERSION | ||
echo "ls *" | ||
ls * | ||
git add -A ${VERSION}/ | ||
git add .nojekyll | ||
|
||
python ${MAINTAIN_DIR}/update_versions_json.py | ||
git add versions.json | ||
|
||
# check for anything to commit | ||
# https://stackoverflow.com/questions/3878624/how-do-i-programmatically-determine-if-there-are-uncommited-changes | ||
git diff-index --quiet HEAD -- || git commit -m "rebuilt html docs from branch ${GH_DOC_BRANCH} with sphinx at ${rev}" | ||
git push -q upstream HEAD:gh-pages | ||
|
||
|
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,41 @@ | ||
import json | ||
import os | ||
|
||
try: | ||
from urllib.request import urlopen | ||
except ImportError: | ||
from urllib2 import urlopen | ||
|
||
URL = "https://www.mdanalysis.org/mdanalysis/" | ||
|
||
VERSION = os.environ['VERSION'] | ||
url = os.path.join(URL, 'versions.json') | ||
try: | ||
data = urlopen(url).read().decode() | ||
versions = json.loads(data) | ||
except: | ||
try: | ||
with open('versions.json', 'r') as f: | ||
versions = json.loads(f) | ||
except: | ||
versions = [] | ||
|
||
existing = [item['version'] for item in versions] | ||
already_exists = VERSION in existing | ||
|
||
if not already_exists: | ||
latest = 'dev' not in VERSION | ||
if latest: | ||
for ver in versions: | ||
ver['latest'] = False | ||
|
||
versions.append({ | ||
'version': VERSION, | ||
'display': VERSION, | ||
'url': os.path.join(URL, VERSION), | ||
'latest': latest | ||
}) | ||
|
||
with open("versions.json", 'w') as f: | ||
json.dump(versions, f, indent=2) | ||
|
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