fix(deploy): rebuild when deployed binary is stale, not just on ref change #31
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/deploy-retry-stale-binary"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
If a deploy fast-forwarded the git ref but the build failed (as happened with the missing npm dep), subsequent runs of
deploy.shsawbefore == afterand exited as a no-op — never retrying the build. A human had to rebuild and restart manually.Changes
deploy/deploy.sh: after fetch/pull, also checks whether the deployed binary is stale. It runs/usr/local/bin/kwila-tournaments --version 2>&1and greps for HEAD's short SHA (the build embeds it via-ldflags -X main.Version, e.g.2026.8.12+1cdcdda). The script now rebuilds + redeploys when the binary version doesn't match HEAD or the binary is missing entirely, even when the git ref is unchanged. No-op only when both ref and binary match.main.go: fixes--version, which previously printed PocketBase's own(untracked)version.app.RootCmd.Version = Versionwires in the build-time version so the flag reports it on stdout.deploy/README.md: clarifies that "up to date" means both git ref AND deployed binary match HEAD.Testing
bash -nsyntax check; detection snippet verified against the real deployed binary (read-only)git/just/sudo: stale binary → rebuilds, up-to-date binary → no-op, missing binary → rebuildsgo testpasses on all backend packages;--versionoutput verified with a test-ldflags buildNote: the deploy script greps combined
2>&1output, so it works with both the currently-deployed binary (version only in the stderr startup log) and new binaries (version in--versionstdout).PocketBase's root command is constructed with its own Version variable ("(untracked)"), so --version never reported the version embedded at build time via -ldflags -X main.Version. Override RootCmd.Version after pocketbase.New() so --version prints it (e.g. 2026.8.12+1cdcdda) on stdout, which the deploy script uses to detect a stale binary. Co-authored-by: Shelley <[email protected]>