1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

CICD: GoReleaser version (#2737)

Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
This commit is contained in:
Jeffrey Cafferata
2024-01-02 21:14:35 +01:00
committed by GitHub
parent 8ed137aff5
commit 17da0bc69f
9 changed files with 19 additions and 94 deletions

View File

@@ -1,44 +0,0 @@
package version
import (
"fmt"
"runtime/debug"
"strconv"
"time"
)
// NOTE: main() updates these.
var (
BuildTime = ""
SHA = ""
Semver = ""
)
var versionCache string
// Banner returns the version banner.
func Banner() string {
if versionCache != "" {
return versionCache
}
var version string
if SHA != "" {
version = fmt.Sprintf("%s (%s)", Semver, SHA)
} else {
version = fmt.Sprintf("%s-dev", Semver) // no SHA. '0.x.y-dev' indicates it is run from source without build script.
}
if info, ok := debug.ReadBuildInfo(); !ok && info == nil {
version += " (non-modules)"
}
if BuildTime != "" {
i, err := strconv.ParseInt(BuildTime, 10, 64)
if err == nil {
tm := time.Unix(i, 0)
version += fmt.Sprintf(" built %s", tm.Format(time.RFC822))
}
}
versionCache = version
return version
}