fix: update nightly releases (#125)

Nightly updates correctly detected the newest version, but the installer
always queried GitHub’s `/releases/latest` endpoint. Since that endpoint
only returns the latest stable release, `iris update` downloaded the
stable binary even when the nightly channel was configured.

This change passes the selected nightly tag to the installer through
`IRIS_RELEASE_TAG`. When set, the installer queries
`/releases/tags/<tag>`, locates that nightly release’s assets, and
installs the correct binary. Stable updates continue to use
`/releases/latest` unchanged.
This commit is contained in:
João Vitor Alves
2026-08-06 10:12:46 +07:00
committed by GitHub
parent 994ff83675
commit 0595ddd4b9
3 changed files with 50 additions and 19 deletions
+16 -4
View File
@@ -90,14 +90,14 @@ func FetchLatestVersion() (string, error) {
func IsNewer(current, latest string) bool {
c := strings.TrimPrefix(current, "v")
l := strings.TrimPrefix(latest, "v")
channel := config.Get().Updater.Channel
// dev builds or empty versions never trigger an update
if c == "" || c == "dev" || l == "" || l == "dev" {
return false
}
// nightly builds are never shown as stable update targets
if config.Get().Updater.Channel != "nightly" && strings.Contains(l, "-nightly.") {
if channel != "nightly" && strings.Contains(l, "-nightly.") {
return false
}
@@ -124,6 +124,10 @@ func IsNewer(current, latest string) bool {
}
}
if channel == "nightly" && strings.Contains(l, "-nightly.") && c != l {
return true
}
// if all parts are equal, the one with more parts is newer (e.g. 1.0.1 > 1.0)
return len(lParts) > len(cParts)
}
@@ -245,9 +249,17 @@ var updateCmd = &cobra.Command{
// download and replace the binary using the install script
installScript := "https://raw.githubusercontent.com/versenilvis/iris/main/scripts/install.sh"
fmt.Printf("running: curl -sSL %s | sh\n\n", installScript)
command := "curl -sSL " + installScript + " | sh"
runningPrefix := ""
if config.Get().Updater.Channel == "nightly" {
runningPrefix = fmt.Sprintf("IRIS_RELEASE_TAG=%s ", latest)
}
fmt.Printf("running: %s%s\n\n", runningPrefix, command)
cmdRun := exec.Command("sh", "-c", "curl -sSL "+installScript+" | sh")
cmdRun := exec.Command("sh", "-c", command)
if config.Get().Updater.Channel == "nightly" {
cmdRun.Env = append(os.Environ(), "IRIS_RELEASE_TAG="+latest)
}
cmdRun.Stdout = os.Stdout
cmdRun.Stderr = os.Stderr
cmdRun.Stdin = os.Stdin