2017-11-11 23:17:17 +01:00
|
|
|
#!/bin/bash
|
|
|
|
set -eo pipefail
|
|
|
|
|
|
|
|
GHPAGESREPO="git@github.com:zrepl/zrepl.github.io.git"
|
|
|
|
SCRIPTDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
|
|
|
PUBLICDIR="${SCRIPTDIR}/public_git"
|
|
|
|
|
|
|
|
checkout_repo_msg() {
|
|
|
|
echo "clone ${GHPAGESREPO} to ${PUBLICDIR}:"
|
|
|
|
echo " git clone ${GHPAGESREPO} ${PUBLICDIR}"
|
|
|
|
git clone "${GHPAGESREPO}" "${PUBLICDIR}"
|
|
|
|
}
|
|
|
|
|
|
|
|
exit_msg() {
|
|
|
|
echo "error, exiting..."
|
|
|
|
}
|
|
|
|
trap exit_msg EXIT
|
|
|
|
|
2017-11-18 21:16:54 +01:00
|
|
|
if ! type sphinx-versioning >/dev/null; then
|
|
|
|
echo "install sphinx-versioning and come back"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-11-11 23:17:17 +01:00
|
|
|
cd "$SCRIPTDIR"
|
|
|
|
|
|
|
|
if [ ! -d "$PUBLICDIR" ]; then
|
|
|
|
checkout_repo_msg
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-11-18 16:21:53 +01:00
|
|
|
echo -n "PRESS ENTER to confirm you commited and pushed docs changes and tags to the zrepl repo"
|
2017-11-11 23:17:17 +01:00
|
|
|
read
|
|
|
|
|
|
|
|
pushd "$PUBLICDIR"
|
|
|
|
|
|
|
|
echo "verify we're in the GitHub pages repo..."
|
|
|
|
git remote get-url origin | grep -E "^${GHPAGESREPO}\$"
|
|
|
|
if [ "$?" -ne "0" ] ;then
|
|
|
|
checkout_repo_msg
|
|
|
|
echo "finished checkout, please run again"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "resetting GitHub pages repo to latest commit"
|
|
|
|
git fetch origin
|
|
|
|
git reset --hard origin/master
|
|
|
|
|
|
|
|
echo "cleaning GitHub pages repo"
|
|
|
|
git rm -rf .
|
|
|
|
|
|
|
|
popd
|
|
|
|
|
|
|
|
echo "building site"
|
|
|
|
set -e
|
2017-11-18 16:21:53 +01:00
|
|
|
sphinx-versioning build \
|
|
|
|
--show-banner \
|
2019-03-30 19:03:18 +01:00
|
|
|
--whitelist-branches '^master$' \
|
2019-10-03 11:57:19 +02:00
|
|
|
--whitelist-tags '(v)?\d+\.[1-9][0-9]*.\d+$' \
|
2017-11-18 16:21:53 +01:00
|
|
|
docs ./public_git \
|
|
|
|
-- -c sphinxconf # older conf.py throw errors because they used
|
|
|
|
# version = subprocess.show_output(["git", "describe"])
|
|
|
|
# which fails when building with sphinxcontrib-versioning
|
2017-11-11 23:17:17 +01:00
|
|
|
set +e
|
|
|
|
|
|
|
|
CURRENT_COMMIT=$(git rev-parse HEAD)
|
|
|
|
git status --porcelain
|
|
|
|
if [[ "$(git status --porcelain)" != "" ]]; then
|
|
|
|
CURRENT_COMMIT="${CURRENT_COMMIT}(dirty)"
|
|
|
|
fi
|
2017-11-18 16:21:53 +01:00
|
|
|
COMMIT_MSG="sphinx-versioning render from publish.sh - `date -u` - ${CURRENT_COMMIT}"
|
2017-11-11 23:17:17 +01:00
|
|
|
|
|
|
|
pushd "$PUBLICDIR"
|
|
|
|
|
|
|
|
echo "adding and commiting all changes in GitHub pages repo"
|
|
|
|
git add -A
|
|
|
|
git commit -m "$COMMIT_MSG"
|
2017-11-12 13:33:34 +01:00
|
|
|
git push origin master
|
2017-11-11 23:17:17 +01:00
|
|
|
|