Skip to content

Commit

Permalink
add deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-sanders committed May 25, 2018
1 parent 66ed1c3 commit 24adf31
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions etc/deploy-docs
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
}

0 comments on commit 24adf31

Please sign in to comment.