diff --git a/www/docs/cookbooks/private-monorepo-public-release.md b/www/docs/cookbooks/private-monorepo-public-release.md new file mode 100644 index 000000000..409daf99b --- /dev/null +++ b/www/docs/cookbooks/private-monorepo-public-release.md @@ -0,0 +1,65 @@ +# Building in a private monorepo, publishing in to a public repository + +One fairly common usecase is on open-core projects is to have the code in a +private monorepo, but publish its binaries to a public repository. + +This cookbook gives some suggestions on how to handle that. + +!!! success "GoReleaser Pro" + This cookbook uses [GoReleaser Pro](/pro). + +Usually, you'll rely on tag prefixes for each sub-project within your monorepo. +GoReleaser can handle that within its [monorepo +configuration](/customization/monorepo): + +```yaml +monorepo: + tag_prefix: app1/ + dir: ./app1/ +``` + +With that you can already push a tag `app1/v1.0.0`, for example, and GoReleaser +should gracefully handling everything. + +But, if you want the release to happen in another repository, you'll also need +to add some [release](/customization/release) settings: + +```yaml +release: + github: + owner: myorg + name: myrepo +``` + +When you release now, it'll create the `app1/v1.0.0` tag and respective release +in `myorg/myrepo`. + +## Removing the `myapp/` prefix + +Maybe you'll create one public repository to release each of the projects in +your monorepo. In that case, the tag prefix on the public repository makes no +sense. + +You can remove it by setting the `release.tag` field: + +```yaml +release: + tag: '{{ .Tag }}' + github: + owner: myorg + name: app1 +``` + +!!! info + On GoReleaser Pro, `{{.Tag}}` is the tag without the prefix, and the + prefixed tag can be accessed with `{{.PrefixedTag}}`. Check the + [documentation](/customization/templates) for more information. + +## Learning more + +Make sure to take a look at the following documentation pages: + +- [Monorepo](/customization/monorepo) +- [Release](/customization/release) +- [Template variables](/customization/templates) + diff --git a/www/docs/customization/release.md b/www/docs/customization/release.md index ffbc95655..bbd79f6b1 100644 --- a/www/docs/customization/release.md +++ b/www/docs/customization/release.md @@ -48,8 +48,19 @@ release: # # Default: '' # Since: v1.11 + # Templates: allowed target_commitish: '{{ .Commit }}' + # This allows to change which tag GitHub will create. + # Usually you'll use this together with `target_commitish`, or if you want to + # publish a binary from a monorepo into a public repository somewhere, without + # the tag prefix. + # + # Default: '{{ .PrefixedCurrentTag }}' + # Since: v1.19 (pro) + # Templates: allowed + tag: '{{ .CurrentTag }}' + # If set, will create a release discussion in the category specified. # # Warning: do not use categories in the 'Announcement' format. diff --git a/www/docs/static/schema-pro.json b/www/docs/static/schema-pro.json index 7af633bc5..16d918bbc 100644 --- a/www/docs/static/schema-pro.json +++ b/www/docs/static/schema-pro.json @@ -2540,6 +2540,9 @@ "target_commitish": { "type": "string" }, + "tag": { + "type": "string" + }, "disable": { "oneOf": [ { diff --git a/www/mkdocs.yml b/www/mkdocs.yml index 9998222d2..722600c6b 100644 --- a/www/mkdocs.yml +++ b/www/mkdocs.yml @@ -184,6 +184,7 @@ nav: - About: cookbooks/index.md - Blog Posts: cookbooks/blog-posts.md - Add a new cookbook: cookbooks/contributing.md + - cookbooks/private-monorepo-public-release.md - cookbooks/multi-platform-docker-images.md - cookbooks/build-go-modules.md - cookbooks/cgo-and-crosscompiling.md