2021-10-30 14:50:23 +02:00
|
|
|
# Environment Variables
|
2019-03-03 19:12:22 +02:00
|
|
|
|
|
|
|
Global environment variables to be passed down to all hooks and builds.
|
|
|
|
|
2021-12-23 02:52:01 +02:00
|
|
|
This is useful for `GO111MODULE`, for example. You can have your `.goreleaser.yaml` file like the following:
|
2019-03-03 19:12:22 +02:00
|
|
|
|
|
|
|
```yaml
|
2021-12-23 02:52:01 +02:00
|
|
|
# .goreleaser.yaml
|
2019-03-03 19:12:22 +02:00
|
|
|
env:
|
|
|
|
- GO111MODULE=on
|
2021-05-31 03:53:57 +02:00
|
|
|
- FOO={{ .Env.FOOBAR }}
|
|
|
|
- ENV_WITH_DEFAULT={{ if index .Env "ENV_WITH_DEFAULT" }}{{ .Env.ENV_WITH_DEFAULT }}{{ else }}default_value{{ end }}
|
2019-03-03 19:12:22 +02:00
|
|
|
before:
|
|
|
|
hooks:
|
2021-03-03 02:29:31 +02:00
|
|
|
- go mod tidy
|
2019-03-03 19:12:22 +02:00
|
|
|
builds:
|
|
|
|
- binary: program
|
|
|
|
```
|
|
|
|
|
2021-03-03 02:29:31 +02:00
|
|
|
This way, both `go mod tidy` and the underlying `go build` will have
|
2019-03-03 19:12:22 +02:00
|
|
|
`GO111MODULE` set to `on`.
|
|
|
|
|
2021-05-25 04:23:59 +02:00
|
|
|
The root `env` section also accepts templates.
|
|
|
|
|
|
|
|
!!! tip
|
|
|
|
Learn more about the [name template engine](/customization/templates/).
|