You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-07-15 01:34:21 +02:00
feat: release with target_commitish in another repo
We should not imply the target_commitish, as some users might want to
have the code in one repo and the releases in another (e.g. private
code, public releases), so the commit might not be there.
We should instead allow the user to set the `target_commitish` (or not),
and pass it down to the github api.
refs 95bba02211
refs #3044
refs #3330
Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
@ -217,17 +217,27 @@ func (c *githubClient) CreateRelease(ctx *context.Context, body string) (string,
|
|||||||
body = truncateReleaseBody(body)
|
body = truncateReleaseBody(body)
|
||||||
|
|
||||||
data := &github.RepositoryRelease{
|
data := &github.RepositoryRelease{
|
||||||
Name: github.String(title),
|
Name: github.String(title),
|
||||||
TagName: github.String(ctx.Git.CurrentTag),
|
TagName: github.String(ctx.Git.CurrentTag),
|
||||||
TargetCommitish: github.String(ctx.Git.Commit),
|
Body: github.String(body),
|
||||||
Body: github.String(body),
|
Draft: github.Bool(ctx.Config.Release.Draft),
|
||||||
Draft: github.Bool(ctx.Config.Release.Draft),
|
Prerelease: github.Bool(ctx.PreRelease),
|
||||||
Prerelease: github.Bool(ctx.PreRelease),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.Config.Release.DiscussionCategoryName != "" {
|
if ctx.Config.Release.DiscussionCategoryName != "" {
|
||||||
data.DiscussionCategoryName = github.String(ctx.Config.Release.DiscussionCategoryName)
|
data.DiscussionCategoryName = github.String(ctx.Config.Release.DiscussionCategoryName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if target := ctx.Config.Release.TargetCommitish; target != "" {
|
||||||
|
target, err := tmpl.New(ctx).Apply(target)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if target != "" {
|
||||||
|
data.TargetCommitish = github.String(target)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
release, _, err = c.client.Repositories.GetReleaseByTag(
|
release, _, err = c.client.Repositories.GetReleaseByTag(
|
||||||
ctx,
|
ctx,
|
||||||
ctx.Config.Release.GitHub.Owner,
|
ctx.Config.Release.GitHub.Owner,
|
||||||
|
@ -500,6 +500,7 @@ type Release struct {
|
|||||||
Gitea Repo `yaml:"gitea,omitempty" json:"gitea,omitempty"`
|
Gitea Repo `yaml:"gitea,omitempty" json:"gitea,omitempty"`
|
||||||
Draft bool `yaml:"draft,omitempty" json:"draft,omitempty"`
|
Draft bool `yaml:"draft,omitempty" json:"draft,omitempty"`
|
||||||
ReplaceExistingDraft bool `yaml:"replace_existing_draft,omitempty" json:"replace_existing_draft,omitempty"`
|
ReplaceExistingDraft bool `yaml:"replace_existing_draft,omitempty" json:"replace_existing_draft,omitempty"`
|
||||||
|
TargetCommitish string `yaml:"target_commitish,omitempty" json:"target_commitish,omitempty"`
|
||||||
Disable bool `yaml:"disable,omitempty" json:"disable,omitempty"`
|
Disable bool `yaml:"disable,omitempty" json:"disable,omitempty"`
|
||||||
SkipUpload bool `yaml:"skip_upload,omitempty" json:"skip_upload,omitempty"`
|
SkipUpload bool `yaml:"skip_upload,omitempty" json:"skip_upload,omitempty"`
|
||||||
Prerelease string `yaml:"prerelease,omitempty" json:"prerelease,omitempty"`
|
Prerelease string `yaml:"prerelease,omitempty" json:"prerelease,omitempty"`
|
||||||
|
@ -34,6 +34,13 @@ release:
|
|||||||
# Default is false.
|
# Default is false.
|
||||||
replace_existing_draft: true
|
replace_existing_draft: true
|
||||||
|
|
||||||
|
# Useful if you want to delay the creation of the tag in the remote.
|
||||||
|
# You can create the tag locally, but not push it, and run GoReleaser.
|
||||||
|
# It'll then set the `target_commitish` portion of the GitHub release to the value of this field.
|
||||||
|
# Only works on GitHub.
|
||||||
|
# Default is empty.
|
||||||
|
target_commitish: '{{ .Commit }}'
|
||||||
|
|
||||||
# If set, will create a release discussion in the category specified.
|
# If set, will create a release discussion in the category specified.
|
||||||
#
|
#
|
||||||
# Warning: do not use categories in the 'Announcement' format.
|
# Warning: do not use categories in the 'Announcement' format.
|
||||||
|
@ -49,10 +49,10 @@ On fields that support templating, these fields are always available:
|
|||||||
| `.Runtime.Goos` | equivalent to `runtime.GOOS` |
|
| `.Runtime.Goos` | equivalent to `runtime.GOOS` |
|
||||||
| `.Runtime.Goarch` | equivalent to `runtime.GOARCH` |
|
| `.Runtime.Goarch` | equivalent to `runtime.GOARCH` |
|
||||||
|
|
||||||
[^1]: The `v` prefix is stripped and it might be changed in `snapshot` and `nightly` builds.
|
[^1]: The `v` prefix is stripped, and it might be changed in `snapshot` and `nightly` builds.
|
||||||
[^2]: Assuming `Tag` is a valid a SemVer, otherwise empty/zeroed.
|
[^2]: Assuming `Tag` is a valid a SemVer, otherwise empty/zeroed.
|
||||||
[^3]: Will panic if not a semantic version.
|
[^3]: Will panic if not a semantic version.
|
||||||
[^4]: Composed from the current SCM's download URL and current tag. For instance, on GitHub, it'll be `https://github.com/{owner}/{repo}/releases/tag/{tag}`.
|
[^4]: Composed of the current SCM's download URL and current tag. For instance, on GitHub, it'll be `https://github.com/{owner}/{repo}/releases/tag/{tag}`.
|
||||||
[^5]: It is generated by `git describe --dirty --always --tags`, the format will be `{Tag}-$N-{CommitSHA}`
|
[^5]: It is generated by `git describe --dirty --always --tags`, the format will be `{Tag}-$N-{CommitSHA}`
|
||||||
[^6]: As reported by `git tag -l --format='%(contents:subject)'`
|
[^6]: As reported by `git tag -l --format='%(contents:subject)'`
|
||||||
[^7]: As reported by `git tag -l --format='%(contents)'`
|
[^7]: As reported by `git tag -l --format='%(contents)'`
|
||||||
|
Reference in New Issue
Block a user