1#! /usr/bin/env bash 2 3set -eu 4shopt -s extglob 5 6if grep 'localhost:4000' *.md _posts/*.md; then 7 echo "ERROR: Your content has links to localhost:4000!" >&2 8 exit 1 9fi 10 11if [ "x$(git status --porcelain)" != "x" ]; then 12 echo -n "git repo has uncommited changes. Continue anyway? (y/N) " >&2 13 read -n 1 YESNO 14 echo >&2 15 if [ "x$YESNO" != xy ]; then 16 exit 1 17 fi 18fi 19 20case $(git rev-parse --abbrev-ref HEAD) in 21 master ) 22 echo "On master branch. Will generate to /next." 23 CONFIG=_config_next.yml 24 PREFIX=/next 25 LABEL="preview site" 26 FUTURE=--future 27 ;; 28 29 release-* ) 30 echo "On release branch. Will generate to /." 31 CONFIG=_config.yml 32 PREFIX= 33 LABEL="site" 34 FUTURE= 35 ;; 36 37 * ) 38 echo "Unrecognized branch." >&2 39 exit 1 40 ;; 41esac 42 43echo "Regenerating site..." 44 45rm -rf _site _site.tar.gz 46 47jekyll _3.8.1_ build --safe $FUTURE --config $CONFIG 48 49echo -n "Push now? (y/N)" 50read -n 1 YESNO 51echo 52 53if [ "x$YESNO" == "xy" ]; then 54 echo "Pushing..." 55 tar cz --xform='s,_site/,,' _site/* | gce-ss ssh alpha2 --command "cd /var/www/capnproto.org$PREFIX && tar xz" 56else 57 echo "Push CANCELED" 58fi 59