Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build and deploy site

on:
push:
branches: [main]
# Build (but don't deploy) on PRs, so a broken build is caught before merge.
pull_request:
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

# Queue deploys rather than cancelling them, so a push mid-deploy can't leave
# the live site half-updated.
concurrency:
group: pages
cancel-in-progress: false

env:
# Pinned to match the nix devshell, so CI output is byte-identical to a
# local build. Bump these together with flake.lock.
HUGO_VERSION: 0.115.0
MDBOOK_VERSION: 0.4.31
MDBOOK_KATEX_VERSION: 0.5.4

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Recursive is required: /docs/ is built from the dither-spec
# submodule, and static/disp/interactive-walkthrough.html is a
# symlink into the disp submodule that Hugo follows.
submodules: recursive

- name: Install toolchain
run: |
set -euo pipefail
mkdir -p "$RUNNER_TEMP/bin"
curl -sSfL "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz" \
| tar -xz -C "$RUNNER_TEMP/bin" hugo
curl -sSfL "https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz" \
| tar -xz -C "$RUNNER_TEMP/bin" mdbook
curl -sSfL "https://github.com/lzanini/mdbook-katex/releases/download/v${MDBOOK_KATEX_VERSION}/mdbook-katex-v${MDBOOK_KATEX_VERSION}-x86_64-unknown-linux-gnu.tar.gz" \
| tar -xz -C "$RUNNER_TEMP/bin" mdbook-katex
echo "$RUNNER_TEMP/bin" >> "$GITHUB_PATH"

- name: Build
run: ./build.sh

- uses: actions/upload-pages-artifact@v3
with:
path: ./public

deploy:
needs: build
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v4
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
result
resources
# public
.direnv
public
.direnv
.hugo_build.lock
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
[submodule "themes/book"]
path = themes/book
url = https://github.com/alex-shpak/hugo-book
[submodule "public"]
path = public
url = https://github.com/libdither/dither.link-build.git
[submodule "disp"]
path = disp
url = https://github.com/libdither/disp
Empty file removed .hugo_build.lock
Empty file.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,35 @@
Website for Dither, hosts the entirety of [libdither/dither-spec](https://github.com/libdither/dither-spec) in addition to an introduction to Dither

More to be added in the future (such as a blog and perhaps a simple commenting system).

## Publishing

Pushing to `main` builds and deploys the site to <https://dither.link> via
GitHub Actions (`.github/workflows/deploy.yml`). There is nothing to run by
hand — `public/` is build output and is no longer committed.

To publish a change to the spec:

```sh
cd dither-spec
# edit, then
git commit -am "..." && git push
cd ..
git commit -am "dither-spec: ..." dither-spec # bump the submodule pointer
git push # triggers the deploy
```

## Local development

Requires [nix](https://nixos.org) with flakes (or hugo-extended, mdbook and
mdbook-katex on `PATH`). `direnv allow` picks up the devshell automatically.

```sh
nix develop # hugo-extended, mdbook, mdbook-katex
hugo server # live preview of the site shell
./build.sh # full build (site + /docs/) into public/
```

CI pins the same tool versions the devshell provides, so a local `./build.sh`
produces byte-identical output to a deploy. When bumping `flake.lock`, update
the pinned versions in `.github/workflows/deploy.yml` to match.
13 changes: 0 additions & 13 deletions build-push.sh

This file was deleted.

18 changes: 18 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Build the full site into public/. Used by both `nix develop` locally and CI.
set -euo pipefail
cd "$(dirname "$0")"

# Hugo never removes stale output, so old fingerprinted assets accumulate
# across builds. Start clean instead.
rm -rf public

# Hugo first: it owns the site root. mdbook then fills in /docs/ underneath.
hugo --gc
mdbook build dither-spec -d ../public/docs

# dither-spec/book.toml sets src = ".", so mdbook copies every non-markdown
# file in the submodule into the output -- including its git metadata and any
# stale build dir left behind by running `mdbook build` there without -d. A
# fresh CI checkout has neither; drop them so local builds match.
rm -rf public/docs/.git public/docs/public
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
src = ./.;
nativeBuildInputs = buildInputs;
buildPhase = ''
hugoix
./build.sh
'';
installPhase = ''
cp -r public $out
Expand Down
1 change: 0 additions & 1 deletion public
Submodule public deleted from b61841
Loading