Skip to content

Add version flag#385

Merged
justjanne merged 1 commit intojustjanne:mainfrom
marklap:master
Jan 14, 2026
Merged

Add version flag#385
justjanne merged 1 commit intojustjanne:mainfrom
marklap:master

Conversation

@marklap
Copy link
Copy Markdown
Contributor

@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
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
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
Copy Markdown
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^^

@5HT2
Copy link
Copy Markdown

5HT2 commented Oct 15, 2024

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

Did you get a chance to look at it? I made a pull request to @marklap's branch to sync all changes made, it'd be cool to get this PR merged given the value:LoC of it.

image


If there are issues with the implementation itself I'd be happy to help change it or open a new PR on @marklap's behalf if they are too busy. I understand if you have too much on your hands already to spend a ton of energy on it yourself!

@marklap
Copy link
Copy Markdown
Contributor Author

marklap commented Jan 13, 2026

@justjanne The PR has been updated to latest from the upstream branch. I also squashed commits to clean up my branch a git.

Ran tests successfully then did a build and performed a manual functional test. Everything works as expected as far as I can tell. Is there more I can do or should do? Do you think this is acceptable to merge? If there's more that I can do, just let me know.

$ go test -v                                            
=== RUN   Test_detectShell
=== RUN   Test_detectShell/#00
=== RUN   Test_detectShell//bin/sh
=== RUN   Test_detectShell//bin/bash
=== RUN   Test_detectShell//usr/local/bin/bash5
=== RUN   Test_detectShell//usr/bin/zsh
--- PASS: Test_detectShell (0.00s)
    --- PASS: Test_detectShell/#00 (0.00s)
    --- PASS: Test_detectShell//bin/sh (0.00s)
    --- PASS: Test_detectShell//bin/bash (0.00s)
    --- PASS: Test_detectShell//usr/local/bin/bash5 (0.00s)
    --- PASS: Test_detectShell//usr/bin/zsh (0.00s)
PASS
ok  	github.com/justjanne/powerline-go	0.004s
$ CGO_ENABLED=0 go build -o ./powerline-go -trimpath -ldflags '-s -w -X github.com/justjanne/powerline-go/powerline.Version=9.9.9'
$ ./powerline-go -version                                                                                                         
9.9.9

@justjanne justjanne merged commit 4a8abaa into justjanne:main Jan 14, 2026
2 checks passed
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.

4 participants