Open marklap opened 1 year ago
@marklap
Goreleaser adds -X main.version={{.Version}}
by default (see: https://goreleaser.com/customization/builds/)
then either put this variable to main
package or add:
ldflags:
- -s -w -X powerline.Version={{.Version}}
to .goreleaser.yaml
@dex4er I was not able to get a relative import path to work. Only the fully qualified import path works.
$ CGO_ENABLED=0 go build -trimpath -ldflags '-s -w -X github.com/justjanne/powerline-go/powerline.Version=1.2.3' -o powerline-go-dev
$ powerline-go-dev -version
1.2.3
$ CGO_ENABLED=0 go build -trimpath -ldflags '-s -w -X powerline.Version=1.2.3' -o powerline-go-dev
$ powerline-go-dev -version
development
Do you get the same results? If you do, can the PR able to be merged as is?
@justjanne Can you accept this PR? It will help us to verify if correct version of powerline-go is installed. Also it will simplify my CI test for https://github.com/dex4er/asdf-powerline-go
@dex4er I'll look into it this weekend. I'll try to find some time to make a few changes to powerline-go in the next week anyway, a version flag would definitely be part of that^^
Intended to add support for a version flag that is updated automatically at build time (and reflected in the build artifacts). Disclaimer: I know nothing about goreleaser so my assumptions may be bad and more work on this PR may be needed. Of course I'm happy to do the work, but some guidance from someone more familiar with goreleaser would be much appreciated.
ref: https://github.com/justjanne/powerline-go/issues/78