1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/www/docs/customization/env.md

25 lines
733 B
Markdown
Raw Normal View History

2021-10-30 14:50:23 +02:00
# Environment Variables
Global environment variables to be passed down to all hooks and builds.
If you have an environment variable named `FOOBAR` set to `on`, your `.goreleaser.yaml` file could use it like this:
```yaml
# .goreleaser.yaml
env:
- FOO={{ .Env.FOOBAR }}
- ENV_WITH_DEFAULT={{ if index .Env "ENV_WITH_DEFAULT" }}{{ .Env.ENV_WITH_DEFAULT }}{{ else }}default_value{{ end }}
before:
hooks:
- go mod tidy
builds:
- binary: program
```
This way, both your before hooks (in this example, `go mod tidy`) and the underlying builds (using `go build`) will have `FOO` 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/).