Skip to content

feat: add update command and passive version-check notification#6

Merged
debidong merged 2 commits into
mainfrom
feat/update-command
May 13, 2026
Merged

feat: add update command and passive version-check notification#6
debidong merged 2 commits into
mainfrom
feat/update-command

Conversation

@debidong
Copy link
Copy Markdown
Collaborator

Summary

  • Add flashduty update command that checks GitHub Releases for the latest version and shells out to the existing install script (install.sh / install.ps1) to perform the upgrade
  • Add flashduty update --check flag for check-only mode (no install)
  • Add background version-check notification: every command silently checks GitHub Releases (24h interval), then prints a non-blocking stderr reminder if a newer version exists
  • Change goreleaser draft: true to draft: false so the /releases/latest API endpoint returns published releases

Gating logic (passive check is skipped when)

  • Version is dev or (devel) (local build)
  • FLASHDUTY_NO_UPDATE_CHECK=1 is set
  • CI environment detected (CI, GITHUB_ACTIONS, JENKINS_URL, GITLAB_CI)
  • Last check was less than 24 hours ago (persisted in ~/.flashduty/state.yaml)
  • stderr is not a TTY
  • Command is update or version

New files

  • internal/update/check.go — version check logic, state file, GitHub API, semver comparison
  • internal/update/check_test.go — 14 test cases
  • internal/cli/update.goflashduty update Cobra command

Modified files

  • internal/cli/root.go — PersistentPreRun/PersistentPostRun hooks, register update command
  • .goreleaser.ymldraft: false

Test plan

  • go test -race ./internal/update/... passes
  • go test -race ./... passes
  • flashduty update --check prints current vs latest version
  • flashduty update downloads and installs latest version via install script
  • Running any command (e.g. flashduty version) does NOT trigger background check (excluded command)
  • Running a regular command shows update notice on stderr if newer version exists
  • FLASHDUTY_NO_UPDATE_CHECK=1 suppresses the background check
  • Running twice within 24h skips the API call on second run

debidong added 2 commits May 13, 2026 17:59
Add `flashduty update` to check for and install the latest release,
and a background version check that reminds users to update after
a 24-hour interval. The update command shells out to the existing
install scripts rather than replacing the binary in-process.
- Add explicit error ignoring for fmt.Fprintf and resp.Body.Close
- Clear CI env vars in tests so ShouldCheck doesn't short-circuit on
  GitHub Actions runners
- Set USERPROFILE alongside HOME for Windows test compatibility
- Use unambiguously invalid YAML for corrupt state file test
@debidong debidong merged commit bc4cd81 into main May 13, 2026
12 checks passed
@debidong debidong deleted the feat/update-command branch May 13, 2026 10:14
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