Skip to content

Commit

Permalink
Handle cases where GitHub release does not exist for tag
Browse files Browse the repository at this point in the history
  • Loading branch information
abhay-krishna committed Apr 25, 2024
1 parent 8e4b281 commit f97bbd9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tools/version-tracker/pkg/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package github
import (
"context"
"encoding/base64"
"errors"
"fmt"
"os"
"path/filepath"
Expand All @@ -19,6 +20,8 @@ import (
"github.com/aws/eks-anywhere-build-tooling/tools/version-tracker/pkg/util/version"
)

var ErrNotFound = errors.New("404 Not Found")

// getTagsForRepo retrieves the list of tags for the given GitHub repository.
func getTagsForRepo(client *github.Client, org, repo string) ([]*github.RepositoryTag, error) {
logger.V(6).Info(fmt.Sprintf("Getting tags for [%s/%s] repository", org, repo))
Expand Down Expand Up @@ -149,10 +152,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 err == ErrNotFound {
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
}

Expand Down

0 comments on commit f97bbd9

Please sign in to comment.