devops-works / binenv

One binary to rule them all. Manage all those pesky binaries (kubectl, helm, terraform, ...) easily.
MIT License
373 stars 44 forks source link

string -> int type conversion loses `0` prefix in numbers (was: How add app when release with date ?) #138

Open patsevanton opened 3 years ago

patsevanton commented 3 years ago

Hello! Thanks for binenv. I try add app https://github.com/deref/exo to binenv. But app when release with date

leucos commented 3 years ago

Hey @patsevanton

It should be the same as usual. The culprit here is that version contains a v. So to handle this, you could use {{ .VersionMajor }}, {{ .VersionMinor }} and {{ .VersionPatch }}.

See bomberman for an example.

Good luck & tell us how it goes.

patsevanton commented 3 years ago

Thanks. But it another quiestion - https://github.com/deref/exo/releases/download/v2021.07.30/exo-2021.07.30-linux-amd64

Download link have date.

leucos commented 3 years ago

This almost works:

fetch:
  url: https://github.com/deref/exo/releases/download/v{{ .VersionMajor }}.{{ .VersionMinor }}.{{ .VersionPatch }}/exo-{{ .VersionMajor }}.{{ .VersionMinor }}.{{ .VersionPatch }}-{{ .OS }}-{{ .Arch }}

However, since there is some type conversion from string to int somewhere, the generated link is

https://github.com/deref/exo/releases/download/v2021.7.30/exo-2021.7.30-linux-amd64

instead of

https://github.com/deref/exo/releases/download/v2021.07.30/exo-2021.07.30-linux-amd64

So I guess we're stuck for now on this one.

leucos commented 2 years ago

Luckily there is a 2021.10.12 version :D

leucos commented 2 years ago

The "issue" comes from the upstream library https://github.com/hashicorp/go-version/blob/master/version.go#L69 See also https://github.com/hashicorp/go-version/issues/86