1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-26 04:22:05 +02:00

fix: pass tree state as ldflag (#3968)

needs #3967

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker 2023-05-02 01:04:48 -03:00 committed by GitHub
parent 4330b522ea
commit 45b80dfa26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -37,7 +37,7 @@ builds:
flags:
- -trimpath
ldflags:
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{ .CommitDate }} -X main.builtBy=goreleaser
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{ .CommitDate }} -X main.builtBy=goreleaser -X main.treeState={{ .IsGitDirty }}
universal_binaries:
- replace: false

12
main.go
View File

@ -15,10 +15,11 @@ import (
// nolint: gochecknoglobals
var (
version = ""
commit = ""
date = ""
builtBy = ""
version = ""
commit = ""
treeState = ""
date = ""
builtBy = ""
)
func init() {
@ -55,6 +56,9 @@ func buildVersion(version, commit, date, builtBy string) goversion.Info {
if commit != "" {
i.GitCommit = commit
}
if treeState != "" {
i.GitTreeState = treeState
}
if date != "" {
i.BuildDate = date
}