github.com/goreleaser/goreleaser@v1.25.1/www/docs/customization/release.md (about)

     1  # Release
     2  
     3  GoReleaser can create a GitHub/GitLab/Gitea release with the current tag, upload
     4  all the artifacts and generate the changelog based on the new commits since the
     5  previous tag.
     6  
     7  ## GitHub
     8  
     9  Let's see what can be customized in the `release` section for GitHub:
    10  
    11  ```yaml
    12  # .goreleaser.yaml
    13  release:
    14    # Repo in which the release will be created.
    15    # Default is extracted from the origin remote URL or empty if its private hosted.
    16    github:
    17      owner: user
    18      name: repo
    19  
    20    # IDs of the archives to use.
    21    # Empty means all IDs.
    22    #
    23    # Default: []
    24    ids:
    25      - foo
    26      - bar
    27  
    28    # If set to true, will not auto-publish the release.
    29    # Note: all GitHub releases start as drafts while artifacts are uploaded.
    30    # Available only for GitHub and Gitea.
    31    draft: true
    32  
    33    # Whether to remove existing draft releases with the same name before creating
    34    # a new one.
    35    #
    36    # Only effective if `draft` is set to true.
    37    # Available only for GitHub.
    38    #
    39    # Since: v1.11
    40    replace_existing_draft: true
    41  
    42    # Whether to remove an artifact that already exists.
    43    #
    44    # Available only for GitHub.
    45    # This might be a bit expensive (rate-limiting speaking), so it is only done
    46    # when the upload of an artifact fails with a 422 (which means it already
    47    # exists in the release).
    48    # We then grab the list of artifacts from the release, and delete the file
    49    # that matches the one we're trying to upload.
    50    # GoReleaser will then retry its upload.
    51    #
    52    # Since: v1.25
    53    replace_existing_artifacts: true
    54  
    55    # Useful if you want to delay the creation of the tag in the remote.
    56    # You can create the tag locally, but not push it, and run GoReleaser.
    57    # It'll then set the `target_commitish` portion of the GitHub release to the
    58    # value of this field.
    59    # Only works on GitHub.
    60    #
    61    # Since: v1.11
    62    # Default: ''
    63    # Templates: allowed
    64    target_commitish: "{{ .Commit }}"
    65  
    66    # This allows to change which tag GitHub will create.
    67    # Usually you'll use this together with `target_commitish`, or if you want to
    68    # publish a binary from a monorepo into a public repository somewhere, without
    69    # the tag prefix.
    70    #
    71    # Since: v1.19 (pro)
    72    # Default: '{{ .PrefixedCurrentTag }}'
    73    # Templates: allowed
    74    tag: "{{ .CurrentTag }}"
    75  
    76    # If set, will create a release discussion in the category specified.
    77    #
    78    # Warning: do not use categories in the 'Announcement' format.
    79    #  Check https://github.com/goreleaser/goreleaser/issues/2304 for more info.
    80    #
    81    # Default is empty.
    82    discussion_category_name: General
    83  
    84    # If set to auto, will mark the release as not ready for production
    85    # in case there is an indicator for this in the tag e.g. v1.0.0-rc1
    86    # If set to true, will mark the release as not ready for production.
    87    # Default is false.
    88    prerelease: auto
    89  
    90    # If set to false, will NOT mark the release as "latest".
    91    # This prevents it from being shown at the top of the release list,
    92    # and from being returned when calling https://api.github.com/repos/OWNER/REPO/releases/latest.
    93    #
    94    # Available only for GitHub.
    95    #
    96    # Default is true.
    97    # Since: v1.20
    98    make_latest: true
    99  
   100    # What to do with the release notes in case there the release already exists.
   101    #
   102    # Valid options are:
   103    # - `keep-existing`: keep the existing notes
   104    # - `append`: append the current release notes to the existing notes
   105    # - `prepend`: prepend the current release notes to the existing notes
   106    # - `replace`: replace existing notes
   107    #
   108    # Default is `keep-existing`.
   109    mode: append
   110  
   111    # Header for the release body.
   112    #
   113    # Templates: allowed
   114    header: |
   115      ## Some title ({{ .Date }})
   116  
   117      Welcome to this new release!
   118  
   119    # Header for the release body.
   120    #
   121    # This feature is only available in GoReleaser Pro.
   122    # Since v1.20 (pro)
   123    header:
   124      # Loads from an URL.
   125      from_url:
   126        # Templates: allowed
   127        url: https://foo.bar/header.md
   128        headers:
   129          x-api-token: "${MYCOMPANY_TOKEN}"
   130  
   131      # Loads from a local file.
   132      # Overrides `from_url`.
   133      from_file:
   134        # Templates: allowed
   135        path: ./header.md
   136  
   137    # Footer for the release body.
   138    #
   139    # Templates: allowed
   140    footer: |
   141      ## Thanks
   142  
   143      Those were the changes on {{ .Tag }}!
   144  
   145    # Footer for the release body.
   146    #
   147    # This feature is only available in GoReleaser Pro.
   148    # Since v1.20 (pro)
   149    footer:
   150      # Loads from an URL.
   151      from_url:
   152        # Templates: allowed
   153        url: https://foo.bar/footer.md
   154        footers:
   155          x-api-token: "${MYCOMPANY_TOKEN}"
   156  
   157      # Loads from a local file.
   158      # Overrides `from_url`.
   159      from_file:
   160        # Templates: allowed
   161        path: ./footer.md
   162  
   163    # You can change the name of the release.
   164    #
   165    # Default: '{{.Tag}}' ('{{.PrefixedTag}}' on Pro)
   166    # Templates: allowed
   167    name_template: "{{.ProjectName}}-v{{.Version}} {{.Env.USER}}"
   168  
   169    # You can disable this pipe in order to not create the release on any SCM.
   170    # Keep in mind that this might also break things that depend on the release
   171    # URL, for instance, homebrew taps.
   172    #
   173    # Templates: allowed (since v1.15)
   174    disable: true
   175  
   176    # Set this to true if you want to disable just the artifact upload to the SCM.
   177    # If this is true, GoReleaser will still create the release with the
   178    # changelog, but won't upload anything to it.
   179    #
   180    # Since: v1.11
   181    # Templates: allowed (since v1.15)
   182    skip_upload: true
   183  
   184    # You can add extra pre-existing files to the release.
   185    # The filename on the release will be the last part of the path (base).
   186    # If another file with the same name exists, the last one found will be used.
   187    #
   188    # Templates: allowed
   189    extra_files:
   190      - glob: ./path/to/file.txt
   191      - glob: ./glob/**/to/**/file/**/*
   192      - glob: ./glob/foo/to/bar/file/foobar/override_from_previous
   193      - glob: ./single_file.txt
   194        name_template: file.txt # note that this only works if glob matches 1 file only
   195  
   196    # Additional templated extra files to add to the release.
   197    # Those files will have their contents pass through the template engine,
   198    # and its results will be added to the release.
   199    #
   200    # This feature is only available in GoReleaser Pro.
   201    # Since: v1.17 (pro)
   202    # Templates: allowed
   203    templated_extra_files:
   204      - src: LICENSE.tpl
   205        dst: LICENSE.txt
   206  
   207    # Upload metadata.json and artifacts.json to the release as well.
   208    #
   209    # Since: v1.25
   210    include_meta: true
   211  
   212  ```
   213  
   214  !!! tip
   215  
   216      [Learn how to set up an API token, GitHub Enterprise, etc](/scm/github/).
   217  
   218  !!! success "GoReleaser Pro"
   219  
   220      Some options are exclusive [GoReleaser Pro features](/pro/).
   221  
   222  ## GitLab
   223  
   224  Let's see what can be customized in the `release` section for GitLab.
   225  
   226  ```yaml
   227  # .goreleaser.yaml
   228  release:
   229    # Default is extracted from the origin remote URL or empty if its private
   230    # hosted.
   231    # You can also use Gitlab's internal project id by setting it in the name
   232    #  field and leaving the owner field empty.
   233    gitlab:
   234      owner: user
   235      name: repo
   236  
   237    # IDs of the archives to use.
   238    ids:
   239      - foo
   240      - bar
   241  
   242    # You can change the name of the release.
   243    #
   244    # Default: '{{.Tag}}' ('{{.PrefixedTag}}' on Pro)
   245    # Templates: allowed
   246    name_template: "{{.ProjectName}}-v{{.Version}} {{.Env.USER}}"
   247  
   248    # You can disable this pipe in order to not upload any artifacts.
   249    disable: true
   250  
   251    # What to do with the release notes in case there the release already exists.
   252    #
   253    # Valid options are:
   254    # - `keep-existing`: keep the existing notes
   255    # - `append`: append the current release notes to the existing notes
   256    # - `prepend`: prepend the current release notes to the existing notes
   257    # - `replace`: replace existing notes
   258    #
   259    # Default: 'keep-existing'
   260    mode: append
   261  
   262    # You can add extra pre-existing files to the release.
   263    # The filename on the release will be the last part of the path (base).
   264    # If another file with the same name exists, the last one found will be used.
   265    #
   266    # Templates: allowed
   267    extra_files:
   268      - glob: ./path/to/file.txt
   269      - glob: ./glob/**/to/**/file/**/*
   270      - glob: ./glob/foo/to/bar/file/foobar/override_from_previous
   271      - glob: ./single_file.txt
   272        name_template: file.txt # note that this only works if glob matches 1 file only
   273  ```
   274  
   275  !!! tip
   276  
   277      [Learn how to set up an API token, self-hosted GitLab, etc](/scm/gitlab/).
   278  
   279  !!! tip
   280  
   281      If you use GitLab subgroups, you need to specify it in the `owner` field,
   282      e.g. `mygroup/mysubgroup`.
   283  
   284  !!! warning
   285  
   286      Only GitLab `v12.9+` is supported for releases.
   287  
   288  ## Gitea
   289  
   290  You can also configure the `release` section to upload to a [Gitea](https://gitea.io) instance:
   291  
   292  ```yaml
   293  # .goreleaser.yaml
   294  release:
   295    gitea:
   296      owner: user
   297      name: repo
   298  
   299    # IDs of the artifacts to use.
   300    ids:
   301      - foo
   302      - bar
   303  
   304    # You can change the name of the release.
   305    #
   306    # Default: '{{.Tag}}' ('{{.PrefixedTag}}' on Pro)
   307    # Templates: allowed
   308    name_template: "{{.ProjectName}}-v{{.Version}} {{.Env.USER}}"
   309  
   310    # You can disable this pipe in order to not upload any artifacts.
   311    disable: true
   312  
   313    # What to do with the release notes in case there the release already exists.
   314    #
   315    # Valid options are:
   316    # - `keep-existing`: keep the existing notes
   317    # - `append`: append the current release notes to the existing notes
   318    # - `prepend`: prepend the current release notes to the existing notes
   319    # - `replace`: replace existing notes
   320    #
   321    # Default: 'keep-existing'
   322    mode: append
   323  
   324    # You can add extra pre-existing files to the release.
   325    # The filename on the release will be the last part of the path (base).
   326    # If another file with the same name exists, the last one found will be used.
   327    #
   328    # Templates: allowed
   329    extra_files:
   330      - glob: ./path/to/file.txt
   331      - glob: ./glob/**/to/**/file/**/*
   332      - glob: ./glob/foo/to/bar/file/foobar/override_from_previous
   333      - glob: ./single_file.txt
   334        name_template: file.txt # note that this only works if glob matches 1 file only
   335  ```
   336  
   337  To enable uploading `tar.gz` and `checksums.txt` files you need to add the
   338  following to your Gitea config in `app.ini`:
   339  
   340  ```ini
   341  [attachment]
   342  ALLOWED_TYPES = application/gzip|application/x-gzip|application/x-gtar|application/x-tgz|application/x-compressed-tar|text/plain
   343  ```
   344  
   345  !!! tip
   346  
   347      [Learn how to set up an API token](/scm/gitea/).
   348  
   349  !!! tip
   350  
   351      Learn more about the [name template engine](/customization/templates/).
   352  
   353  !!! warning
   354  
   355      Gitea versions earlier than 1.9.2 do not support uploading `checksums.txt`
   356      files because of a [bug](https://github.com/go-gitea/gitea/issues/7882),
   357      so you will have to enable all file types with `*/*`.
   358  
   359  !!! warning
   360  
   361      `draft` and `prerelease` are only supported by GitHub and Gitea.
   362  
   363  ### Define Previous Tag
   364  
   365  GoReleaser uses `git describe` to get the previous tag used for generating the
   366  Changelog. You can set a different build tag using the environment variable
   367  `GORELEASER_PREVIOUS_TAG`. This is useful in scenarios where two tags point to
   368  the same commit.
   369  
   370  The [Nightly](/customization/nightlies) is automatically ignored, even if set
   371  via the environment variables above.
   372  
   373  ## Custom release notes
   374  
   375  You can specify a file containing your custom release notes, and pass it with
   376  the `--release-notes=FILE` flag. GoReleaser will then skip its own release notes
   377  generation, using the contents of your file instead. You can use Markdown to
   378  format the contents of your file.
   379  
   380  On Unix systems you can also generate the release notes in-line by using
   381  [process substitution](https://en.wikipedia.org/wiki/Process_substitution). To
   382  list all commits since the last tag, but skip ones starting with `Merge` or
   383  `docs`, you could run this command:
   384  
   385  ```sh
   386  goreleaser release --release-notes <(some_changelog_generator)
   387  ```
   388  
   389  Some changelog generators you can use:
   390  
   391  - [buchanae/github-release-notes](https://github.com/buchanae/github-release-notes)
   392  - [miniscruff/changie](https://github.com/miniscruff/changie)
   393  
   394  !!! info
   395  
   396      If you create the release before running GoReleaser, and the said release
   397      has some text in its body, GoReleaser will not override it with its release
   398      notes.