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
Conditional Build Handling Based on OS Running goreleaser #2829
Comments
this seems reasonable to me, will work on it.
this is also a good idea IMHO, will work on it as well. |
TODO: see if we can do the same for environment variables |
unfortunately, its not possible... we use the env for templates and thing that happen before we even get to the build line stuff... so, we'd had to break compatibility or do something else that would also be probably confusing. refs #2583 that said, as the other things were implement, will close this one for now. if we eventually find out we really really really need the env stuff, we can try to find a way to do it in another issue. Thanks! |
Is your feature request related to a problem? Please describe.
We have a
goreleaser
configuration that is setup with a single cross-compilationbuild
section. We are in the process of trying to conditionally enable CGO/netcgo if thegoreleaser
process is running on the same OS that is being built (or very particularly in our case, if it is running ondarwin
). Builds for other OS should not try to enable that additional configuration as the cross-compilation will fail.Describe the solution you'd like
Initial proposal:
goreleaser
could potentially expose theruntime.GOOS
of thegoreleaser
process as a field in the templating engine, such as.CurrentOS
, then I think we could theoretically setup our configuration like:Other thoughts:
Supporting special build configuration that is per os/arch/target within a build would then allow the configuration to be DRY, e.g.
I'm also not sure if there might be a better way to expose "configuration that should apply when the current os/arch/target matches the running goreleaser process", e.g. very roughly
I think the os/arch/target specific configuration would be more clear than this last one.
Describe alternatives you've considered
Hardcoding some special environment variable flag in the CI configuration, which could then apply a
goreleaser
template with{{ if index .Env "EXAMPLE" }}netcgo{{ end }}
. This only fixes the issue for CI builds though, not local builds usinggoreleaser
without extra documentation (or a specific Makefile target) that can be easily missed. Also, it can fail if incorrectly used.Having separate
goreleaser
configurations for CI versus local or configurations that are OS specific depending on wheregoreleaser
is running.Search
Code of Conduct
Additional context
In our particular situation, this would be a viable workaround for #2320 since we only need CGO/netcgo on one OS (darwin) because of golang/go#12524.
Thanks for such as great project and happy to contribute.
The text was updated successfully, but these errors were encountered: