(httpClient *http.Client, repo ghrepo.Interface, tagName string)
| 110 | } |
| 111 | |
| 112 | func publishedReleaseExists(httpClient *http.Client, repo ghrepo.Interface, tagName string) (bool, error) { |
| 113 | url, err := safeurl.JoinPathWithHostPrefix(ghinstance.RESTPrefix(repo.RepoHost()), "repos", repo.RepoOwner(), repo.RepoName(), "releases", "tags", tagName) |
| 114 | if err != nil { |
| 115 | return false, err |
| 116 | } |
| 117 | req, err := http.NewRequest("HEAD", url.String(), nil) |
| 118 | if err != nil { |
| 119 | return false, err |
| 120 | } |
| 121 | |
| 122 | // TODO(api-client-rollout) |
| 123 | // This has been deferred from moving to api.Client due to HEAD responses having no body while REST decodes non-204/205 2xx responses as JSON. |
| 124 | resp, err := httpClient.Do(req) |
| 125 | if err != nil { |
| 126 | return false, err |
| 127 | } |
| 128 | if resp.Body != nil { |
| 129 | defer resp.Body.Close() |
| 130 | } |
| 131 | |
| 132 | if resp.StatusCode == 200 { |
| 133 | return true, nil |
| 134 | } else if resp.StatusCode == 404 { |
| 135 | return false, nil |
| 136 | } else { |
| 137 | return false, api.HandleHTTPError(resp) |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | func createRelease(httpClient *http.Client, repo ghrepo.Interface, params map[string]interface{}) (*shared.Release, error) { |
| 142 | bodyBytes, err := json.Marshal(params) |
no test coverage detected