Skip to content

Commit 015b9f7

Browse files
author
keijun-kumagai
committed
fix(release): discussion category with assets
1 parent eaa64df commit 015b9f7

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

pkg/cmd/release/create/create.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,12 @@ func createRun(opts *CreateOptions) error {
418418
}
419419

420420
if !opts.Draft {
421-
rel, err := publishRelease(httpClient, newRelease.APIURL)
421+
params := map[string]interface{}{}
422+
params["draft"] = false
423+
if opts.DiscussionCategory != "" {
424+
params["discussion_category_name"] = opts.DiscussionCategory
425+
}
426+
rel, err := publishRelease(httpClient, newRelease.APIURL, params)
422427
if err != nil {
423428
return err
424429
}

pkg/cmd/release/create/http.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ func createRelease(httpClient *http.Client, repo ghrepo.Interface, params map[st
134134
return &newRelease, err
135135
}
136136

137-
func publishRelease(httpClient *http.Client, releaseURL string) (*shared.Release, error) {
138-
req, err := http.NewRequest("PATCH", releaseURL, bytes.NewBufferString(`{"draft":false}`))
137+
func publishRelease(httpClient *http.Client, releaseURL string, params map[string]interface{}) (*shared.Release, error) {
138+
bodyBytes, err := json.Marshal(params)
139+
req, err := http.NewRequest("PATCH", releaseURL, bytes.NewBuffer(bodyBytes))
139140
if err != nil {
140141
return nil, err
141142
}

0 commit comments

Comments
 (0)