Skip to content

Add self-update command and background update check#106

Merged
sdairs merged 4 commits intomainfrom
issue-103-self-update
Apr 14, 2026
Merged

Add self-update command and background update check#106
sdairs merged 4 commits intomainfrom
issue-103-self-update

Conversation

@sdairs
Copy link
Copy Markdown
Collaborator

@sdairs sdairs commented Apr 10, 2026

Summary

  • Adds clickhousectl update command that downloads the latest release binary from GitHub Releases and replaces the current binary in-place
  • Adds clickhousectl update --check to check for updates without installing
  • Adds a background update check that runs on every command (at most once per 24h, cached in ~/.clickhouse/last_update_check) and prints a notice to stderr when a newer version is available
  • The background check runs concurrently with the actual command to avoid slowing down normal usage

Test plan

  • cargo build passes
  • cargo test passes (254 tests, including 3 new tests for version parsing, comparison, and asset name detection)
  • cargo clippy clean
  • Manual test: clickhousectl update --check reports current version status
  • Manual test: clickhousectl update downloads and replaces binary
  • Manual test: background notice appears on stale cache, suppressed when cache is fresh

Closes #103

🤖 Generated with Claude Code

Implements `clickhousectl update` to download the latest release from GitHub
and replace the running binary in-place. Also adds a background version check
that runs on every command (cached for 24h) and prints a notice to stderr
when a newer version is available.

Closes #103

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdairs sdairs requested a review from iskakaushik as a code owner April 10, 2026 16:05
@sdairs sdairs temporarily deployed to cloud-integration April 10, 2026 16:05 — with GitHub Actions Inactive
Two fixes:
- Split the background update check into a sync cache-read phase
  (prints notice before the command runs, no interleaved output) and
  a fire-and-forget async refresh (never awaited, never prints).
  The next invocation sees the refreshed cache.
- Add a 10s timeout to the GitHub API client so even explicit
  `update`/`update --check` commands don't hang on unreachable hosts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdairs sdairs temporarily deployed to cloud-integration April 10, 2026 17:03 — with GitHub Actions Inactive
…d client

- Await the cache refresh handle with a 5s timeout so short-lived
  commands (local which, --version, etc.) don't drop the task before
  the cache write completes, while still bounding the worst case.
- Add 5-minute timeout to the download client in perform_update so
  `clickhousectl update` can't hang indefinitely on a stalled connection.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdairs sdairs temporarily deployed to cloud-integration April 10, 2026 19:39 — with GitHub Actions Inactive
The implicit background check should never degrade CLI responsiveness.

- Background GitHub API request now has a 400ms timeout (vs 10s for
  explicit `update`/`update --check` commands).
- On any failure (timeout, network error, etc.), write the current
  version to the cache so we back off for 24 hours instead of
  retrying on every invocation.
- Grace period at exit reduced from 5s to 500ms (just enough headroom
  above the 400ms HTTP timeout for the cache file write).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdairs sdairs temporarily deployed to cloud-integration April 10, 2026 19:54 — with GitHub Actions Inactive
@sdairs sdairs merged commit 341bbd6 into main Apr 14, 2026
10 checks passed
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.

Self-update: CLI should detect new versions and update itself

2 participants