-
Notifications
You must be signed in to change notification settings - Fork 54
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
66ed1c3
commit 24adf31
Showing
1 changed file
with
64 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
shopt -s extglob | ||
|
||
cd "$(dirname "$BASH_SOURCE")/../" | ||
|
||
REMOTE='origin' | ||
TEMP_DOCS_LABEL='doc-build-dir' | ||
DOCUMENTATION_FILES=!(doc|404.md|CHANGES.md|"$TEMP_DOCS_LABEL"|_config.yml) | ||
|
||
. ./rose-version | ||
if [[ -z $ROSE_VERSION ]]; then | ||
exit 1 | ||
fi | ||
|
||
initial_deployment () { # Create a new gh-pages branch from scratch. | ||
# start with a blank doc directory | ||
git clean -xf doc | ||
|
||
# build the documentation | ||
rose make-docs html slides | ||
|
||
# create the gh-pages branch | ||
git branch -D gh-pages || true | ||
git checkout --orphan gh-pages | ||
|
||
# move docs to the top level and delete everything else | ||
git rm -rf $DOCUMENTATION_FILES # remove tracked files | ||
git clean -xf $DOCUMENTATION_FILES # remove untracked files | ||
mv doc "$TEMP_DOCS_LABEL" # permit the alias "doc" | ||
mv "$TEMP_DOCS_LABEL"/* . | ||
git clean -xf "$TEMP_DOCS_LABEL" | ||
git add * -f | ||
|
||
# commit and push | ||
git commit -m "${ROSE_VERSION}" | ||
# git push "${REMOTE}" gh-pages | ||
} | ||
|
||
|
||
subsequent_deployment () { # Add new version to documentation. | ||
# update gh-pages branch | ||
git pull "${REMOTE}" gh-pages -f | ||
git clean -xf doc | ||
|
||
# copy gh-pahes branch to a temporary directory | ||
TMP_DOCS_DIR="$(mktemp -d)" | ||
git archive 'gh-pages' | (cd "${TMP_DOCS_DIR}" && tar -xf -) | ||
|
||
# append new documentation to the temporary directory | ||
ln -s "$TMP_DOCS_DIR" doc | ||
rose make-docs html slides | ||
|
||
# apply changes to gh-pages branch | ||
git checkout gh-pages | ||
rsync -av "${TMP_DOCS_DIR}/" . # NOTE: the trailing slash is required | ||
rm -rf "${TMP_DOCS_DIR}" | ||
git add * -f | ||
|
||
# commit and push | ||
git commit -m "${ROSE_VERSION}" | ||
# git push "${REMOTE}" gh-pages | ||
} |