Never build a release without the pinned Timeless Sans
make release now runs hack/fonts.sh, which fetches the font if it is missing, then hack/fonts.sh check, and stops unless the file is exactly the pinned one (R31). fonts.sh pins the extracted file's SHA-256 too, so a file already in place is checked rather than trusted, and a fresh extraction is checked twice. Dev and test builds keep the DM Sans fallback. hack/fonts_test.sh, run by script-test, covers the missing and wrong-file cases and the release recipe's order without the network.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 files changed,
+134
−19
Makefile+9 −2README.md+4 −2hack/fonts.sh+53 −15hack/fonts_test.sh+68 −0
diff --git a/Makefile b/Makefile| index 951a4b0..bc534e2 100644 |
| --- a/Makefile |
| +++ b/Makefile |
| @@ -19,11 +19,16 @@ RASTRILLO := go run amadan.net/rastrillo/rastrillo/cmd/rastrillo |
| build: |
| CGO_ENABLED=0 go build ./... |
| -# Builds every binary under ./cmd, stamped with the clean commit. |
| +# Builds every binary under ./cmd, stamped with the clean commit. A release |
| +# is set in Timeless Sans or not built at all: it fetches the font if it is |
| +# missing and refuses to go on unless the file is the pinned one. (Dev and |
| +# test builds fall back to DM Sans.) |
| release: |
| @test -z "$$(git ls-files --others --exclude-standard)" |
| @git diff --quiet && git diff --cached --quiet || \ |
| { echo "refusing to build a release from a dirty tree"; exit 1; } |
| + ./hack/fonts.sh |
| + @./hack/fonts.sh check || { echo "refusing to build a release without Timeless Sans"; exit 1; } |
| @mkdir -p releases |
| @for dir in cmd/*/; do \ |
| app=$$(basename $$dir); \ |
| @@ -69,9 +74,11 @@ gitleaks: |
| echo "gitleaks: not the root of a git repository, nothing committed to scan"; \ |
| fi |
| -# Tests the operator script against a fake carlos. |
| +# Tests the operator script against a fake carlos, and the font checks the |
| +# release relies on. |
| script-test: |
| scripts/prepare-apps_test.sh |
| + hack/fonts_test.sh |
| # ci is the one gate: what a runner executes and what you run before pushing. |
| ci: build vet fmt-check staticcheck govulncheck gitleaks budget script-test test |
diff --git a/README.md b/README.md| index ac22778..3db7dec 100644 |
| --- a/README.md |
| +++ b/README.md |
| @@ -69,7 +69,9 @@ Build the binaries, then deploy Base to a channel: |
| make release |
| carlos deploy --app base --channel edge releases/base-linux-arm64-<version> |
| -`make release` refuses to build from a dirty tree. It builds `base`, |
| +`make release` refuses to build from a dirty tree. It fetches Timeless Sans |
| +if it isn't there yet (this needs the network), and refuses to build unless |
| +the font is exactly the pinned file. It builds `base`, |
| `scratchpad` and `welcome` for linux/arm64 into `releases/`, named with the |
| commit. Set the `BASE_*` settings with `carlos env set --app base KEY=value`. |
| @@ -110,6 +112,6 @@ installed it vouches for, with no roles of their own. |
| `make ci` is the gate. `make browser` drives Chromium through Base and the |
| apps it installs; set `RASTRILLO_CHROME` to a Chromium first. `make fonts` |
| fetches Timeless Sans, which the licence keeps out of the repository. Without |
| -it Base falls back to DM Sans. |
| +it development and test builds fall back to DM Sans; a release never does. |
| `docs/live-check.md` is the by-hand check against a real account. |
diff --git a/hack/fonts.sh b/hack/fonts.sh| index 7a9671a..24b3616 100755 |
| --- a/hack/fonts.sh |
| +++ b/hack/fonts.sh |
| @@ -8,20 +8,66 @@ |
| # embeds it from there. Without it the site still builds and runs, set in |
| # DM Sans. |
| # |
| +# A release is never built without it: `make release` runs this script and |
| +# then `hack/fonts.sh check`, which fails unless the file is there and is |
| +# exactly the pinned font. |
| +# |
| # make fonts fetch it (needs the network: media.timeless.co) |
| # FORCE=1 make fonts fetch it again even if it is already there |
| +# hack/fonts.sh check check the file that is there; never downloads |
| set -eu |
| VERSION=1.094 |
| URL="https://media.timeless.co/type/Timeless-Type-Family-$VERSION.zip" |
| SHA256=510685dfce6010b74a1a250af7de1204e1b9901be152a39f5dd6be85fc6d6084 |
| MEMBER=Timeless-Type-Family-$VERSION/Sans-Grotesk/TimelessSansVF.woff2 |
| +# The extracted file, from the zip above, so a file already in place can be |
| +# checked without the network. |
| +FONT_SHA256=353b3fbb75b8e9b927db12d520ff8d446d89c36897b47a90d70dbe36e9eeb23a |
| root=$(cd "$(dirname "$0")/.." && pwd) |
| dest="$root/internal/look/static/fonts/timeless/$VERSION" |
| +font="$dest/TimelessSansVF.woff2" |
| + |
| +sha256() { |
| + if command -v sha256sum >/dev/null 2>&1; then |
| + sha256sum "$1" | cut -d' ' -f1 |
| + else |
| + shasum -a 256 "$1" | cut -d' ' -f1 |
| + fi |
| +} |
| -if [ -f "$dest/TimelessSansVF.woff2" ] && [ -z "${FORCE:-}" ]; then |
| - echo "fonts: $dest/TimelessSansVF.woff2 is already there (FORCE=1 to fetch again)" |
| +# verify FILE WANT fails loudly unless FILE's SHA-256 is WANT. |
| +verify() { |
| + got=$(sha256 "$1") |
| + if [ "$got" != "$2" ]; then |
| + echo "fonts: checksum mismatch for $1" >&2 |
| + echo "fonts: want $2" >&2 |
| + echo "fonts: got $got" >&2 |
| + return 1 |
| + fi |
| +} |
| + |
| +case "${1:-}" in |
| +check) |
| + if [ ! -f "$font" ]; then |
| + echo "fonts: $font is not there; run make fonts" >&2 |
| + exit 1 |
| + fi |
| + verify "$font" "$FONT_SHA256" || { echo "fonts: FORCE=1 make fonts fetches it again" >&2; exit 1; } |
| + echo "fonts: $font is the pinned Timeless Sans" |
| + exit 0 |
| + ;; |
| +"") ;; |
| +*) |
| + echo "usage: hack/fonts.sh [check]" >&2 |
| + exit 2 |
| + ;; |
| +esac |
| + |
| +if [ -f "$font" ] && [ -z "${FORCE:-}" ]; then |
| + verify "$font" "$FONT_SHA256" || { echo "fonts: FORCE=1 make fonts fetches it again" >&2; exit 1; } |
| + echo "fonts: $font is already there (FORCE=1 to fetch again)" |
| exit 0 |
| fi |
| @@ -48,17 +94,7 @@ trap 'exit 1' INT TERM |
| echo "fonts: downloading $URL" |
| curl --fail --silent --show-error --location --proto '=https' --output "$work/timeless.zip" "$URL" |
| -if command -v sha256sum >/dev/null 2>&1; then |
| - got=$(sha256sum "$work/timeless.zip" | cut -d' ' -f1) |
| -else |
| - got=$(shasum -a 256 "$work/timeless.zip" | cut -d' ' -f1) |
| -fi |
| -if [ "$got" != "$SHA256" ]; then |
| - echo "fonts: checksum mismatch for $URL" >&2 |
| - echo "fonts: want $SHA256" >&2 |
| - echo "fonts: got $got" >&2 |
| - exit 1 |
| -fi |
| +verify "$work/timeless.zip" "$SHA256" || { echo "fonts: (downloaded from $URL)" >&2; exit 1; } |
| # Only the one file comes out of the zip, into a scratch directory first, |
| # so a failed extraction leaves nothing half-installed. |
| @@ -75,6 +111,8 @@ with zipfile.ZipFile(zf) as z, z.open(member) as src: |
| ' "$work/timeless.zip" "$MEMBER" "$work/out" |
| fi |
| +verify "$work/out/TimelessSansVF.woff2" "$FONT_SHA256" |
| + |
| mkdir -p "$dest" |
| -mv "$work/out/TimelessSansVF.woff2" "$dest/TimelessSansVF.woff2" |
| -echo "fonts: wrote $dest/TimelessSansVF.woff2" |
| +mv "$work/out/TimelessSansVF.woff2" "$font" |
| +echo "fonts: wrote $font" |
diff --git a/hack/fonts_test.sh b/hack/fonts_test.sh| new file mode 100755 |
| index 0000000..432c058 |
| --- /dev/null |
| +++ b/hack/fonts_test.sh |
| @@ -0,0 +1,68 @@ |
| +#!/usr/bin/env bash |
| +# Tests for fonts.sh's checks and for the release gate that uses them. None |
| +# needs the network: every case fails before a download would start. Run |
| +# directly: |
| +# hack/fonts_test.sh |
| +set -uo pipefail |
| + |
| +here=$(cd -- "$(dirname -- "$0")" && pwd) |
| +root=$(cd -- "$here/.." && pwd) |
| +work=$(mktemp -d) |
| +trap 'rm -rf "$work"' EXIT |
| +fails=0 |
| + |
| +fail() { echo "FAIL: $*"; fails=$((fails + 1)); } |
| + |
| +# A copy of the script in a tree of its own, so nothing touches the real |
| +# font directory. |
| +mkdir -p "$work/hack" "$work/internal/look/static/fonts/timeless" |
| +cp "$here/fonts.sh" "$work/hack/fonts.sh" |
| +font=$work/internal/look/static/fonts/timeless/1.094/TimelessSansVF.woff2 |
| + |
| +# check: a missing font fails. |
| +if out=$(sh "$work/hack/fonts.sh" check 2>&1); then |
| + fail "check passed with no font: $out" |
| +elif ! printf '%s' "$out" | grep -q "not there"; then |
| + fail "check without a font said: $out" |
| +fi |
| + |
| +# check: a file that is not the pinned font fails. |
| +mkdir -p "$(dirname "$font")" |
| +printf 'not a font' >"$font" |
| +if out=$(sh "$work/hack/fonts.sh" check 2>&1); then |
| + fail "check passed a wrong file: $out" |
| +elif ! printf '%s' "$out" | grep -q "checksum mismatch"; then |
| + fail "check of a wrong file said: $out" |
| +fi |
| + |
| +# fetch: a wrong file already there is refused, not kept as the font. |
| +if out=$(sh "$work/hack/fonts.sh" 2>&1); then |
| + fail "fetch kept a wrong file: $out" |
| +elif ! printf '%s' "$out" | grep -q "checksum mismatch"; then |
| + fail "fetch with a wrong file said: $out" |
| +fi |
| + |
| +# The real font, when this machine has fetched it, passes. |
| +real=$root/internal/look/static/fonts/timeless/1.094/TimelessSansVF.woff2 |
| +if [ -f "$real" ]; then |
| + cp "$real" "$font" |
| + if ! out=$(sh "$work/hack/fonts.sh" check 2>&1); then |
| + fail "check refused the real font: $out" |
| + fi |
| +fi |
| + |
| +# The release target fetches and checks the font before it builds anything. |
| +plan=$(make -C "$root" -n release 2>/dev/null) |
| +fetch=$(printf '%s\n' "$plan" | grep -n 'hack/fonts.sh$' | head -1 | cut -d: -f1) |
| +check=$(printf '%s\n' "$plan" | grep -n 'hack/fonts.sh check' | head -1 | cut -d: -f1) |
| +build=$(printf '%s\n' "$plan" | grep -n 'go build' | head -1 | cut -d: -f1) |
| +if [ -z "$fetch" ] || [ -z "$check" ] || [ -z "$build" ] || [ "$fetch" -gt "$build" ] || [ "$check" -gt "$build" ]; then |
| + fail "make release does not fetch and check the font before building:" |
| + printf '%s\n' "$plan" |
| +fi |
| + |
| +if [ "$fails" -ne 0 ]; then |
| + echo "fonts_test: $fails failed" |
| + exit 1 |
| +fi |
| +echo "fonts_test: ok" |