Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: Stamp binaries with released version #20

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions infra/get_workspace_status
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion infra/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions internal/buildstamp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down
6 changes: 6 additions & 0 deletions internal/buildstamp/buildstamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
)

type Vars struct {
ReleaseVersion string
SourceBranch string
SourceRevision string
IsClean bool
Expand All @@ -42,6 +43,7 @@ const (
)

var (
releaseVersion = unknown
gitBranch = unknown
gitSha = unknown
gitSourceTreeStatus = unknown
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down