From 3fd37796c5ae84764c4b269b4a6a6a0689e57101 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Mon, 13 Oct 2025 15:52:10 +0000 Subject: [PATCH] fix: Prioritize VERSION file over git describe for release builds #64 --- internal/updates/version.go | 60 +++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/internal/updates/version.go b/internal/updates/version.go index abb2a4e..6403963 100644 --- a/internal/updates/version.go +++ b/internal/updates/version.go @@ -119,7 +119,37 @@ func (v *Version) IsPrerelease() bool { // GetCurrentVersion gets the current running version func GetCurrentVersion() (*VersionInfo, error) { - // Try to get version from git first (development) + // Try to read from VERSION file first (release builds) + versionPaths := []string{ + "VERSION", + "/opt/pulse/VERSION", + filepath.Join(filepath.Dir(os.Args[0]), "VERSION"), + } + + for _, path := range versionPaths { + versionBytes, err := os.ReadFile(path) + if err == nil { + version := strings.TrimSpace(string(versionBytes)) + if version != "" { + // Determine channel from version string + channel := "stable" + if strings.Contains(strings.ToLower(version), "rc") { + channel = "rc" + } + return &VersionInfo{ + Version: version, + Build: "release", + Runtime: "go", + Channel: channel, + IsDevelopment: false, + IsDocker: isDockerEnvironment(), + DeploymentType: GetDeploymentType(), + }, nil + } + } + } + + // Fall back to git (development builds) gitVersion, err := getGitVersion() if err == nil && gitVersion != "" { // Determine channel from git version @@ -138,34 +168,6 @@ func GetCurrentVersion() (*VersionInfo, error) { }, nil } - // Try to read from VERSION file in multiple locations - versionPaths := []string{ - "VERSION", - "/opt/pulse/VERSION", - filepath.Join(filepath.Dir(os.Args[0]), "VERSION"), - } - - for _, path := range versionPaths { - versionBytes, err := os.ReadFile(path) - if err == nil { - version := strings.TrimSpace(string(versionBytes)) - // Determine channel from version string - channel := "stable" - if strings.Contains(strings.ToLower(version), "rc") { - channel = "rc" - } - return &VersionInfo{ - Version: version, - Build: "release", - Runtime: "go", - Channel: channel, - IsDevelopment: false, - IsDocker: isDockerEnvironment(), - DeploymentType: GetDeploymentType(), - }, nil - } - } - // Final fallback version := "4.24.0-rc.1" channel := "stable"