Skip to content

feat: tell of a newer release once a day, at a terminal - #74

Merged
achoimet merged 3 commits into
mainfrom
feat/update-notice
Sep 29, 2026
Merged

achoimet merged 3 commits into
mainfrom
feat/update-notice

Conversation

@achoimet

Copy link
Copy Markdown
Member

With npm gone, nothing tells people a new CLI release is out: a downloaded binary stays as it is.

Behaviour

  • At most once a day, the CLI asks where https://github.com/steadybit/cli/releases/latest redirects. That costs nothing against the GitHub API's rate limit. It caches the answer in ~/.steadybit/update-check.json.
  • After the command, when a newer release exists, it prints to stderr:
    A new release of the Steadybit CLI is available: 6.0.0 → 6.0.1
    Update with: brew upgrade steadybit        (Homebrew install: the binary lives in a Caskroom)
    Get it from https://github.com/steadybit/cli/releases/latest    (otherwise)
    
  • Silent when:
    • stderr isn't a terminal;
    • the CI, JENKINS_URL, TF_BUILD or BUILDKITE variables are set;
    • the command is completion or __complete;
    • the build isn't a release (go install …@main, dev builds);
    • STEADYBIT_NO_UPDATE_CHECK is set.
  • The check runs alongside the command, which waits for it at most 1 s, once a day. Offline, the check is still recorded, so GitHub isn't asked again on every command.
  • Versions compare by number, so 6.10.0 is newer than 6.9.0.

Testing

  • Unit tests against a fake releases redirect, covering:
    • a newer release is announced;
    • at most one request per day, with the cached answer used in between;
    • silent when up to date, for non-releases, and when nobody would see it;
    • offline is recorded;
    • the number comparison.
  • go test -race ./... and go vet (also GOOS=windows) pass.
  • Live against GitHub with a build stamped 6.0.0, in a temporary home:
    • on a terminal it announces 6.0.1, and the second run uses the cache;
    • nothing is printed with stderr piped, with CI=true, or for completion;
    • the same binary run from a Caskroom path prints brew upgrade steadybit.

npm used to tell people when a new version was out; a downloaded binary stays
as it is, so users would not notice releases. At most once a day the CLI asks
where GitHub's latest-release redirect points, which costs none of the API's
rate limit, and caches the answer in ~/.steadybit. A newer release is shown on
stderr after the command, with `brew upgrade steadybit` for Homebrew installs.

It stays quiet where nobody would read it or where it would get in the way: when
stderr is not a terminal, in CI, during completion, for builds that are not
releases, and with STEADYBIT_NO_UPDATE_CHECK set. A command waits for the check
at most a second, once a day, and offline the check is not retried until the
next day.
- The request gives up after 800 ms, earlier than the command's 1 s wait, so a
  request that runs out of time behind a firewall is still recorded before the
  command ends; before, every later command could wait again.
- The cache is replaced through a renamed temporary file, so a command ending
  mid-write, or two running at once, never leave a broken file.
- A check dated in the future, from a wrong clock or a copied cache, is due
  instead of trusted until the clock catches up.
- Completion skips the check wherever global flags put it in the arguments
  (`--profile x completion zsh`, `-v __complete ...`), not only first.
- STEADYBIT_NO_UPDATE_CHECK=0 or false no longer turns the check off.
- The container image sets STEADYBIT_NO_UPDATE_CHECK: each run starts fresh,
  often in a pipeline whose CI variables are not passed in, and is updated by
  pulling an image, so the check would only ask GitHub every time and advise
  the wrong thing.
- The cache path comes from the config package, which owns ~/.steadybit.
- Tests no longer depend on how fast a refused connection fails, which on
  Windows takes longer than the check waits.
@achoimet
achoimet merged commit 34242d5 into main Sep 29, 2026
8 checks passed
@achoimet
achoimet deleted the feat/update-notice branch September 29, 2026 13:07
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant