2022-05-13 14:06:44 +02:00
|
|
|
package build
|
|
|
|
|
|
2025-09-15 12:51:54 +03:00
|
|
|
import (
|
|
|
|
|
"time"
|
2022-05-13 14:06:44 +02:00
|
|
|
|
2025-09-15 12:51:54 +03:00
|
|
|
"github.com/zitadel/logging"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// These variables are set via ldflags in the Makefile
|
2022-05-13 14:06:44 +02:00
|
|
|
var (
|
2025-09-15 12:51:54 +03:00
|
|
|
version = ""
|
|
|
|
|
commit = ""
|
|
|
|
|
date = ""
|
2022-05-13 14:06:44 +02:00
|
|
|
)
|
|
|
|
|
|
2025-09-15 12:51:54 +03:00
|
|
|
// dateTime is the parsed version of [date]
|
|
|
|
|
var dateTime time.Time
|
|
|
|
|
|
|
|
|
|
// init prevents race conditions when accessing dateTime and version.
|
|
|
|
|
func init() {
|
|
|
|
|
var err error
|
|
|
|
|
dateTime, err = time.Parse(time.RFC3339, date)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logging.WithError(err).Warn("could not parse build date, using current time instead")
|
|
|
|
|
dateTime = time.Now()
|
|
|
|
|
}
|
|
|
|
|
if version == "" {
|
|
|
|
|
logging.Warn("no build version set, using timestamp as version")
|
|
|
|
|
version = date
|
2022-11-07 10:50:44 +01:00
|
|
|
}
|
2025-09-15 12:51:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Version returns the current build version of Zitadel
|
|
|
|
|
func Version() string {
|
2022-05-13 14:06:44 +02:00
|
|
|
return version
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-15 12:51:54 +03:00
|
|
|
// Commit returns the git commit hash of the current build of Zitadel
|
2022-05-13 14:06:44 +02:00
|
|
|
func Commit() string {
|
|
|
|
|
return commit
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-15 12:51:54 +03:00
|
|
|
// Date returns the build date of the current build of Zitadel
|
2022-05-13 14:06:44 +02:00
|
|
|
func Date() time.Time {
|
|
|
|
|
return dateTime
|
|
|
|
|
}
|