diff --git a/infra/get_workspace_status b/infra/get_workspace_status index 278c6db..236c9bd 100755 --- a/infra/get_workspace_status +++ b/infra/get_workspace_status @@ -23,6 +23,7 @@ echo BUILD_SCM_BRANCH $(git rev-parse --abbrev-ref HEAD) echo BUILD_SCM_REVISION $(git rev-parse --verify HEAD) +echo STABLE_BUILD_RELEASE_VERSION ${BUILD_RELEASE_VERSION} git diff-index --quiet HEAD -- if [[ $? == 0 ]]; then diff --git a/infra/release.sh b/infra/release.sh index c77b048..b1d2824 100755 --- a/infra/release.sh +++ b/infra/release.sh @@ -78,7 +78,8 @@ echo "[FINISH] Release branch checks" # Build release artifacts echo "[START] Building artifacts" -bazel build \ +BUILD_RELEASE_VERSION="${RELEASE_VERSION}" \ + bazel build \ --config=release \ -- \ //:release_artifacts diff --git a/internal/buildstamp/BUILD b/internal/buildstamp/BUILD index 026a12c..80b5609 100644 --- a/internal/buildstamp/BUILD +++ b/internal/buildstamp/BUILD @@ -9,6 +9,7 @@ go_library( # These vars are populated by `infra/get_workspace_status` and are set # when the `--stamp` flag is passed to bazel. See # https://bazel.build/docs/user-manual#workspace-status for more info. + "releaseVersion": "{STABLE_BUILD_RELEASE_VERSION}", "gitBranch": "{BUILD_SCM_BRANCH}", "gitSha": "{BUILD_SCM_REVISION}", "gitSourceTreeStatus": "{BUILD_SCM_STATUS}", diff --git a/internal/buildstamp/buildstamp.go b/internal/buildstamp/buildstamp.go index 0a1bf48..a47dcfd 100644 --- a/internal/buildstamp/buildstamp.go +++ b/internal/buildstamp/buildstamp.go @@ -27,6 +27,7 @@ import ( ) type Vars struct { + ReleaseVersion string SourceBranch string SourceRevision string IsClean bool @@ -42,6 +43,7 @@ const ( ) var ( + releaseVersion = unknown gitBranch = unknown gitSha = unknown gitSourceTreeStatus = unknown @@ -91,6 +93,7 @@ func init() { } // Assume stamping is enabled, and initialize Vars accordingly. + Values.ReleaseVersion = releaseVersion Values.SourceBranch = gitBranch Values.SourceRevision = gitSha Values.IsClean = gitSourceTreeStatus == gitStatusClean @@ -116,6 +119,9 @@ func (v Vars) String() string { return "build metadata is unavailable (build with bazel's `--stamp` flag to enable)" } var sb strings.Builder + if v.ReleaseVersion != unknown { + fmt.Fprintf(&sb, "release version: %v\n", v.ReleaseVersion) + } fmt.Fprintf(&sb, "build time: %v\n", v.BuildTimestamp) fmt.Fprintf(&sb, "official build: %v\n", v.IsOfficial) fmt.Fprintf(&sb, "build branch: %s\n", v.SourceBranch)