The Makefile is the only supported way to ship. Never copy a binary by hand: the server move did that five times, and that mess is why these targets exist.
The flow
make test gofmt, vet, all unit tests, CSS freshness (the only gate)
git push CI runs the same checks plus race tests and firmware (see CI)
make tag V=v0.35.0 annotated git tag; refuses a dirty tree
make deploy test → build → upload → switch → restart → check
What make deploy does, step by step
- Test again, so nothing untested ships.
- Build a static Linux binary with
CGO_ENABLED=0. The version comes fromgit describe, so the binary knows exactly which commit it is. - Upload compressed:
xzshrinks 16 MB to about 5 MB, piped over SSH to/tmp/guzva.new. (Measured 2026-10-31: a deploy took 190 s, 157 s of it the upload over a home connection.) - Smoke test the new file on the server (
guzva.new version), so a broken upload stops here. - Install into
/srv/guzva/bin/releases/<version>/and point thecurrentsymlink at it. Switching a symlink is atomic, so there is never a half-installed state. - Prune to the last 3 releases.
- Restart the service. Downtime is under 2 s; a camera that posts in that gap retries.
- Check with
make check:/healthzmust sayok:trueand the new version, the homepage must answer 200, the admin 200 or 303. Any failure stops withHEALTHCHECK FAILED.
Then write the deploy into docs/ops-log.md with the proof.
Rollback
make rollback TAG=v0.34.1
Points current back at an older release folder, restarts and runs the same check. It takes seconds because the old binary is still on the server.
Known gap (found 2026-11-23): rollback across a schema change does not work. On start, the binary refuses a database whose schema is newer than it knows (
store: unknown schema version … binary older than db?). That is the safe choice, since an old binary never writes to a schema it doesn't understand, but it meansmake rollbackafter a migrating deploy leaves the service down until the pre-deploy database is restored. Planned:make deploytakes a database snapshot before switching, and rollback offers to restore it.
Database migrations
Schema changes live in internal/store as numbered migrations, embedded in the binary. On start the binary reads PRAGMA user_version, applies any missing steps in one transaction each, and bumps the number. Prod is at schema v29. Rules: additive only (new tables and columns), and every migration is exercised against a copy of a real migrated database, not just a fresh one. A restart-proof migration gap once hid behind fresh-database tests.
Planned (O2)
- CI builds the release binary on each tag, with a checksum and a record of how it was built.
- The server downloads that exact file instead of the laptop uploading its own build, so production runs byte-for-byte what CI tested, and deploys stop depending on the home connection.
- Deploys stay manual: no SSH key to the server is stored in GitHub.