Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version outputs unknown #181

Closed
runephilosof-karnovgroup opened this issue May 1, 2024 · 5 comments
Closed

version outputs unknown #181

runephilosof-karnovgroup opened this issue May 1, 2024 · 5 comments

Comments

@runephilosof-karnovgroup

I installed gilt:

go install github.com/retr0h/gilt/v2@latest
# go: downloading github.com/retr0h/gilt v1.0.2
# go: downloading github.com/retr0h/gilt/v2 v2.2.0

Version output

go/bin/gilt version
# {"version":"dev","commit":"none","date":"unknown"}

Expected something like

go/bin/gilt version
# {"version":"2.2.0","commit":"185799bf","date":"2024-03-06"}
Copy link
Contributor

github-actions bot commented May 1, 2024

Thank you for your first issue! 😊🕹️

@0xDEC0DE
Copy link
Contributor

0xDEC0DE commented May 1, 2024

Installing released versions appears to report correctly:

$ curl -sLO https://github.com/retr0h/gilt/releases/download/v2.2.0/gilt_2.2.0_darwin_all
$ chmod 0755 gilt_2.2.0_darwin_all
$ ./gilt_2.2.0_darwin_all version
{"version":"2.2.0","commit":"185799bf267bb0965b8969f53791225446939515","date":"2024-03-06T22:34:14Z"}

and:

$ python3 -m venv lol_gilt
$ . lol_gilt/bin/activate
$ pip install python-gilt
Successfully installed python-gilt-2.2.0
$ gilt version
{"version":"2.2.0","commit":"185799bf267bb0965b8969f53791225446939515","date":"2024-03-06T22:34:14Z"}

and building from sources also looks like it works:

$ cd gilt/
$ task build
$ dist/gilt_darwin_all/gilt version
{"version":"2.2.1.dev","commit":"a0408698ee1abb98c54009f0d093e06a6ce78db3","date":"2024-04-29T17:19:53Z"}

So, clearly, we are capable of getting it right SOME of the time...

@0xDEC0DE
Copy link
Contributor

0xDEC0DE commented May 1, 2024

The previous comment somewhat buries the lede in that I am able to reproduce the demonstrated behavior on my machine by running the provided steps.

@retr0h
Copy link
Owner

retr0h commented May 2, 2024

The previous comment somewhat buries the lede in that I am able to reproduce the demonstrated behavior on my machine by running the provided steps.

Yeah, the version is baked into the binary at build by LDFLAGS.

Since go install simply compiles the executable file, it's missing the LDFLAGS context, and reports the hardcoded defaults. I wanted to avoid having to bump version file on every release with a hard coded version number. However, I'm sure there are more creative ways to tackle this or I'm missing something.

Look promising:

@retr0h
Copy link
Owner

retr0h commented May 6, 2024

Best I can do when installing via go install, and matches the behavior of other projects (such as goreleaser), see #191:

~/git/gilt main ≡
(⎈ |N/A:N/A) aws:(default) ❯ go install github.com/retr0h/gilt/v2@latest
go: downloading github.com/retr0h/gilt/v2 v2.2.1
go: downloading github.com/caarlos0/go-version v0.1.1
go: downloading github.com/go-playground/validator/v10 v10.20.0
go: downloading golang.org/x/term v0.19.0
go: downloading golang.org/x/sys v0.19.0
go: downloading golang.org/x/crypto v0.21.0
go: downloading golang.org/x/net v0.23.0

~/git/gilt main ≡
(⎈ |N/A:N/A) aws:(default) ❯ gilt version
{
  "gitVersion": "v2.2.1",
  "moduleCheksum": "h1:VrD5HwhF8O54TEcIaCKpDGigNjjJ3TVJVUTuldnQw+0=",
  "gitCommit": "unknown",
  "gitTreeState": "unknown",
  "buildDate": "unknown",
  "builtBy": "unknown",
  "goVersion": "go1.22.2",
  "compiler": "gc",
  "platform": "darwin/amd64"
}

@retr0h retr0h closed this as completed May 6, 2024
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

No branches or pull requests

3 participants