From 7a7a6f61baf0b107d41605b77efa807ce629409b Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 21 Apr 2021 13:43:59 -0300 Subject: [PATCH] feat: create discussions from releases (#2177) Signed-off-by: Carlos Alexandro Becker --- go.mod | 2 +- go.sum | 4 ++-- internal/client/github.go | 17 ++++++++--------- pkg/config/config.go | 19 ++++++++++--------- www/docs/customization/release.md | 4 ++++ 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/go.mod b/go.mod index 70858959d..c19cf31fa 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/caarlos0/go-shellwords v1.0.12 github.com/campoy/unique v0.0.0-20180121183637-88950e537e7e github.com/fatih/color v1.10.0 - github.com/google/go-github/v28 v28.1.1 + github.com/google/go-github/v35 v35.0.1-0.20210421135231-b235769d1606 github.com/goreleaser/fileglob v1.2.0 github.com/goreleaser/nfpm/v2 v2.4.0 github.com/imdario/mergo v0.3.12 diff --git a/go.sum b/go.sum index 90bad92d6..fa89a7c68 100644 --- a/go.sum +++ b/go.sum @@ -274,8 +274,8 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-github/v28 v28.1.1 h1:kORf5ekX5qwXO2mGzXXOjMe/g6ap8ahVe0sBEulhSxo= -github.com/google/go-github/v28 v28.1.1/go.mod h1:bsqJWQX05omyWVmc00nEUql9mhQyv38lDZ8kPZcQVoM= +github.com/google/go-github/v35 v35.0.1-0.20210421135231-b235769d1606 h1:+8mvMVu+3yXBi/HdWq39mWbt/60u9qS+dkVZfjqEnt8= +github.com/google/go-github/v35 v35.0.1-0.20210421135231-b235769d1606/go.mod h1:s0515YVTI+IMrDoy9Y4pHt9ShGpzHvHO8rZ7L7acgvs= github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/go-replayers/grpcreplay v1.0.0 h1:B5kVOzJ1hBgnevTgIWhSTatQ3608yu/2NnU0Ta1d0kY= diff --git a/internal/client/github.go b/internal/client/github.go index 7994d0397..39e1d33a7 100644 --- a/internal/client/github.go +++ b/internal/client/github.go @@ -10,7 +10,7 @@ import ( "strconv" "github.com/apex/log" - "github.com/google/go-github/v28/github" + "github.com/google/go-github/v35/github" "github.com/goreleaser/goreleaser/internal/artifact" "github.com/goreleaser/goreleaser/internal/tmpl" "github.com/goreleaser/goreleaser/pkg/config" @@ -60,7 +60,6 @@ func NewGitHub(ctx *context.Context, token string) (Client, error) { // CloseMilestone closes a given milestone. func (c *githubClient) CloseMilestone(ctx *context.Context, repo Repo, title string) error { milestone, err := c.getMilestoneByTitle(ctx, repo, title) - if err != nil { return err } @@ -139,12 +138,13 @@ func (c *githubClient) CreateRelease(ctx *context.Context, body string) (string, return "", err } - var data = &github.RepositoryRelease{ - Name: github.String(title), - TagName: github.String(ctx.Git.CurrentTag), - Body: github.String(body), - Draft: github.Bool(ctx.Config.Release.Draft), - Prerelease: github.Bool(ctx.PreRelease), + data := &github.RepositoryRelease{ + Name: github.String(title), + TagName: github.String(ctx.Git.CurrentTag), + Body: github.String(body), + Draft: github.Bool(ctx.Config.Release.Draft), + Prerelease: github.Bool(ctx.PreRelease), + DiscussionCategoryName: github.String(ctx.Config.Release.DiscussionCategoryName), } release, _, err = c.client.Repositories.GetReleaseByTag( ctx, @@ -229,7 +229,6 @@ func (c *githubClient) getMilestoneByTitle(ctx *context.Context, repo Repo, titl repo.Name, opts, ) - if err != nil { return nil, err } diff --git a/pkg/config/config.go b/pkg/config/config.go index 4f840e779..a3536e033 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -275,15 +275,16 @@ type Archive struct { // Release config used for the GitHub/GitLab release. type Release struct { - GitHub Repo `yaml:",omitempty"` - GitLab Repo `yaml:",omitempty"` - Gitea Repo `yaml:",omitempty"` - Draft bool `yaml:",omitempty"` - Disable bool `yaml:",omitempty"` - Prerelease string `yaml:",omitempty"` - NameTemplate string `yaml:"name_template,omitempty"` - IDs []string `yaml:"ids,omitempty"` - ExtraFiles []ExtraFile `yaml:"extra_files,omitempty"` + GitHub Repo `yaml:",omitempty"` + GitLab Repo `yaml:",omitempty"` + Gitea Repo `yaml:",omitempty"` + Draft bool `yaml:",omitempty"` + Disable bool `yaml:",omitempty"` + Prerelease string `yaml:",omitempty"` + NameTemplate string `yaml:"name_template,omitempty"` + IDs []string `yaml:"ids,omitempty"` + ExtraFiles []ExtraFile `yaml:"extra_files,omitempty"` + DiscussionCategoryName string `yaml:"discussion_category_name,omitempty"` } // Milestone config used for VCS milestone. diff --git a/www/docs/customization/release.md b/www/docs/customization/release.md index 01ec65eb3..dec3389fd 100644 --- a/www/docs/customization/release.md +++ b/www/docs/customization/release.md @@ -28,6 +28,10 @@ release: # Default is false. draft: true + # If set, will create a release discussion in the category specified. + # Default is empty. + discussion_category_name: General + # If set to auto, will mark the release as not ready for production # in case there is an indicator for this in the tag e.g. v1.0.0-rc1 # If set to true, will mark the release as not ready for production.