Build Bazel with embedded label for release candidate downstream test (#1195)

diff --git a/buildkite/bazelci.py b/buildkite/bazelci.py
index 81e0286..6eddcfc 100755
--- a/buildkite/bazelci.py
+++ b/buildkite/bazelci.py
@@ -960,7 +960,7 @@
     if action_key in include_json_profile:
         json_profile_out = os.path.join(tmpdir, "{}.profile.gz".format(action_key))
         json_profile_flags = get_json_profile_flags(json_profile_out)
-     
+
     capture_corrupted_outputs_flags = []
     capture_corrupted_outputs_dir = None
     if action_key in capture_corrupted_outputs:
@@ -1117,7 +1117,7 @@
                     bazel_version,
                     bazel_binary,
                     platform,
-                    build_flags,
+                    build_flags + ["--embed_label=%s" % get_release_name_from_branch_name()] if save_but else [],
                     build_targets,
                     None,
                     incompatible_flags,
@@ -1325,6 +1325,11 @@
     return os.getenv("BUILDKITE_BRANCH") in ("master", "stable", "main")
 
 
+def get_release_name_from_branch_name():
+    res = re.match(r"release-(\d+\.\d+\.\d+).*", os.getenv("BUILDKITE_BRANCH"))
+    return res.group(1) if res else ""
+
+
 def is_pull_request():
     third_party_repo = os.getenv("BUILDKITE_PULL_REQUEST_REPO", "")
     return len(third_party_repo) > 0