Add release cycle to versioning of Flamenco

Include `RELEASE_CYCLE` in the Makefile. This is mentioned at startup of
Manager and Worker, and reflects in the software version they report.

If `RELEASE_CYCLE == "release"`, Manager and Worker report their version
as `ApplicationVersion`. If it's any other string, the Git hash will get
appended.
This commit is contained in:
Sybren A. Stüvel 2022-07-28 15:10:27 +02:00
parent 8c86d4c1a9
commit d4dfa2d071
6 changed files with 29 additions and 3 deletions

View File

@ -3,9 +3,12 @@ PKG := git.blender.org/flamenco
# To update the version number in all the relevant places, update the VERSION # To update the version number in all the relevant places, update the VERSION
# variable below and run `make update-version`. # variable below and run `make update-version`.
VERSION := 3.0-dev0 VERSION := 3.0-dev0
RELEASE_CYCLE := alpha
GITHASH := $(shell git describe --dirty --always) GITHASH := $(shell git describe --dirty --always)
LDFLAGS := -X ${PKG}/internal/appinfo.ApplicationVersion=${VERSION} -X ${PKG}/internal/appinfo.ApplicationGitHash=${GITHASH} LDFLAGS := -X ${PKG}/internal/appinfo.ApplicationVersion=${VERSION} \
-X ${PKG}/internal/appinfo.ApplicationGitHash=${GITHASH} \
-X ${PKG}/internal/appinfo.ReleaseCycle=${RELEASE_CYCLE}
BUILD_FLAGS = -ldflags="${LDFLAGS}" BUILD_FLAGS = -ldflags="${LDFLAGS}"
# Package name of the generated Python/JavaScript code for the Flamenco API. # Package name of the generated Python/JavaScript code for the Flamenco API.

View File

@ -73,6 +73,7 @@ func main() {
log.Info(). log.Info().
Str("version", appinfo.ApplicationVersion). Str("version", appinfo.ApplicationVersion).
Str("git", appinfo.ApplicationGitHash). Str("git", appinfo.ApplicationGitHash).
Str("releaseCycle", appinfo.ReleaseCycle).
Str("os", runtime.GOOS). Str("os", runtime.GOOS).
Str("arch", runtime.GOARCH). Str("arch", runtime.GOARCH).
Msgf("starting %v", appinfo.ApplicationName) Msgf("starting %v", appinfo.ApplicationName)

View File

@ -63,6 +63,7 @@ func main() {
log.Info(). log.Info().
Str("version", appinfo.ApplicationVersion). Str("version", appinfo.ApplicationVersion).
Str("git", appinfo.ApplicationGitHash). Str("git", appinfo.ApplicationGitHash).
Str("releaseCycle", appinfo.ReleaseCycle).
Str("OS", runtime.GOOS). Str("OS", runtime.GOOS).
Str("ARCH", runtime.GOARCH). Str("ARCH", runtime.GOARCH).
Int("pid", os.Getpid()). Int("pid", os.Getpid()).

View File

@ -15,6 +15,17 @@ var ApplicationVersion = "set-during-build"
// It is set during the build. // It is set during the build.
var ApplicationGitHash = "set-during-build" var ApplicationGitHash = "set-during-build"
// ReleaseCycle determines whether this is marked as release or whether it's
// an development version. This is used to determine wehtehr ExtendedVersion()
// actually returns just the version ("release") or also has the Git hash
// (any other string).
//
// This is a string and not a boolean, because it must be set by the linker and
// that only supports strings.
var ReleaseCycle string = "set-during-build"
const releaseCycleRelease = "release"
// FormattedApplicationInfo returns the application name & version as single string. // FormattedApplicationInfo returns the application name & version as single string.
func FormattedApplicationInfo() string { func FormattedApplicationInfo() string {
return fmt.Sprintf("%s %s", ApplicationName, ApplicationVersion) return fmt.Sprintf("%s %s", ApplicationName, ApplicationVersion)
@ -24,3 +35,13 @@ func FormattedApplicationInfo() string {
func UserAgent() string { func UserAgent() string {
return fmt.Sprintf("%s/%s (%s)", ApplicationName, ApplicationVersion, ApplicationGitHash) return fmt.Sprintf("%s/%s (%s)", ApplicationName, ApplicationVersion, ApplicationGitHash)
} }
// ExtendedVersion returns the application version, and includes the Git hash if
// this is not a release version. See `IsReleaseVersion`.
func ExtendedVersion() string {
if ReleaseCycle == releaseCycleRelease {
return ApplicationVersion
}
return fmt.Sprintf("%s-%s", ApplicationVersion, ApplicationGitHash)
}

View File

@ -23,7 +23,7 @@ import (
func (f *Flamenco) GetVersion(e echo.Context) error { func (f *Flamenco) GetVersion(e echo.Context) error {
return e.JSON(http.StatusOK, api.FlamencoVersion{ return e.JSON(http.StatusOK, api.FlamencoVersion{
Version: appinfo.ApplicationVersion, Version: appinfo.ExtendedVersion(),
Name: appinfo.ApplicationName, Name: appinfo.ApplicationName,
}) })
} }

View File

@ -153,7 +153,7 @@ func signOn(ctx context.Context, cfg WorkerConfig, client FlamencoClient) (api.W
req := api.SignOnJSONRequestBody{ req := api.SignOnJSONRequestBody{
Name: workerName(), Name: workerName(),
SupportedTaskTypes: cfg.TaskTypes, SupportedTaskTypes: cfg.TaskTypes,
SoftwareVersion: appinfo.ApplicationVersion, SoftwareVersion: appinfo.ExtendedVersion(),
} }
logger.Info(). logger.Info().