Skip to content

Commit

Permalink
fix(release): only change release draft status on new releases (#4744)
Browse files Browse the repository at this point in the history
If we're editing an existing release, do not set it to draft.

Closes #4742
Refs #4626
  • Loading branch information
caarlos0 committed Apr 3, 2024
1 parent 22b7daa commit 053eccd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/client/github.go
Expand Up @@ -417,13 +417,17 @@ func (c *githubClient) CreateRelease(ctx *context.Context, body string) (string,
return strconv.FormatInt(release.GetID(), 10), nil
}

func (c *githubClient) PublishRelease(ctx *context.Context, releaseID string) (err error) {
func (c *githubClient) PublishRelease(ctx *context.Context, releaseID string) error {
draft := ctx.Config.Release.Draft
if draft {
return nil
}
releaseIDInt, err := strconv.ParseInt(releaseID, 10, 64)
if err != nil {
return fmt.Errorf("non-numeric release ID %q: %w", releaseID, err)
}
if _, err := c.updateRelease(ctx, releaseIDInt, &github.RepositoryRelease{
Draft: github.Bool(ctx.Config.Release.Draft),
Draft: github.Bool(draft),
}); err != nil {
return fmt.Errorf("could not update existing release: %w", err)
}
Expand Down Expand Up @@ -454,6 +458,7 @@ func (c *githubClient) createOrUpdateRelease(ctx *context.Context, data *github.
return release, err
}

data.Draft = release.Draft
data.Body = github.String(getReleaseNotes(release.GetBody(), body, ctx.Config.Release.ReleaseNotesMode))
return c.updateRelease(ctx, release.GetID(), data)
}
Expand Down

0 comments on commit 053eccd

Please sign in to comment.