From a6e670e93a19ed9d7a9bd04201e3d4f6c9b6c763 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Sun, 30 Apr 2023 11:22:28 -0400 Subject: [PATCH] update tag fetch method to filetr for cli tags only --- cli/packages/util/check-for-update.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/cli/packages/util/check-for-update.go b/cli/packages/util/check-for-update.go index 2f283070c..0c73c28dc 100644 --- a/cli/packages/util/check-for-update.go +++ b/cli/packages/util/check-for-update.go @@ -4,12 +4,14 @@ import ( "encoding/json" "errors" "fmt" - log "github.com/sirupsen/logrus" "io" "net/http" "os" "os/exec" "runtime" + "strings" + + log "github.com/sirupsen/logrus" "github.com/fatih/color" ) @@ -73,7 +75,23 @@ func getLatestTag(repoOwner string, repoName string) (string, error) { return "", fmt.Errorf("failed to unmarshal github response: %w", err) } - return tags[0].Name[1:], nil + // Filter tags with prefix "infisical-cli/" + prefix := "infisical-cli/" + var validTags []string + for _, tag := range tags { + if strings.HasPrefix(tag.Name, prefix) { + validTags = append(validTags, tag.Name) + } + } + + if len(validTags) == 0 { + return "", errors.New("no tags for the CLI is found") + } + + // Extract the version from the first valid tag + version := strings.TrimPrefix(validTags[0], prefix) + + return version, nil } func GetUpdateInstructions() string {