mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-25 21:29:14 +02:00
docs: improve hooks, fix typo
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
parent
55dd91e404
commit
3d2f82461f
@ -319,7 +319,7 @@ To make your releases, checksums, and signatures reproducible, you will need to
|
||||
## Import pre-built binaries
|
||||
|
||||
!!! success "GoReleaser Pro"
|
||||
The prebuilt buidler is a [GoReleaser Pro feature](/pro/).
|
||||
The prebuilt builder is a [GoReleaser Pro feature](/pro/).
|
||||
|
||||
Since GoReleaser Pro v0.179.0, it is possible to import pre-built binaries into the GoReleaser lifecycle.
|
||||
|
||||
|
@ -2,64 +2,66 @@
|
||||
title: Global Hooks
|
||||
---
|
||||
|
||||
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.
|
||||
Some release cycles may need run something before or after everything else.
|
||||
|
||||
The configuration is very simple, here is a complete example:
|
||||
GoReleaser allows this with the global hooks feature.
|
||||
|
||||
```yaml
|
||||
# .goreleaser.yml
|
||||
before:
|
||||
# Templates for the commands to be ran.
|
||||
hooks:
|
||||
- make clean
|
||||
- go generate ./...
|
||||
- go mod tidy
|
||||
- touch {{ .Env.FILE_TO_TOUCH }}
|
||||
```
|
||||
=== "OSS"
|
||||
The `before` section allows for global hooks which will be executed before the build is started.
|
||||
|
||||
If any of the hooks fails the build process is aborted.
|
||||
The configuration is very simple, here is a complete example:
|
||||
|
||||
```yaml
|
||||
# .goreleaser.yml
|
||||
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 are [GoReleaser Pro features](/pro/).
|
||||
|
||||
With [GoReleaser Pro](/pro/), things are a bit more flexible: you can specify the dir, environment variables and also global after hooks:
|
||||
|
||||
```yaml
|
||||
# .goreleaser.yml
|
||||
# global before hooks
|
||||
before:
|
||||
# Templates for the commands to be ran.
|
||||
hooks:
|
||||
- make clean # simple string
|
||||
- cmd: go generate ./... # specify cmd
|
||||
- cmd: go mod tidy
|
||||
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:
|
||||
# Templates for the commands to be ran.
|
||||
hooks:
|
||||
- make clean
|
||||
- cmd: cat *.yaml
|
||||
dir: ./submodule
|
||||
- cmd: touch {{ .Env.RELEASE_DONE }}
|
||||
env:
|
||||
RELEASE_DONE: 'something-{{ .ProjectName }}' # specify hook level environment variables
|
||||
```
|
||||
|
||||
|
||||
|
||||
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 real fast.
|
||||
|
||||
|
||||
## Pro Features
|
||||
|
||||
!!! success "GoReleaser Pro"
|
||||
Global after hooks and the additional options in before hooks are [GoReleaser Pro features](/pro/).
|
||||
|
||||
With [GoReleaser Pro](/pro/), things are a bit more flexible: you can specify the dir, environment variables and also global after hooks.
|
||||
|
||||
```yaml
|
||||
# .goreleaser.yml
|
||||
|
||||
# global before hooks
|
||||
before:
|
||||
# Templates for the commands to be ran.
|
||||
hooks:
|
||||
- make clean # simple string
|
||||
- cmd: go generate ./... # specify cmd
|
||||
- cmd: go mod tidy
|
||||
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:
|
||||
# Templates for the commands to be ran.
|
||||
hooks:
|
||||
- make clean
|
||||
- cmd: cat *.yaml
|
||||
dir: ./submodule
|
||||
- cmd: touch {{ .Env.RELEASE_DONE }}
|
||||
env:
|
||||
RELEASE_DONE: 'something-{{ .ProjectName }}' # specify hook level environment variables
|
||||
```
|
||||
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/).
|
||||
|
Loading…
x
Reference in New Issue
Block a user