autoupdate 3/3: Apply pending update and re-exec#1769
Open
yahanxing-stripe wants to merge 3 commits into
Open
Conversation
This was referenced Jul 9, 2026
yahanxing-stripe
added a commit
that referenced
this pull request
Jul 14, 2026
## Summary - Introduce `pkg/autoupdate` package with helpers to detect whether the CLI was installed via curl (`~/.stripe/bin/`) and whether auto-update is opted out - Opt-out via `STRIPE_NO_AUTO_UPDATE=1` env var or `auto_update = false` in `~/.config/stripe/config.toml` - Exposes `GetStateDir()` for later use by the checker and updater This is **part 1/3** of the auto-update feature for curl-installed binaries. Stack: **this** → #1768 (checker) → #1769 (apply) ## Test plan - [x] Unit tests for opt-out detection (env var, config.toml true/false, missing config) - [x] Unit test for curl install detection via env override 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
yahanxing-stripe
added a commit
that referenced
this pull request
Jul 14, 2026
## Summary - After each command completes, check GitHub for a newer CLI version (rate-limited to once per 24h via timestamp file) - If a minor/patch update is available, write a marker file to `~/.stripe/state/update-available` with version, download URL, and checksum - **Skip major version changes** entirely — no prompt, no auto-update to avoid silently introducing breaking changes - Includes SHA256 checksum verification utility used by the apply step This is **part 2/3** of the auto-update feature for curl-installed binaries. Stack: #1767 (config) → **this** → #1769 (apply) ## Test plan - [x] Unit tests for major version detection logic - [x] Unit tests for marker file read/write/clear - [x] Unit test for `recordLastCheck` timestamp - [x] Unit test for checksum verification 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
On startup, if a marker file indicates a newer version is available, download the binary, verify its checksum, atomically replace the current binary, and re-exec the process. The user always runs the latest version with no manual step required. This is part 3/3 of the auto-update feature for curl-installed binaries. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
No curl install path exists for Windows yet, so this code is unreachable. Simplifies extractBinary to tar.gz only. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
7f580df to
449e758
Compare
Tests extractFromTarGz with real tar archives, downloadAndReplace with httptest.Server including checksum verification and error cases, and ApplyIfPending skip logic. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
449e758 to
83432c5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is part 3/3 of the auto-update feature for curl-installed binaries.
Stack: #1767 (config) → #1768 (checker) → this
Test plan
~/.stripe/bin/, run a command, verify marker is written🤖 Generated with Claude Code