diff --git a/constants/constants.go b/constants/constants.go index 0a031da..83e8cc3 100644 --- a/constants/constants.go +++ b/constants/constants.go @@ -26,13 +26,13 @@ var LoadingSpinner = spinner.New(spinner.CharSets[9], 100*time.Millisecond, spin var RegexDarwin = `(?i)(darwin|mac(os)?|apple|osx)` // RegexWindows is a regular express for windows systems -var RegexWindows = `(?i)(windows|win)` +var RegexWindows = `(?i)(windows|win|.msi|.exe)` // RegexArm64 is a regular express for arm64 architectures -var RegexArm64 = `(?i)(arm64|aarch64)` +var RegexArm64 = `(?i)(arm64|aarch64|arm64e)` // RegexAmd64 is a regular express for amd64 architectures -var RegexAmd64 = `(?i)(x86_64|amd64|x64)` +var RegexAmd64 = `(?i)(x86_64|amd64|x64|amd64e)` // Regex386 is a regular express for 386 architectures var Regex386 = `(?i)(i?386|x86_32|amd32|x32)` @@ -46,6 +46,9 @@ var RegexGithubSearch = `(?i)^[A-Za-z0-9\_\.\-\/\:]+$` // RegexURL is a regular express for valid URLs var RegexURL = `(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])` +// RegexChecksum is a regular expression for matching checksum files +var RegexChecksum = `\.(sha(256|512)(sum)?)$` + // StewOwner is the username of the stew github repo owner var StewOwner = `marwanhawari` diff --git a/lib/github.go b/lib/github.go index 685dbb9..fc5415d 100644 --- a/lib/github.go +++ b/lib/github.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "regexp" - "strings" "github.com/marwanhawari/stew/constants" ) @@ -130,8 +129,10 @@ func assetsFound(releaseAssets []string, releaseTag string) error { func filterReleaseAssets(assets []string) []string { var filteredAssets []string + re := regexp.MustCompile(constants.RegexChecksum) + for _, asset := range assets { - if strings.HasSuffix(asset, ".sha256") { + if re.MatchString(asset) { continue } filteredAssets = append(filteredAssets, asset)