Skip to content

AGE-120: display message when new version available#54

Merged
murrayju merged 23 commits intomainfrom
murrayju/version-check
Oct 15, 2025
Merged

AGE-120: display message when new version available#54
murrayju merged 23 commits intomainfrom
murrayju/version-check

Conversation

@murrayju
Copy link
Member

@murrayju murrayju commented Oct 10, 2025

This pulls the latest release version number from the (configurable) S3 bucket url, compares it to the current version, and outputs a message when outdated. This is performed at most once per hour (also configurable), with the last check time stored in the config file.

We attempt to determine the installation method based on the current binary's path, and output a helpful message for how to upgrade as well (e.g. brew upgrade tiger-cli).

I made tiger version skip this implicit check, instead adding an explicit tiger version --check that forces checking (regardless of last check time).

image

Finally, I also implemented some --output options for the version command, to conform to table formatting by default, with json, yaml, and bare (only the version number) to making parsing for scripting tasks easier.

image

Includes the new version when --check is used
image

-o bare will be easiest to just capture the version number
image

@murrayju
Copy link
Member Author

murrayju commented Oct 10, 2025

I created an alpha prerelease from this branch to test this out on the various platforms.

Can get the binary via:

curl -fsSL https://tiger-cli-releases.s3.amazonaws.com/install/install.sh | VERSION=v0.0.0-alpha.20  sh

macos

curl

image

homebrew

image

linux

curl

image

deb

image

rpm + dnf

docker run --rm -it -v ~/Downloads/tiger-cli-0.0.0.alpha.20-1.aarch64.rpm:/tmp/package.rpm rockylinux:9 bash -c "dnf install -y /tmp/package.rpm && tiger version --check"
image

rpm + yum

docker run --rm -it -v ~/Downloads/tiger-cli-0.0.0.alpha.20-1.aarch64.rpm:/tmp/package.rpm centos:7 bash -c "yum install -y /tmp/package.rpm && tiger version --check"
image

@murrayju murrayju marked this pull request as ready for review October 10, 2025 20:07
table.Append("version_check_interval", fmt.Sprintf("%d seconds", *cfg.VersionCheckInterval))
}
if cfg.VersionCheckLastTime != nil {
table.Append("version_check_last_time", time.Unix(int64(*cfg.VersionCheckLastTime), 0).Format(time.RFC1123))
Copy link
Member Author

Choose a reason for hiding this comment

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

I figured it'd be nice for the table output format to be more human readable. Open to a different formatting choice, or just the raw number if people think that's better.

Image

return fmt.Errorf("failed to load config: %w", err)
}

if err := logging.Init(cfg.Debug); err != nil {
Copy link
Member Author

Choose a reason for hiding this comment

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

I fixed this unrelated bug, where debug from the config file/env was not being used (only the cli flag worked)

# Test that the binary is executable and get version
local installed_version
if installed_version=$("${binary_path}" version 2>/dev/null | head -n1 || echo ""); then
if installed_version=$("${binary_path}" version -o bare 2>/dev/null | head -n1 || echo ""); then
Copy link
Member Author

Choose a reason for hiding this comment

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

To fix this:

Image

Copy link
Contributor

@cevian cevian left a comment

Choose a reason for hiding this comment

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

Looks mostly good but I would like to see if we can use more of golang's time and interval types natively

}

// DetectInstallMethod determines how Tiger CLI was installed
func detectInstallMethod(binaryPath string) InstallMethod {
Copy link
Contributor

Choose a reason for hiding this comment

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

dislike this but don't know if there is a better way. We could run tiger config set install_method deb and similar in post-install scripts. but that has its own complexity (which I think is better but wont inisist).

Copy link
Member Author

Choose a reason for hiding this comment

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

The GitHub cli uses detection (similar to this), but they also only bother to detect homebrew.

I do think good detection logic is going to be more reliable than writing to the config file, which can easily be altered/reset. Either way, it is easy to think of ways to break it... we could bail on attempts to be helpful, and instead show a more generic "update according to your install method" message (or no message at all).

This is again a case of code written by Claude, that I tested and appears to work well. I'm not convinced that there is a good reason to rework it a different way.

}
return "sudo yum update tiger-cli"
case InstallMethodInstallSh:
return "curl -fsSL https://tiger-cli-releases.s3.amazonaws.com/install/install.sh | sh"
Copy link
Contributor

Choose a reason for hiding this comment

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

will have to remember to replace when changing url (Not to self)

Copy link
Member Author

Choose a reason for hiding this comment

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

This helps, but I think we'll also change the subpath
7b25e54

@murrayju murrayju requested a review from cevian October 14, 2025 16:12
Copy link
Member

@nathanjcochran nathanjcochran left a comment

Choose a reason for hiding this comment

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

Didn't get far into reviewing, but left a couple minor comments about things I noticed.

Can continue reviewing tomorrow if Mat doesn't get to it first.

Comment on lines +147 to +148
"releases_url": "https://cli.tigerdata.com",
"version_check_interval": float64(3600000000000), // JSON unmarshals time.Duration as nanoseconds (1 hour = 3600000000000ns)
Copy link
Member

@nathanjcochran nathanjcochran Oct 14, 2025

Choose a reason for hiding this comment

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

This test doesn't appear to check for the presence of version_check_last_time. Might be good to include (I think all of the other config options are included here 🤔). Same for the other tests below.

If the problem is that version_check_last_time is non-deterministic, we might want to stub out time.Now and mock it in these tests. That's usually done like this:

  1. Do this in the code itself, and call now() instead of time.Now()
var now = time.Now
  1. Do this to mock it in the tests (and don't forget to reset it when the test is finished, either via a defer call or T.Cleanup):
now = func() time.Time {
    return time.Date(2025, time.October, 14, 12, 0, 0, 0, time.UTC)
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@cevian cevian left a comment

Choose a reason for hiding this comment

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

a few optional comments

},
}

cmd.Flags().BoolVar(&checkVersion, "check", false, "Check for the latest version")
Copy link
Contributor

Choose a reason for hiding this comment

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

I still don't get why we don't just use the existing global. but don't feel too strongly

Copy link
Member Author

Choose a reason for hiding this comment

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

This is to force a check, regardless of last check time. The global is --skip-update-check. Maybe you are thinking --skip-update-check=false? That doesn't quite seem clear enough to me, plus it is much more to type.

Copy link
Member Author

Choose a reason for hiding this comment

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

This should help: f322c16

@murrayju murrayju merged commit cb63bb5 into main Oct 15, 2025
2 checks passed
@murrayju murrayju deleted the murrayju/version-check branch October 15, 2025 16:09
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