1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

fix(github): set discussion category on publish only

It has no effect if the release is a draft, and seems to be ignored
later when published.

Move setting the discussion category to the publish method only.

Closes https://github.com/orgs/goreleaser/discussions/4902
This commit is contained in:
Carlos Alexandro Becker 2024-06-15 15:46:50 -03:00
parent 9b6af9efba
commit afd92ffe0f
No known key found for this signature in database

View File

@ -390,10 +390,6 @@ func (c *githubClient) CreateRelease(ctx *context.Context, body string) (string,
MakeLatest: github.String("true"),
}
if 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 {
@ -425,9 +421,13 @@ func (c *githubClient) PublishRelease(ctx *context.Context, releaseID string) er
if err != nil {
return fmt.Errorf("non-numeric release ID %q: %w", releaseID, err)
}
if _, err := c.updateRelease(ctx, releaseIDInt, &github.RepositoryRelease{
data := &github.RepositoryRelease{
Draft: github.Bool(draft),
}); err != nil {
}
if ctx.Config.Release.DiscussionCategoryName != "" {
data.DiscussionCategoryName = github.String(ctx.Config.Release.DiscussionCategoryName)
}
if _, err := c.updateRelease(ctx, releaseIDInt, data); err != nil {
return fmt.Errorf("could not update existing release: %w", err)
}
return nil