added upgrade command - #4
Conversation
🤖 Augment PR SummarySummary: This PR adds a self-update flow to versola-cli via a new Changes:
Technical Notes: Uses go-selfupdate’s platform-aware replacement logic to safely swap binaries in place, including Windows’ executable-lock constraints. 🤖 Was this summary useful? React with 👍 or 👎 |
| module github.com/versolauth/versola-cli | ||
|
|
||
| go 1.22 | ||
| go 1.25.12 |
There was a problem hiding this comment.
go.mod:3 — The go 1.25.12 directive makes this module require that exact minimum Go toolchain; it will also conflict with .github/workflows/release.yml currently using Go 1.22 (the go command will refuse to build/test). Could you confirm the intended minimum Go version and align the workflow/toolchain accordingly?
Severity: high
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| return fmt.Errorf("no release found for %s/%s", runtime.GOOS, runtime.GOARCH) | ||
| } | ||
|
|
||
| if latest.LessOrEqual(version) { |
There was a problem hiding this comment.
internal/cmd/upgrade.go:67 — latest.LessOrEqual(version) ultimately calls semver.MustParse(version) in go-selfupdate, which will panic if version ever contains a non-semver value (anything other than the explicit "dev" you already handle). Consider guarding against unexpected version values so upgrade fails gracefully instead of crashing.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
|
|
||
| fmt.Printf("versola-cli %s is available (you have %s).\n", latest.Version(), version) | ||
|
|
||
| if !upgradeAssumeYes && !confirm("Update now?") { |
There was a problem hiding this comment.
internal/cmd/upgrade.go:74 — confirm() reads from stdin unconditionally, so running versola upgrade in a non-interactive context without --yes can block waiting for input. Consider detecting non-interactive stdin (like promptOpen does) and erroring/aborting with a clear message unless --yes is set.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
What
Adds
versola upgrade: checks GitHub for a newer versola-cli releaseand, if found, downloads and swaps in the new binary in place (after
confirmation), verified against the release's checksums.txt.
Why
Requested by the team lead after re-running the install one-liner to
"upgrade" wasn't obviously doing anything from the user's side. A
dedicated command makes the update itself, and whether it happened,
explicit.
Implementation notes
github.com/creativeprojects/go-selfupdateinstead of writingour own replace-the-running-binary logic. That library already solves
the tricky part correctly: on Windows you can't overwrite a currently
executing .exe in place, so it does the standard rename-current-then-
move-new-into-place dance; on macOS/Linux it can just replace the file
directly. Rolling this ourselves would mean owning those OS-specific
edge cases; the library is actively maintained (latest release
Dec 2025) and already used by other CLI tools for exactly this.
(
{cmd}-{goos}-{goarch}) and itsChecksumValidator(a singlechecksums.txt with sha256 lines) already match what we publish today.
Testing
Not yet tested against a real published release (needs an actual newer
release to exist to test the full download+replace path) -- code
compiles and the "already latest" / "dev build" early-exit paths are
straightforward, but the actual replace should be verified after the
next release goes out.
Follow-up
go.mod/go.sumneedgo mod tidyrun locally to pick up the newdependency (not run here -- no Go toolchain available in this
environment).