Skip to content

autoupdate 2/3: Add version check and update marker#1768

Open
yahanxing-stripe wants to merge 1 commit into
yx/autoupdate-1-configfrom
yx/autoupdate-2-checker
Open

autoupdate 2/3: Add version check and update marker#1768
yahanxing-stripe wants to merge 1 commit into
yx/autoupdate-1-configfrom
yx/autoupdate-2-checker

Conversation

@yahanxing-stripe

@yahanxing-stripe yahanxing-stripe commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

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

  • Unit tests for major version detection logic
  • Unit tests for marker file read/write/clear
  • Unit test for recordLastCheck timestamp
  • Unit test for checksum verification

🤖 Generated with Claude Code

After each command completes, check for a newer CLI version (once per
day max). If a minor/patch update is available, write a marker file to
~/.stripe/state/update-available. Major version changes are skipped.

The marker will be consumed by the apply step (next PR in the stack).

This is part 2/3 of the auto-update feature for curl-installed binaries.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
Comment thread pkg/autoupdate/checker.go
Comment on lines +72 to +84
func isMajorVersionChange(current, latest string) bool {
currentMajor := majorVersion(current)
latestMajor := majorVersion(latest)
return currentMajor != "" && latestMajor != "" && currentMajor != latestMajor
}

func majorVersion(v string) string {
parts := strings.SplitN(v, ".", 2)
if len(parts) == 0 {
return ""
}
return parts[0]
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a semver library that we use in other places, could we use that here? Just to avoid having to maintain this or have to handle non-semver values

Comment thread pkg/autoupdate/checker.go

func fetchLatestRelease() (ver string, downloadURL string, checksum string) {
client := github.NewClient(nil)
release, _, err := client.Repositories.GetLatestRelease(context.Background(), "stripe", "stripe-cli")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we time out after some amount of time?

Comment thread pkg/autoupdate/checker.go
}

func fetchChecksumForAsset(checksumURL, assetName string) string {
resp, err := http.Get(checksumURL) //nolint:gosec

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question about timeout here

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.

3 participants