Add hammer update self-update command#8
Merged
Conversation
Add an `update` subcommand that replaces the running binary with the latest GitHub release. It resolves the target release via the GitHub API, downloads the platform archive (tar.gz, or zip on Windows), verifies it against SHA256SUMS, and atomically swaps the binary in place (with a cross-filesystem copy fallback and the Windows rename-aside path). Reuses the install.sh mirror ladder (auto/github/ghproxy/custom proxy via -mirror or HAMMER_INSTALL_MIRROR) and HAMMER_REPO for forks. Flags: -check, -version, -y/-yes. Semver-aware so it won't downgrade or reinstall the same version; a dev build always upgrades to a real release. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
hammer updatesubcommand so the CLI can update itself to the latest GitHub release.latest, or a pinned-version <tag>).tar.gz, or.zipon Windows), verifies it againstSHA256SUMS, and atomically swaps the running binary (cross-filesystem copy fallback + Windows rename-aside)install.shmirror ladder —-mirror auto|github|ghproxy|<proxy>/HAMMER_INSTALL_MIRROR, andHAMMER_REPOfor forksdevbuild always upgrades to a real release-check(report only),-version,-y/-yes(skip prompt)Testing
update_test.go: semver parse/compare, asset naming, mirror candidate ordering, checksum verify (valid/missing/tampered), tar.gz + zip extraction, atomic replacev1.1.0binary downloaded, checksum-verified, and replaced itself with the livev1.2.0releasego build,go vet,gofmt -l, andgo test -race ./...all clean🤖 Generated with Claude Code