@@ -49,18 +49,6 @@ func NewSourceHelper(opts ...SourceHelperOptions) *SourceHelper {
4949 return gh
5050}
5151
52- // ListReleases lists the available `github.RepositoryRelease` in the source repo.
53- //func (h *SourceHelper) ListReleases() ([]*github.RepositoryRelease, error) {
54- // client := github.NewClient(nil)
55- //
56- // releases, _, err := client.Repositories.ListReleases(context.Background(), h.GithubOwner, h.GithubRepo, nil)
57- // if err != nil {
58- // return nil, err
59- // }
60- //
61- // return releases, nil
62- //}
63-
6452// DownloadAndUnpackSource downloads the generator source artifact for the specified version (if it's not already cached),
6553// unpacks it to the provided folder, then returns the local path of the artifact .zip file.
6654func (h * SourceHelper ) DownloadAndUnpackSource (version string , unpackTargetDir string , out io.Writer ) (string , error ) {
@@ -167,10 +155,13 @@ func (h *SourceHelper) downloadReleaseAsset(releaseAsset *github.ReleaseAsset, d
167155func (h * SourceHelper ) getReleaseByVersion (version string ) (* github.RepositoryRelease , error ) {
168156 client := github .NewClient (nil )
169157
170- release , resp , err := client .Repositories .GetReleaseByTag (context .Background (), h .GithubOwner , h .GithubRepo , version )
158+ // the repo uses a "v" prefix for release tags
159+ tagName := "v" + version
160+
161+ release , resp , err := client .Repositories .GetReleaseByTag (context .Background (), h .GithubOwner , h .GithubRepo , tagName )
171162 if err != nil {
172163 if resp .StatusCode == http .StatusNotFound {
173- return nil , fmt .Errorf ("github release not found for version : %s" , version )
164+ return nil , fmt .Errorf ("github release not found with tag : %s" , tagName )
174165 }
175166 return nil , err
176167 }
0 commit comments