From e579612239ac0ebe45da16c0f3ed57696eb32128 Mon Sep 17 00:00:00 2001 From: Abhay Krishna Date: Fri, 26 Apr 2024 11:16:39 -0700 Subject: [PATCH] Handle cases where GitHub release does not exist for tag (#3116) --- tools/version-tracker/pkg/github/github.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/version-tracker/pkg/github/github.go b/tools/version-tracker/pkg/github/github.go index 429d1ab6bf..4879720bf3 100644 --- a/tools/version-tracker/pkg/github/github.go +++ b/tools/version-tracker/pkg/github/github.go @@ -149,10 +149,17 @@ func GetLatestRevision(client *github.Client, org, repo, currentRevision string, } } releaseForTag, _, err := client.Repositories.GetReleaseByTag(context.Background(), org, repo, tagName) + preRelease := false if err != nil { - return "", false, fmt.Errorf("calling GetReleaseByTag API for tag %s in [%s/%s] repository: %v", tagName, org, repo, err) + if strings.Contains(err.Error(), "404 Not Found") { + preRelease = false + } else { + return "", false, fmt.Errorf("calling GetReleaseByTag API for tag %s in [%s/%s] repository: %v", tagName, org, repo, err) + } + } else { + preRelease = *releaseForTag.Prerelease } - if *releaseForTag.Prerelease { + if preRelease { continue }