Skip to content

Commit

Permalink
Exclude pre-releases from "latest tag" selection in install/upgrade (#49
Browse files Browse the repository at this point in the history
)
  • Loading branch information
HugoDF authored Jan 19, 2025
1 parent 79280da commit 81d6e1f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
8 changes: 7 additions & 1 deletion cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ func installOne(pkg stew.PackageData, userOS, userArch string, systemInfo stew.S
}

if tag == "" || tag == "latest" {
tag = githubProject.Releases[0].TagName
// Find first non-prerelease tag
for _, release := range githubProject.Releases {
if !release.Prerelease {
tag = release.TagName
break
}
}
}

tagIndex, tagFound := stew.Contains(releaseTags, tag)
Expand Down
7 changes: 6 additions & 1 deletion cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,13 @@ func upgradeOne(binaryName, userOS, userArch string, lockFile stew.LockFile, sys
return err
}

// Get the latest tag
// Start at the latest tag
tagIndex := 0
// Find first non-prerelease tag
for githubProject.Releases[tagIndex].Prerelease {
tagIndex += 1
}

tag := githubProject.Releases[tagIndex].TagName

if pkg.Tag == tag {
Expand Down
5 changes: 3 additions & 2 deletions lib/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ type GithubAPIResponse []GithubRelease

// GithubRelease contains information about a GitHub release, including the associated assets
type GithubRelease struct {
TagName string `json:"tag_name"`
Assets []GithubAsset `json:"assets"`
TagName string `json:"tag_name"`
Assets []GithubAsset `json:"assets"`
Prerelease bool `json:"prerelease"`
}

// GithubAsset contains information about a specific GitHub asset
Expand Down

0 comments on commit 81d6e1f

Please sign in to comment.