1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-26 04:22:05 +02:00
Carlos Alexandro Becker cf4aba68d3
feat: global env and template-able before hooks (#974)
* feat: global env

* docs: hooks templateable, global env

* docs: hooks templateable, global env

* feat: templas on before hooks

* docs: revert unwanted change

* fix: use os.environ too

* chore: travis

* fix: goreleaser.yml
2019-03-03 14:12:22 -03:00

33 lines
895 B
Markdown

---
title: Global Hooks
series: customization
hideFromIndex: true
weight: 20
---
Some builds may need pre-build steps before building, e.g. `go generate`.
The `before` section allows for global hooks which will be executed before
the build is started.
The configuration is very simple, here is a complete example:
```yml
# .goreleaser.yml
before:
# Templates for the commands to be ran.
hooks:
- make clean
- go generate ./...
- go mod download
- touch {{ .Env.FILE_TO_TOUCH }}
```
If any of the hooks fails the build process is aborted.
It is important to note that you can't have "complex" commands, like
`bash -c "echo foo bar"` or `foo | bar` or anything like that. If you need
to do things that are more complex than just calling a command with some
attributes, wrap it in a shell script or into your `Makefile`.
> Learn more about the [name template engine](/templates).