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

Add version flag #385

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Add version flag #385

wants to merge 7 commits into from

Conversation

marklap
Copy link

@marklap marklap commented Jun 9, 2023

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: #78

@dex4er
Copy link
Contributor

dex4er commented Aug 7, 2023

@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

@marklap
Copy link
Author

marklap commented Sep 8, 2023

@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?

@dex4er
Copy link
Contributor

dex4er commented Sep 9, 2023

@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

@justjanne
Copy link
Owner

@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^^

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.

None yet

3 participants