Skip to content

Commit

Permalink
fix(github): set discussion category on publish only
Browse files Browse the repository at this point in the history
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
  • Loading branch information
caarlos0 committed Jun 15, 2024
1 parent 9b6af9e commit afd92ff
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/client/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit afd92ff

Please sign in to comment.