(httpClient *http.Client, repo ghrepo.Interface, tagName string)
| 142 | } |
| 143 | |
| 144 | func publishedReleaseExists(httpClient *http.Client, repo ghrepo.Interface, tagName string) (bool, error) { |
| 145 | path := fmt.Sprintf("repos/%s/%s/releases/tags/%s", repo.RepoOwner(), repo.RepoName(), url.PathEscape(tagName)) |
| 146 | url := ghinstance.RESTPrefix(repo.RepoHost()) + path |
| 147 | req, err := http.NewRequest("HEAD", url, nil) |
| 148 | if err != nil { |
| 149 | return false, err |
| 150 | } |
| 151 | |
| 152 | resp, err := httpClient.Do(req) |
| 153 | if err != nil { |
| 154 | return false, err |
| 155 | } |
| 156 | if resp.Body != nil { |
| 157 | defer resp.Body.Close() |
| 158 | } |
| 159 | |
| 160 | if resp.StatusCode == 200 { |
| 161 | return true, nil |
| 162 | } else if resp.StatusCode == 404 { |
| 163 | return false, nil |
| 164 | } else { |
| 165 | return false, api.HandleHTTPError(resp) |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | func createRelease(httpClient *http.Client, repo ghrepo.Interface, params map[string]interface{}) (*shared.Release, error) { |
| 170 | bodyBytes, err := json.Marshal(params) |
no test coverage detected