cannam@62: #! /usr/bin/env bash cannam@62: cannam@62: set -eu cannam@62: shopt -s extglob cannam@62: cannam@62: if grep 'localhost:4000' *.md _posts/*.md; then cannam@62: echo "ERROR: Your content has links to localhost:4000!" >&2 cannam@62: exit 1 cannam@62: fi cannam@62: cannam@62: if [ "x$(git status --porcelain)" != "x" ]; then cannam@62: echo -n "git repo has uncommited changes. Continue anyway? (y/N) " >&2 cannam@62: read -n 1 YESNO cannam@62: echo >&2 cannam@62: if [ "x$YESNO" != xy ]; then cannam@62: exit 1 cannam@62: fi cannam@62: fi cannam@62: cannam@62: case $(git rev-parse --abbrev-ref HEAD) in cannam@62: master ) cannam@62: echo "On master branch. Will generate to /next." cannam@62: CONFIG=_config_next.yml cannam@62: PREFIX=/next cannam@62: LABEL="preview site" cannam@62: FUTURE=--future cannam@62: ;; cannam@62: cannam@62: release-* ) cannam@62: echo "On release branch. Will generate to /." cannam@62: CONFIG=_config.yml cannam@62: PREFIX= cannam@62: LABEL="site" cannam@62: FUTURE= cannam@62: ;; cannam@62: cannam@62: * ) cannam@62: echo "Unrecognized branch." >&2 cannam@62: exit 1 cannam@62: ;; cannam@62: esac cannam@62: cannam@62: echo "Regenerating site..." cannam@62: cannam@62: rm -rf _site _site.tar.gz cannam@62: cannam@62: jekyll build --safe $FUTURE --config $CONFIG cannam@62: cannam@62: echo -n "Push now? (y/N)" cannam@62: read -n 1 YESNO cannam@62: echo cannam@62: cannam@62: if [ "x$YESNO" == "xy" ]; then cannam@62: echo "Pushing..." cannam@62: tar cz --xform='s,_site/,,' _site/* | gce-ss ssh fe --command "cd /var/www/capnproto.org$PREFIX && tar xz" cannam@62: else cannam@62: echo "Push CANCELED" cannam@62: fi