MCPcopy Create free account
hub / github.com/cli/cli / publishRelease

Function publishRelease

pkg/cmd/release/create/http.go:183–207  ·  view source on GitHub ↗
(httpClient *http.Client, host string, releaseURL safeurl.SafeURL, discussionCategory string, isLatest *bool)

Source from the content-addressed store, hash-verified

181}
182
183func publishRelease(httpClient *http.Client, host string, releaseURL safeurl.SafeURL, discussionCategory string, isLatest *bool) (*shared.Release, error) {
184 params := map[string]interface{}{"draft": false}
185 if discussionCategory != "" {
186 params["discussion_category_name"] = discussionCategory
187 }
188
189 if isLatest != nil {
190 params["make_latest"] = fmt.Sprintf("%v", *isLatest)
191 }
192
193 bodyBytes, err := json.Marshal(params)
194 if err != nil {
195 return nil, err
196 }
197
198 var release shared.Release
199 // TODO(api-client-rollout)
200 // This line of code is part of a mechanical roll out of the api client.
201 // As a follow up, consider whether the api client can be injected to this call site, rather than constructed
202 err = api.NewClientFromHTTP(httpClient).REST(host, http.MethodPatch, releaseURL.String(), bytes.NewBuffer(bodyBytes), &release)
203 if err != nil {
204 return nil, err
205 }
206 return &release, nil
207}
208
209func deleteRelease(httpClient *http.Client, host string, releaseURL safeurl.SafeURL) error {
210 // TODO(api-client-rollout)

Callers 2

createRunFunction · 0.85

Calls 3

NewClientFromHTTPFunction · 0.92
RESTMethod · 0.65
StringMethod · 0.65

Tested by 1