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
feat: allow to override build flags by goos/goarch/etc #2860
Conversation
Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
Codecov Report
@@ Coverage Diff @@
## main #2860 +/- ##
=========================================
+ Coverage 0 84.45% +84.45%
=========================================
Files 0 111 +111
Lines 0 8837 +8837
=========================================
+ Hits 0 7463 +7463
- Misses 0 1105 +1105
- Partials 0 269 +269
Continue to review full report at Codecov.
|
Hey @caarlos0 👋 This looks like its going in the right direction, although I'm having a little trouble verifying it after installing from this branch. It seems to be losing all the build configuration in the Configuration: builds:
- flags:
- -trimpath
goos:
- darwin
- freebsd
- linux
- windows
goarch:
- '386'
- amd64
- arm
- arm64
ignore:
- goarch: arm
goos: windows
- goarch: arm64
goos: freebsd
- goarch: arm64
goos: windows
ldflags:
- -s -w -X main.Version={{.Version}}
mod_timestamp: '{{ .CommitTimestamp }}'
# overrides:
# - goos: darwin
# goarch: amd64
# tags:
# - netcgo Environment: ❯ go env GOOS
darwin
❯ go env GOARCH
amd64 Command: goreleaser build --snapshot --rm-dist --single-target --debug v1.4.1 output:
buildconf output (no overrides):
buildconf output (with overrides uncommented, no goarm or gomips in override):
buildconf output (with overrides uncommented and goarm: 6 and gomips: hardfloat in override):
Not sure about the missing goreleaser/internal/builders/golang/build.go Lines 57 to 62 in 3f593d7
|
Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
pushed some changes... it should now merge overrides into the build values, so it won't loose configs anymore also, you can now template the goos/goarch/etc on overrides as well, in which you can for example use |
Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like its now selecting and merging correctly 🎉 although I think the build command logic might still need some updates to ensure its checking the details/overrides 😄
Co-authored-by: Brian Flad <bflad417@gmail.com>
Co-authored-by: Brian Flad <bflad417@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is working as I would anticipate! 🎉 Thanks so much.
Totally fine as something in the future: I'm also wondering if env
should allow similar overrides since I don't believe it can be templated and setting CGO_ENABLED between platforms (or other go command environment variables) is a bit awkward. I understand that is more difficult to merge/manage in the code though and happy to submit a followup issue/pull request. 👍
🚀🚀🚀🚀
I was thinking the same... and maybe also other options... but I think that yes, at least for env, we should do it. for envs the endeavor is slightly bigger, as we need to care for build hooks as well https://goreleaser.com/customization/build/#build-hooks but I think we can work on it on a different PR once this one has better coverage and is merged |
Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
refs #2829
allow to override ldflags et al based on the build target
TODO