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

Function publishRelease

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

Source from the content-addressed store, hash-verified

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

Callers 2

createRunFunction · 0.85

Calls 3

NewClientFromHTTPFunction · 0.92
RESTMethod · 0.65
StringMethod · 0.65

Tested by 1