commit 92b7b08ebc291e3d4123171b674c051a5d1b36ca
parent 77b5ecb51da7bd42a85c458ce6a206faedc9a564
Author: Chris Bracken <chris@bracken.jp>
Date: Wed, 10 Apr 2019 09:47:44 -0700
Add publish.sh rather than rely on CI
Rather than rely on Travis, publish locally using a shell script. A few
reasons:
* Eliminates the need to build Hugo from source.
* Avoids dealing with incompatibilies between whatever version of Go
is available on the CI bots and the version hugo is developed with.
* `go get` doesn't support fetching from a tag, which means building
from unreleased bleeding-edge versions of hugo, or manually fetching
the transitive closure of dependencies.
* It's much, much faster.
Diffstat:
3 files changed, 49 insertions(+), 27 deletions(-)
diff --git a/.travis.yml b/.travis.yml
@@ -1,26 +0,0 @@
-language: go
-
-# use the latest version of go.
-go:
- - master
-
-# Fetch the latest version of Hugo.
-install:
- - go get github.com/spf13/hugo
-
-# Build the website.
-script:
- - hugo
-
-deploy:
- local_dir: public # static site output dir for Hugo.
- repo: cbracken/cbracken.github.io # repo to deploy to.
- target_branch: master # deploy to master branch.
- provider: pages # GitHub Pages
- skip_cleanup: true
- keep_history: true
- github_token: $GITHUB_TOKEN
- email: chris@bracken.jp
- name: "Chris Bracken"
- on:
- branch: master
diff --git a/README.md b/README.md
@@ -20,7 +20,7 @@ Next, initialise and fetch git submodules:
git submodule update --init
```
-## Building and running
+## Starting the dev server
Fire up hugo's dev server:
```
@@ -44,5 +44,18 @@ Edit `content/post/yyyy-mm-dd-title-of-post.md` in your favourite editor. When
it's ready to post, remove the `draft` tag from the post header, commit the
changes, and push.
+## Building and deploying the site
+
+The site is currently published to [GitHub pages][pages_repo]. That repo
+contains a [CNAME][pages_cname] file that tells GitHub the site should resolve
+to my personal domain.
+
+To build and deploy the site, run:
+```
+./publish.sh
+```
+
[blog]: https://chris.bracken.jp
[hugo_install]: https://gohugo.io/getting-started/installing/
+[pages_repo]: https://github.com/cbracken/cbracken.github.io
+[pages_cname]: https://github.com/cbracken/cbracken.github.io/blob/master/CNAME
diff --git a/publish.sh b/publish.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+PUBLISH_REPO=git@github.com:cbracken/cbracken.github.io.git
+
+if ! git diff-index --quiet HEAD --; then
+ echo >&2 "Git diffs found. Commit changes before publishing. Aborting."
+ exit 1
+fi
+
+# Check for hugo command.
+command -v hugo >/dev/null 2>&1 || { echo >&2 "hugo not found. Aborting."; exit 1; }
+
+# If public dir exists, abort.
+if [[ -d public ]]; then
+ echo >&2 "public directory already exists. Aborting."
+ exit 1
+fi
+
+# Clone the repo and build.
+git clone $PUBLISH_REPO public
+hugo || { echo >&2 "hugo build failed. Aborting."; exit 1; }
+
+# Check diffs and publish.
+echo "Build succeeded. Displaying diffs:"
+git -C public diff
+read -p "Commit and publish? " -n 1 -r
+echo
+if [[ $REPLY =~ ^[Yy]$ ]]; then
+ git -C public add .
+ git -C public commit -m "Publish site"
+ git -C public push origin master
+fi
+
+echo "Cleaning up..."
+rm -rf public