1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00
Carlos Alexandro Becker d524d93086
docs: standarizing docs defaults, since, etc (#3898)
- [x] if the default is the zero-value for the field, do not specify
- [ ] TODO: add a "how to read this docs" section somewhere explaining
that
- [x] if the change was introduced in a v1.x.0, say only v1.x
- [x] drop trail ending `.` from Since, Default, etc
- [x] wording: always use `Default: ` instead of `Defaults to` and
others
- [x] add a note to templateable fields
- [x] default value of a field, if its a string, always between single
quotes `'`

---------

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
2023-04-02 17:16:21 -03:00

82 lines
2.3 KiB
Markdown

# Global Hooks
Some release cycles may need to run something before or after everything else.
GoReleaser allows this with the global hooks feature.
=== "OSS"
The `before` section allows for global hooks that will be executed
**before** the release is started.
The configuration is straightforward, here is an example will all possible
options:
```yaml
# .goreleaser.yaml
before:
# Templates for the commands to be ran.
hooks:
- make clean
- go generate ./...
- go mod tidy
- touch {{ .Env.FILE_TO_TOUCH }}
```
=== "Pro"
!!! success "GoReleaser Pro"
Global after hooks, and the additional options in before hooks (`dir`
and `env`) are [GoReleaser Pro features](/pro/).
The `before` section allows for global hooks that will be executed
**before** the release is started. Likewise, the `after` section allows for
global hooks that will be executed **after** the release is started.
The configuration is straightforward, here is an example will all possible
options:
```yaml
# .goreleaser.yaml
# global before hooks
before:
# Commands to be ran.
#
# Templates: allowed
hooks:
- make clean # simple string
- cmd: go generate ./... # specify cmd
- cmd: go mod tidy
# Always prints command output.
#
# Since: v1.5
output: true
dir: ./submodule # specify command working directory
- cmd: touch {{ .Env.FILE_TO_TOUCH }}
env:
- 'FILE_TO_TOUCH=something-{{ .ProjectName }}' # specify hook level environment variables
# global after hooks
after:
# Commands to be ran.
#
# Templates: allowed
hooks:
- make clean
- cmd: cat *.yaml
dir: ./submodule
- cmd: touch {{ .Env.RELEASE_DONE }}
env:
- 'RELEASE_DONE=something-{{ .ProjectName }}' # specify hook level environment variables
```
Note that if any of the hooks fails the release process is aborted.
## Complex commands
If you need to do anything more complex, it is recommended to create a shell
script and call it instead. You can also go crazy with `sh -c "my commands"`,
but it gets ugly really fast.
!!! tip
Learn more about the [name template engine](/customization/templates/).