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

     1  # Monorepo
     2  
     3  !!! success "GoReleaser Pro"
     4  
     5      The monorepo support is a [GoReleaser Pro feature](/pro/).
     6  
     7  If you want to use GoReleaser within a monorepo and use tag prefixes to mark
     8  "which tags belong to which sub project", GoReleaser has you covered.
     9  
    10  ## Premises
    11  
    12  You project falls into either one of these categories:
    13  
    14  1. tags are like `subproject1/v1.2.3` and `subproject2/v1.2.3`;
    15  1. tags are like `@user/thing@v1.2.3` (for a NPM package, for example)
    16     and `v1.2.3` for the rest of the (Go) code.
    17  
    18  ## Usage
    19  
    20  ### Category 1
    21  
    22  You'll need to create a `.goreleaser.yaml` for each subproject you want to use
    23  GoReleaser in:
    24  
    25  ```yaml
    26  # subroj1/.goreleaser.yaml
    27  project_name: subproj1
    28  
    29  monorepo:
    30    tag_prefix: subproject1/
    31    dir: subproj1
    32  ```
    33  
    34  Then, you can release with (from the project's root directory):
    35  
    36  ```bash
    37  goreleaser release --clean -f ./subproj1/.goreleaser.yaml
    38  ```
    39  
    40  Then, the following is different from a "regular" run:
    41  
    42  - GoReleaser will then look if current commit has a tag prefixed with
    43    `subproject1`, and the previous tag with the same prefix;
    44  - Changelog will include only commits that contain changes to files within the
    45    `subproj1` directory;
    46  - Release name gets prefixed with `{{ .ProjectName }} ` if empty;
    47  - All build's `dir` setting get set to `monorepo.dir` if empty;
    48    - if yours is not, you might want to change that manually;
    49  - Extra files on the release, archives, Docker builds, etc are prefixed with
    50    `monorepo.dir`;
    51  - If using `changelog.use: git`, only commits matching files in `monorepo.dir`
    52    will be included in the changelog.
    53  - On templates, `{{.PrefixedTag}}` will be `monorepo.prefix/tag` (aka the actual
    54    tag name), and `{{.Tag}}` has the prefix stripped;
    55  
    56  The rest of the release process should work as usual.
    57  
    58  ### Category 2
    59  
    60  You'll need to create a `.goreleaser.yaml` for your Go code in the root of the
    61  project:
    62  
    63  ```yaml
    64  # .goreleaser.yaml
    65  monorepo:
    66    tag_prefix: v
    67  ```
    68  
    69  Then, you can release with:
    70  
    71  ```bash
    72  goreleaser release --clean
    73  ```
    74  
    75  GoReleaser will then ignore the tags that are not prefixed with `v`, and it
    76  should work as expected from there on.