Skip to content

feat: Add update and version commands#13

Merged
liamg merged 2 commits into
mainfrom
update-cmd
Mar 10, 2026
Merged

feat: Add update and version commands#13
liamg merged 2 commits into
mainfrom
update-cmd

Conversation

@liamg

@liamg liamg commented Mar 10, 2026

Copy link
Copy Markdown
Member

Summary

  • Add update command that self-updates the CLI binary to the latest GitHub release
  • Add version command that prints the current version

Details

The update command:

  • Fetches the latest release from infracost/cli via the GitHub API
  • Compares it against the current build version using semver (dev builds always update)
  • Downloads the platform-specific asset ({os}_{arch}.tar.gz / .zip) and extracts the binary
  • Atomically replaces the running binary via temp file + rename
  • Authenticates using GH_TOKEN, GITHUB_TOKEN, or gh auth token if available; falls back to unauthenticated access otherwise
  • Looks for infracost-preview in the asset bundle, and falls back to infracost if not found. This will help when we eventually remove the -preview suffix.
  • Uses GH_TOKEN, GITHUB_TOKEN, or gh auth token to authenticate with GitHub to download the asset. Downloads anonymously if this fails.

@liamg
liamg marked this pull request as ready for review March 10, 2026 16:05
@liamg
liamg requested a review from a team March 10, 2026 16:09

@liamcervante liamcervante left a comment

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.

Update the README as well?

@liamg
liamg merged commit 637fc66 into main Mar 10, 2026
4 checks passed
@liamg
liamg deleted the update-cmd branch March 10, 2026 16:33
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.

2 participants