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

Exclude pre-releases from "latest tag" selection in install/upgrade #49

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
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
Loading