diff --git a/cmd/install.go b/cmd/install.go index d3fcb64..5bcbffa 100644 --- a/cmd/install.go +++ b/cmd/install.go @@ -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) diff --git a/cmd/upgrade.go b/cmd/upgrade.go index 2cac799..b22783f 100644 --- a/cmd/upgrade.go +++ b/cmd/upgrade.go @@ -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 { diff --git a/lib/github.go b/lib/github.go index 4c2759d..ff477fb 100644 --- a/lib/github.go +++ b/lib/github.go @@ -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