Skip to content

Commit

Permalink
feat: improve checksum filtering and os/arch detection @marwanhawari (#…
Browse files Browse the repository at this point in the history
…65)

* Improve arch and system autodetection #52

* feat: improve checksum filtering and os/arch detection

---------

Co-authored-by: Slava <[email protected]>
  • Loading branch information
marwanhawari and slavaGanzin authored Jan 21, 2025
1 parent 463ffd3 commit 6358677
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 6 additions & 3 deletions constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)`
Expand All @@ -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`

Expand Down
5 changes: 3 additions & 2 deletions lib/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"regexp"
"strings"

"github.com/marwanhawari/stew/constants"
)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6358677

Please sign in to comment.