Skip to content

Commit 6358677

Browse files
feat: improve checksum filtering and os/arch detection @marwanhawari (#65)
* Improve arch and system autodetection #52 * feat: improve checksum filtering and os/arch detection --------- Co-authored-by: Slava <[email protected]>
1 parent 463ffd3 commit 6358677

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

constants/constants.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ var LoadingSpinner = spinner.New(spinner.CharSets[9], 100*time.Millisecond, spin
2626
var RegexDarwin = `(?i)(darwin|mac(os)?|apple|osx)`
2727

2828
// RegexWindows is a regular express for windows systems
29-
var RegexWindows = `(?i)(windows|win)`
29+
var RegexWindows = `(?i)(windows|win|.msi|.exe)`
3030

3131
// RegexArm64 is a regular express for arm64 architectures
32-
var RegexArm64 = `(?i)(arm64|aarch64)`
32+
var RegexArm64 = `(?i)(arm64|aarch64|arm64e)`
3333

3434
// RegexAmd64 is a regular express for amd64 architectures
35-
var RegexAmd64 = `(?i)(x86_64|amd64|x64)`
35+
var RegexAmd64 = `(?i)(x86_64|amd64|x64|amd64e)`
3636

3737
// Regex386 is a regular express for 386 architectures
3838
var Regex386 = `(?i)(i?386|x86_32|amd32|x32)`
@@ -46,6 +46,9 @@ var RegexGithubSearch = `(?i)^[A-Za-z0-9\_\.\-\/\:]+$`
4646
// RegexURL is a regular express for valid URLs
4747
var RegexURL = `(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])`
4848

49+
// RegexChecksum is a regular expression for matching checksum files
50+
var RegexChecksum = `\.(sha(256|512)(sum)?)$`
51+
4952
// StewOwner is the username of the stew github repo owner
5053
var StewOwner = `marwanhawari`
5154

lib/github.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"encoding/json"
55
"fmt"
66
"regexp"
7-
"strings"
87

98
"github.com/marwanhawari/stew/constants"
109
)
@@ -130,8 +129,10 @@ func assetsFound(releaseAssets []string, releaseTag string) error {
130129

131130
func filterReleaseAssets(assets []string) []string {
132131
var filteredAssets []string
132+
re := regexp.MustCompile(constants.RegexChecksum)
133+
133134
for _, asset := range assets {
134-
if strings.HasSuffix(asset, ".sha256") {
135+
if re.MatchString(asset) {
135136
continue
136137
}
137138
filteredAssets = append(filteredAssets, asset)

0 commit comments

Comments
 (0)