fix: Prioritize VERSION file over git describe for release builds #64
This commit is contained in:
parent
6475ba8374
commit
3fd37796c5
1 changed files with 31 additions and 29 deletions
|
|
@ -119,7 +119,37 @@ func (v *Version) IsPrerelease() bool {
|
||||||
|
|
||||||
// GetCurrentVersion gets the current running version
|
// GetCurrentVersion gets the current running version
|
||||||
func GetCurrentVersion() (*VersionInfo, error) {
|
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()
|
gitVersion, err := getGitVersion()
|
||||||
if err == nil && gitVersion != "" {
|
if err == nil && gitVersion != "" {
|
||||||
// Determine channel from git version
|
// Determine channel from git version
|
||||||
|
|
@ -138,34 +168,6 @@ func GetCurrentVersion() (*VersionInfo, error) {
|
||||||
}, nil
|
}, 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
|
// Final fallback
|
||||||
version := "4.24.0-rc.1"
|
version := "4.24.0-rc.1"
|
||||||
channel := "stable"
|
channel := "stable"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue