Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve checksum filtering and os/arch detection @marwanhawari #65

Merged
merged 3 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading