Skip to content

Commit 6c9e55c

Browse files
committed
make and publish: tag staging repo early in process
Currently, the “Make and Publish Build” process creates a staging tag and pushes it to the staging repository only after all builds and tests have been completed. This approach delays the initiation of the “Build and Sign Cockroach Release” build. In optimal scenarios, “Make and Publish Build” can take over 30 minutes to finish, and any flaky tests can reset this timer. In urgent situations where fixes need to be deployed quickly, we want to initiate the release process without waiting for “Make and Publish Build” to complete. It’s important to note that the built binaries are merely staged and not published at this stage. To enhance efficiency, we can shift the tagging process to the beginning of the “Make and Publish Build.” This adjustment will allow us to commence building release binaries without being hindered by the blocking build jobs. Furthermore, we should publish the metadata.json file immediately after tagging to avoid delaying the Pick SHA process. Release note: none Fixes: RE-958
1 parent 6c3f184 commit 6c9e55c

File tree

2 files changed

+45
-28
lines changed

2 files changed

+45
-28
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2022 The Cockroach Authors.
4+
#
5+
# Use of this software is governed by the CockroachDB Software License
6+
# included in the /LICENSE file.
7+
8+
9+
set -euo pipefail
10+
11+
# This script can be skipped for dry run and customized builds.
12+
is_customized_build="$(echo "$TC_BUILD_BRANCH" | grep -Eo "^custombuild-" || echo "")"
13+
if [[ -n "${DRY_RUN:-}" ]] || [[ -n "${is_customized_build}" ]]; then
14+
echo "Skipping for dry run or customized build."
15+
exit 0
16+
fi
17+
18+
dir="$(dirname $(dirname $(dirname $(dirname $(dirname "${0}")))))"
19+
source "$dir/release/teamcity-support.sh"
20+
21+
github_ssh_key="${GITHUB_COCKROACH_TEAMCITY_PRIVATE_SSH_KEY:?GITHUB_COCKROACH_TEAMCITY_PRIVATE_SSH_KEY must be specified}"
22+
metadata_gcs_bucket="cockroach-release-qualification-prod"
23+
metadata_google_credentials="$GCS_CREDENTIALS_PROD"
24+
build_name="$(git describe --tags --dirty --match=v[0-9]* 2> /dev/null || git rev-parse --short HEAD;)"
25+
26+
configure_git_ssh_key
27+
git tag "${build_name}"
28+
git_wrapped push ssh://[email protected]/cockroachlabs/release-staging.git "${build_name}"
29+
30+
# Publish build metadata to a stable location.
31+
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
32+
metadata_file="artifacts/metadata.json"
33+
mkdir -p artifacts
34+
cat > "$metadata_file" << EOF
35+
{
36+
"sha": "$BUILD_VCS_NUMBER",
37+
"timestamp": "$timestamp",
38+
"tag": "$build_name"
39+
}
40+
EOF
41+
# Run jq to pretty print and validate JSON
42+
jq . "$metadata_file"
43+
google_credentials=$metadata_google_credentials log_into_gcloud
44+
gsutil cp "$metadata_file" "gs://$metadata_gcs_bucket/builds/$BUILD_VCS_NUMBER.json"
45+
echo "Published to https://storage.googleapis.com/$metadata_gcs_bucket/builds/$BUILD_VCS_NUMBER.json"

build/teamcity/internal/release/process/make-and-publish-build-tagging.sh renamed to build/teamcity/internal/release/process/make-and-publish-build.sh

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,6 @@ tc_end_block "Variable Setup"
7171
configure_git_ssh_key
7272

7373
if [[ -z "${is_customized_build}" ]] ; then
74-
tc_start_block "Tag the release"
75-
git tag "${build_name}"
76-
tc_end_block "Tag the release"
77-
78-
tc_start_block "Push release tag to github.com/cockroachlabs/release-staging"
79-
git_wrapped push ssh://[email protected]/cockroachlabs/release-staging.git "${build_name}"
80-
tc_end_block "Push release tag to github.com/cockroachlabs/release-staging"
81-
82-
8374
tc_start_block "Tag docker image as latest-build"
8475
# Only tag the image as "latest-vX.Y-build" if the tag is on a release branch
8576
# (or master for the alphas for the next major release).
@@ -119,22 +110,3 @@ if [[ -n "${is_customized_build}" ]] ; then
119110
git_wrapped push ssh://[email protected]/cockroachdb/cockroach.git --delete "${TC_BUILD_BRANCH}"
120111
tc_end_block "Delete custombuild tag"
121112
fi
122-
123-
# Publish build metadata to a stable location.
124-
tc_start_block "Metadata"
125-
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
126-
metadata_file="artifacts/metadata.json"
127-
mkdir -p artifacts
128-
cat > "$metadata_file" << EOF
129-
{
130-
"sha": "$BUILD_VCS_NUMBER",
131-
"timestamp": "$timestamp",
132-
"tag": "$build_name"
133-
}
134-
EOF
135-
# Run jq to pretty print and validate JSON
136-
jq . "$metadata_file"
137-
google_credentials=$metadata_google_credentials log_into_gcloud
138-
gsutil cp "$metadata_file" "gs://$metadata_gcs_bucket/builds/$BUILD_VCS_NUMBER.json"
139-
echo "Published to https://storage.googleapis.com/$metadata_gcs_bucket/builds/$BUILD_VCS_NUMBER.json"
140-
tc_end_block "Metadata"

0 commit comments

Comments
 (0)