github.com/ahmet2mir/goreleaser@v0.180.3-0.20210927151101-8e5ee5a9b8c5/www/docs/customization/hooks.md (about)

     1  ---
     2  title: Global Hooks
     3  ---
     4  
     5  Some release cycles may need run something before or after everything else.
     6  
     7  GoReleaser allows this with the global hooks feature.
     8  
     9  === "OSS"
    10      The `before` section allows for global hooks that will be executed **before** the release is started.
    11  
    12      The configuration is straightforward, here is an example will all possible options:
    13  
    14      ```yaml
    15      # .goreleaser.yml
    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` and `env`) are [GoReleaser Pro features](/pro/).
    28  
    29      The `before` section allows for global hooks that will be executed **before** the release is started.
    30      Likewise, the `after` section allows for global hooks that will be executed **after** the release is started.
    31  
    32      The configuration is straightforward, here is an example will all possible options:
    33  
    34      ```yaml
    35      # .goreleaser.yml
    36      # global before hooks
    37      before:
    38        # Templates for the commands to be ran.
    39        hooks:
    40        - make clean # simple string
    41        - cmd: go generate ./... # specify cmd
    42        - cmd: go mod tidy
    43          dir: ./submodule # specify command working directory
    44        - cmd: touch {{ .Env.FILE_TO_TOUCH }}
    45          env:
    46            FILE_TO_TOUCH: 'something-{{ .ProjectName }}' # specify hook level environment variables
    47  
    48      # global after hooks
    49      after:
    50        # Templates for the commands to be ran.
    51        hooks:
    52        - make clean
    53        - cmd: cat *.yaml
    54          dir: ./submodule
    55        - cmd: touch {{ .Env.RELEASE_DONE }}
    56          env:
    57            RELEASE_DONE: 'something-{{ .ProjectName }}' # specify hook level environment variables
    58      ```
    59  
    60  
    61  Note that if any of the hooks fails the release process is aborted.
    62  
    63  ## Complex commands
    64  
    65  If you need to do anything more complex, it is recommended to create a shell script and call it instead.
    66  You can also go crazy with `sh -c "my commands"`, but it gets ugly really fast.
    67  
    68  !!! tip
    69      Learn more about the [name template engine](/customization/templates/).