Skip to content

Global Hooks

Some release cycles may need to run something before or after everything else.

GoReleaser allows this with the global hooks feature.

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:

.goreleaser.yaml
before:
  # Templates for the commands to be ran.
  hooks:
    - make clean
    - go generate ./...
    - go mod tidy
    - touch {{ .Env.FILE_TO_TOUCH }}

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.

Learn more about the template language.
Last updated on