Skip to content
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

Further configuration for GoBinary in builds #4453

Closed
2 of 3 tasks
SgtCoDFish opened this issue Nov 30, 2023 · 1 comment · Fixed by #4454
Closed
2 of 3 tasks

Further configuration for GoBinary in builds #4453

SgtCoDFish opened this issue Nov 30, 2023 · 1 comment · Fixed by #4454
Assignees
Labels
enhancement New feature or request

Comments

@SgtCoDFish
Copy link

Is your feature request related to a problem? Please describe.

As a way of minimising the tooling required on developer machines, we like to download a Go tarball locally on a per-project basis and use the untarred binary and GOROOT for all development work in that project. That means for a given project GOROOT is project/_bin/go-$GOVERSION/go and the Go binary can be found inside that GOROOT at project/_bin/go-$GOVERSION/go/bin/go.

We'd like to use the same flags for all builds of our projects, and we want to define those flags in goreleaser.yaml

We can set the GOROOT for a goreleaser build using environment variables and that works as expected.

However, it seems environment variable expansion doesn't work inside the goBinary field and there doesn't appear to be any other way to set this field, so we end up having to hack around the problem.

Our hack currently is to create a copy of _bin/go-1.21.4/go/bin/go to _bin/go-vendored which we update whenever our GO_VERSION variable changes. That means we have gobinary: _bin/go-vendored set in goreleaser.yaml, which in turn means that the only way to use goreleaser in this project is through the Makefile.

If we were able to set GOROOT and it were to be searched for the bin/go path, people would be able to use their system go for development if desired while our CI would still use our vendored go.

Describe the solution you'd like

We only need one version of Go per goreleaser.yaml, but others might want a different setup. We would be fine with any solution which lets us have more flexibility around customising the gobinary field. Some examples:

  • Some global env var we can set when we run goreleaser (e.g. GORELEASER_GO_BINARY=_bin/go-1.21.4/bin/go GOROOT=_bin/go-1.21.4/go goreleaser build ...)

  • Environment variable expansion inside the gobinary field, e.g.:

    builds:
    - ...
      gobinary: {{ .Env.GO_BINARY_LOCATION }}
  • (My personal favourite, I think): Some flag which tells goreleaser to look for the go binary in GOROOT rather than defaulting to go, e.g.:

    goBinaryFromGoRoot: true # there'd probably be a better name
    env:
    - GOROOT=.../project/_bin/go-1.21.4/go # since .../project/_bin/go-1.21.4/go/bin/go exists, we use that

    This change might not need a flag, although I suppose it could be breaking for users who set GOROOT today but who for some reason don't have bin/go in their GOROOT.

Describe alternatives you've considered

I can't really see an alternative in our use case but I'd be interested in discussing it!

Search

  • I did search for other open and closed issues before opening this

Supporter

Code of Conduct

  • I agree to follow this project's Code of Conduct

Additional context

No response

@SgtCoDFish SgtCoDFish added enhancement New feature or request triage Issue pending triage by one of the maintainers labels Nov 30, 2023
caarlos0 added a commit that referenced this issue Dec 1, 2023
caarlos0 added a commit that referenced this issue Dec 5, 2023
@SgtCoDFish
Copy link
Author

Thanks very much @caarlos0 ❤️

@caarlos0 caarlos0 removed the triage Issue pending triage by one of the maintainers label Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants