Skip to content

autoupdate 3/3: Apply pending update and re-exec#1769

Open
yahanxing-stripe wants to merge 3 commits into
v2from
yx/autoupdate-3-apply
Open

autoupdate 3/3: Apply pending update and re-exec#1769
yahanxing-stripe wants to merge 3 commits into
v2from
yx/autoupdate-3-apply

Conversation

@yahanxing-stripe

Copy link
Copy Markdown
Contributor

Summary

  • On startup, if a marker file exists, download the new binary, verify checksum, atomically replace the current binary, and re-exec the process
  • User sees:
    Automatically updating Stripe CLI from 1.23.0 to 1.23.1.
    To disable auto-update, set STRIPE_NO_AUTO_UPDATE=1 or add auto_update = false to ~/.config/stripe/config.toml
    Updated successfully ✓
    
  • If download or checksum fails: prints a one-line warning, clears marker, continues with current version
  • Binary is never left in a broken state (download to temp → atomic rename)
  • Supports both tar.gz (macOS/Linux) and zip (Windows) archives

This is part 3/3 of the auto-update feature for curl-installed binaries.
Stack: #1767 (config) → #1768 (checker) → this

Test plan

  • Manual test: build with an old version string, place in ~/.stripe/bin/, run a command, verify marker is written
  • Manual test: with marker present, run again — verify download + re-exec
  • Verify no-op for Homebrew-installed binary
  • Verify opt-out via env var and config.toml both skip the update

🤖 Generated with Claude Code

@yahanxing-stripe yahanxing-stripe requested a review from a team as a code owner July 9, 2026 21:03
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>
Base automatically changed from yx/autoupdate-2-checker to v2 July 14, 2026 22:38
yahanxing-stripe and others added 2 commits July 14, 2026 22:43
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
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
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