github.com/goreleaser/goreleaser@v1.25.1/www/docs/customization/hooks.md (about) 1 # Global Hooks 2 3 Some release cycles may need to run something before or after everything else. 4 5 GoReleaser allows this with the global hooks feature. 6 7 === "OSS" 8 The `before` section allows for global hooks that will be executed 9 **before** the release is started. 10 11 The configuration is straightforward, here is an example will all possible 12 options: 13 14 ```yaml 15 # .goreleaser.yaml 16 before: 17 # Templates for the commands to be ran. 18 hooks: 19 - make clean 20 - go generate ./... 21 - go mod tidy 22 - touch {{ .Env.FILE_TO_TOUCH }} 23 ``` 24 25 === "Pro" 26 !!! success "GoReleaser Pro" 27 Global after hooks, and the additional options in before hooks (`dir` 28 and `env`) are [GoReleaser Pro features](/pro/). 29 30 The `before` section allows for global hooks that will be executed 31 **before** the release is started. Likewise, the `after` section allows for 32 global hooks that will be executed **after** the release is started. 33 34 The configuration is straightforward, here is an example will all possible 35 options: 36 37 ```yaml 38 # .goreleaser.yaml 39 # global before hooks 40 before: 41 # Commands to be ran. 42 # 43 # Templates: allowed 44 hooks: 45 - make clean # simple string 46 - cmd: go generate ./... # specify cmd 47 - cmd: go mod tidy 48 # Always prints command output. 49 # 50 # Since: v1.5 51 output: true 52 dir: ./submodule # specify command working directory 53 - cmd: touch {{ .Env.FILE_TO_TOUCH }} 54 env: 55 - 'FILE_TO_TOUCH=something-{{ .ProjectName }}' # specify hook level environment variables 56 57 # global after hooks 58 after: 59 # Commands to be ran. 60 # 61 # Templates: allowed 62 hooks: 63 - make clean 64 - cmd: cat *.yaml 65 dir: ./submodule 66 - cmd: touch {{ .Env.RELEASE_DONE }} 67 env: 68 - 'RELEASE_DONE=something-{{ .ProjectName }}' # specify hook level environment variables 69 ``` 70 71 72 Note that if any of the hooks fails the release process is aborted. 73 74 ## Complex commands 75 76 If you need to do anything more complex, it is recommended to create a shell 77 script and call it instead. You can also go crazy with `sh -c "my commands"`, 78 but it gets ugly really fast. 79 80 !!! tip 81 Learn more about the [name template engine](/customization/templates/).