Skip to content

added upgrade command - #4

Closed
BKJN1 wants to merge 1 commit into
mainfrom
feat/added-upgrade
Closed

added upgrade command#4
BKJN1 wants to merge 1 commit into
mainfrom
feat/added-upgrade

Conversation

@BKJN1

@BKJN1 BKJN1 commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

What

Adds versola upgrade: checks GitHub for a newer versola-cli release
and, 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

  • Uses github.com/creativeprojects/go-selfupdate instead of writing
    our 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.
  • No changes needed to release.yml: the library's expected asset naming
    ({cmd}-{goos}-{goarch}) and its ChecksumValidator (a single
    checksums.txt with sha256 lines) already match what we publish today.
  • Refuses to run on a "dev" build (no release to compare against).

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.sum need go mod tidy run locally to pick up the new
dependency (not run here -- no Go toolchain available in this
environment).

@augmentcode

augmentcode Bot commented Aug 4, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR adds a self-update flow to versola-cli via a new upgrade command.

Changes:

  • Introduces versola upgrade (with -y/--yes) to check GitHub Releases, download a newer binary, verify it against checksums.txt, and replace the running executable.
  • Registers the new command in the cobra root command.
  • Updates the README to document upgrade usage and caveats (not yet tested against a real newer release).
  • Adds github.com/creativeprojects/go-selfupdate plus associated indirect dependencies in go.mod/go.sum.

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 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 3 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread go.mod
module github.com/versolauth/versola-cli

go 1.22
go 1.25.12

@augmentcode augmentcode Bot Aug 4, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Comment thread internal/cmd/upgrade.go
return fmt.Errorf("no release found for %s/%s", runtime.GOOS, runtime.GOARCH)
}

if latest.LessOrEqual(version) {

@augmentcode augmentcode Bot Aug 4, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Comment thread internal/cmd/upgrade.go

fmt.Printf("versola-cli %s is available (you have %s).\n", latest.Version(), version)

if !upgradeAssumeYes && !confirm("Update now?") {

@augmentcode augmentcode Bot Aug 4, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@BKJN1 BKJN1 closed this Aug 4, 2026
@BKJN1
BKJN1 deleted the feat/added-upgrade branch August 4, 2026 08:49
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