extract ldflags only à la govvv? #3371
-
Hello, I'm new to goreleaser, I may have missed some behavior. Please gently point me to the correct sample. On a daily building process, I would do get_ldflags.sh was using govvv to extract / generate ldflags strings. outputs: -X main.BuildDate=2022-09-13T05:24:21Z -X main.GitCommit=2b51559 -X main.GitBranch=master -X main.GitState=dirty -X main.GitSummary=v0.6.4-with-no-mangle-double-dash-11-g2b51559 -X main.Version=v0.6.4-with-no-mangle-double-dash -X 'main.GoBuildVersion=go version go1.19.1 linux/amd64' -X 'main.ByUser=sylvain' BUILD_FLAGS=$(shell ./get_ldflags.sh)
docopts: docopts.go Makefile VERSION
go build -o $@ -ldflags "${BUILD_FLAGS} ${LDFLAGS} On dirty not committed, code, etc. We are moving from hand crafted hacky shell script to goreleaser for go cross-compling and publishing release on github. Most of my hacking seems provided out of the box by goreleaser. 😉
builds:
- env:
- CGO_ENABLED=0
targets:
- darwin_amd64
- darwin_arm64
- freebsd_amd64
- linux_386
- linux_amd64
- linux_arm
- windows_amd64
# https://goreleaser.com/customization/templates/
# defaults: https://goreleaser.com/cookbooks/using-main.version
ldflags:
- -X "main.Version={{.Version}}"
- -X "main.BuildDate={{.Date}}"
- -X "main.GitCommit={{.ShortCommit}}"
- -X "main.GoBuildVersion={{.Env.GOVERSION}}" # https://goreleaser.com/customization/build/#passing-environment-variables-to-ldflags But reproducing I tried:
Which randomly does the trick, it still creates all other cross-compiled binaries in here 32bits version: (
Is it a normal behavior? Or Another alternative would to ask Do you know if there's way do grab evaluated ldflags? Or should I parse Regards, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
no that I'm aware of, but some of the vars that govvv provides, goreleaser provides as well: |
Beta Was this translation helpful? Give feedback.
no that I'm aware of, but some of the vars that govvv provides, goreleaser provides as well:
https://goreleaser.com/cookbooks/using-main.version