www/content/customization/monorepo.md
{{< g_featpro >}}
If you want to use GoReleaser within a monorepo and use tag prefixes to mark "which tags belong to which sub project", GoReleaser has you covered.
You project falls into either one of these categories:
subproject1/v1.2.3 and subproject2/v1.2.3;@user/[email protected] (for a NPM package, for example)
and v1.2.3 for the rest of the (Go) code.You'll need to create a .goreleaser.yaml for each subproject you want to use
GoReleaser in:
project_name: subproj1
monorepo:
tag_prefix: subproject1/
dir: subproj1
Then, you can release with (from the project's root directory):
goreleaser release --clean -f ./subproj1/.goreleaser.yaml
Then, the following is different from a "regular" run:
subproject1, and the previous tag with the same prefix;subproj1 directory;{{ .ProjectName }} if empty;dir setting get set to monorepo.dir if empty;
monorepo.dir;changelog.use: git, only commits matching files in monorepo.dir
will be included in the changelog.{{.PrefixedTag}} will be monorepo.prefix/tag (aka the actual
tag name), and {{.Tag}} has the prefix stripped;The rest of the release process should work as usual.
You'll need to create a .goreleaser.yaml for your Go code in the root of the
project:
monorepo:
tag_prefix: v
Then, you can release with:
goreleaser release --clean
GoReleaser will then ignore the tags that are not prefixed with v, and it
should work as expected from there on.
[!NOTE] If you have a
github.com/user/repo/modamodule, its tags should be namedmoda/v1.2.3. This will allow users togo get github.com/user/repo/[email protected], and everything should work as you'd expect.
[!WARNING] Tag prefixes that do not match the module name are not supported by go mods.