You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-07-15 01:34:21 +02:00
feat(pipe/release): Mark GitHub releases as non-draft only after all artifacts are uploaded. (#4626)
Previously end-users would see missing artifacts if trying to use latest version while artifacts are being uploaded. This currently applies only to GitHub releases. GitLab does not support drafts, and I don't dare to make the change for Gitea since I don't use it (and can't test easily). --------- Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
@ -354,10 +354,12 @@ func (c *githubClient) CreateRelease(ctx *context.Context, body string) (string,
|
||||
body = truncateReleaseBody(body)
|
||||
|
||||
data := &github.RepositoryRelease{
|
||||
Name: github.String(title),
|
||||
TagName: github.String(ctx.Git.CurrentTag),
|
||||
Body: github.String(body),
|
||||
Draft: github.Bool(ctx.Config.Release.Draft),
|
||||
Name: github.String(title),
|
||||
TagName: github.String(ctx.Git.CurrentTag),
|
||||
Body: github.String(body),
|
||||
// Always start with a draft release while uploading artifacts.
|
||||
// PublishRelease will undraft it.
|
||||
Draft: github.Bool(true),
|
||||
Prerelease: github.Bool(ctx.PreRelease),
|
||||
MakeLatest: github.String("true"),
|
||||
}
|
||||
@ -388,6 +390,19 @@ 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) {
|
||||
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),
|
||||
}); err != nil {
|
||||
return fmt.Errorf("could not update existing release: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *githubClient) createOrUpdateRelease(ctx *context.Context, data *github.RepositoryRelease, body string) (*github.RepositoryRelease, error) {
|
||||
c.checkRateLimit(ctx)
|
||||
release, _, err := c.client.Repositories.GetReleaseByTag(
|
||||
|
Reference in New Issue
Block a user