Skip to content

feat: add self-update command to install the latest release in place - #18

Merged
utahcon merged 2 commits into
mainfrom
feat/self-update
Oct 8, 2026
Merged

utahcon merged 2 commits into
mainfrom
feat/self-update

Conversation

@utahcon

@utahcon utahcon commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • New github-pokemon self-update command (and --check): fetches the latest release, downloads the archive for the current OS/arch, verifies its sha256 against the release checksums.txt (refuses to install if missing or mismatched), extracts the binary, and replaces the running executable via a temp file + rename in the same directory. On Windows the old binary is renamed aside first. Permission errors suggest re-running with privileges.
  • The background update notice now suggests github-pokemon self-update.
  • Fix: version had a computed initializer, so GoReleaser's -X ...cmd.version was silently ignored. It's now a plain string resolved at startup (ldflags first, then build info, then 0.0.0-dev).
  • +build metadata (e.g. 1.5.0+dirty) is ignored when comparing versions.
  • Adds unit tests for checksum verification, tar.gz/zip extraction, archive naming, and binary replacement.

Test plan

  • go build / go vet / go test
  • End to end on linux/amd64: built as v1.0.0, ran self-update against the live v1.5.0 release; checksum verified and the binary was replaced (--version reports 1.5.0)
  • darwin/windows replacement (covered only by unit test on Windows rename path)

🤖 Generated with Claude Code

utahcon and others added 2 commits October 8, 2026 11:53
Download the release archive for the current OS/arch, verify it against
checksums.txt, and atomically replace the running binary. Includes --check
to only report availability and points the update notice at the command.

Also make the version ldflags override effective (the computed initializer
made -X a no-op) and ignore +build metadata when comparing versions.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@utahcon
utahcon merged commit 26a3d07 into main Oct 8, 2026
4 checks passed
@utahcon
utahcon deleted the feat/self-update branch October 8, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant