sonatype-nexus-community / nancy

A tool to check for vulnerabilities in your Golang dependencies, powered by Sonatype OSS Index
Apache License 2.0
549 stars 76 forks source link

Update check #208

Closed bhamail closed 3 years ago

bhamail commented 3 years ago

Automatic check for new releases. Prompt user when new version is available.

The automatic check will only occur once every 28 hours. The timestamp of the lookup is stored in an app specific yml file: ~/.ossindex/.nancy-config/update_check.yml

This PR also adds an explicit update command that can be used to force a check for a new release. e.g. nancy update

In order for the release lookup logic to be happy, I had to change the goreleaser release filename template a little. (see .goreleaser.yml) The related logic in the selfupdater is: https://github.com/rhysd/go-github-selfupdate/blob/master/selfupdate/detect.go#L95. The suffixes used to find a matching release file didn't like the 'version' on the tail end, so I moved it. Note: I'm guessing something in homebrew-nancy-tap will need to change to match the new filename pattern (or maybe it'll "just work")?

Once we have some releases with the new filename pattern, I can work on adding "auto update" stuff for certain cases.

It relates to the following issue #s:

cc @bhamail / @DarthHater

bhamail commented 3 years ago

I will look into merging the goreleaser template changes first. That would allow me to do more testing.

zendern commented 3 years ago
$ ./nancy update
Checking for updates...
You are running 0.0.0
A new release is available (1.0.6)
You can visit the Github releases page for the CLI to manually download and install:
https://github.com/sonatype-nexus-community/nancy/releases

As per @bhamail ... this is some sample output

bhamail commented 3 years ago

Fixed a boog in the autocheck execution path. Some sample output:

$ ./nancy 
Checking for updates...
You are running 0.0.0
A new release is available (1.0.6)
You can visit the Github releases page for the CLI to manually download and install:
https://github.com/sonatype-nexus-community/nancy/releases

Usage:
  nancy [flags]
...