Created
December 14, 2021 15:41
-
-
Save rail/990a99f225339b9e43780e7261760426 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/build/release/teamcity-mark-build.sh b/build/release/teamcity-mark-build.sh | |
index 25acb1da85..9e955c7322 100755 | |
--- a/build/release/teamcity-mark-build.sh | |
+++ b/build/release/teamcity-mark-build.sh | |
@@ -17,17 +17,24 @@ mark_build() { | |
gcr_repository="us-docker.pkg.dev/cockroach-cloud-images/cockroachdb/cockroach" | |
else | |
google_credentials=$GOOGLE_COCKROACH_RELEASE_CREDENTIALS | |
gcr_repository="us.gcr.io/cockroach-release/cockroach-test" | |
fi | |
tc_end_block "Variable Setup" | |
tc_start_block "Push new docker image tag" | |
if [[ -z "${release_branch}" ]] ; then | |
echo "This tag/branch does not contain a valid major version. Tag/Branch=\"${TC_BUILD_BRANCH}\". Unable to tag docker image as qualified." | |
exit | |
fi | |
log_into_gcloud | |
gcloud container images add-tag "${gcr_repository}:${TC_BUILD_BRANCH}" "${gcr_repository}:latest-${release_branch}-${build_label}-build" | |
tc_end_block "Push new docker image tag" | |
+ # TODO: change this script to publish qualification status to some | |
+ # predictable location in gcs/s3. Also make sure that the upstream job of | |
+ # this script doesn't block publishing. Figure out how to do this in | |
+ # teamcity. We need to pass the result of the upstream job as an input to | |
+ # this one. Or as an alternative publish the results from the upstream job. | |
+ # Right now it's only one job, so shouldn't be an issue, but this can change | |
+ # in the future. | |
} | |
diff --git a/pkg/cmd/publish-provisional-artifacts/main.go b/pkg/cmd/publish-provisional-artifacts/main.go | |
index bf606560bf..0593f0d369 100644 | |
--- a/pkg/cmd/publish-provisional-artifacts/main.go | |
+++ b/pkg/cmd/publish-provisional-artifacts/main.go | |
@@ -1,52 +1,55 @@ | |
// Copyright 2017 The Cockroach Authors. | |
// | |
// Use of this software is governed by the Business Source License | |
// included in the file licenses/BSL.txt. | |
// | |
// As of the Change Date specified in that file, in accordance with | |
// the Business Source License, use of this software will be governed | |
// by the Apache License, Version 2.0, included in the file | |
// licenses/APL.txt. | |
package main | |
import ( | |
"bytes" | |
+ "encoding/json" | |
"flag" | |
"fmt" | |
"go/build" | |
"io" | |
"log" | |
"os" | |
"os/exec" | |
"path/filepath" | |
"regexp" | |
"strings" | |
"github.com/aws/aws-sdk-go/aws" | |
"github.com/aws/aws-sdk-go/aws/session" | |
"github.com/aws/aws-sdk-go/service/s3" | |
+ crdbbuild "github.com/cockroachdb/cockroach/pkg/build" | |
"github.com/cockroachdb/cockroach/pkg/release" | |
"github.com/cockroachdb/cockroach/pkg/util/version" | |
"github.com/kr/pretty" | |
) | |
const ( | |
- awsAccessKeyIDKey = "AWS_ACCESS_KEY_ID" | |
- awsSecretAccessKeyKey = "AWS_SECRET_ACCESS_KEY" | |
+ awsAccessKeyIDKey = "AWS_ACCESS_KEY_ID" | |
+ awsSecretAccessKeyKey = "AWS_SECRET_ACCESS_KEY" | |
+ // TC_BUILD_BRANCH is what we use as a tag we push to release-staging | |
teamcityBuildBranchKey = "TC_BUILD_BRANCH" | |
) | |
var provisionalReleasePrefixRE = regexp.MustCompile(`^provisional_[0-9]{12}_`) | |
type s3I interface { | |
GetObject(*s3.GetObjectInput) (*s3.GetObjectOutput, error) | |
PutObject(*s3.PutObjectInput) (*s3.PutObjectOutput, error) | |
} | |
func makeS3() (s3I, error) { | |
sess, err := session.NewSession(&aws.Config{ | |
Region: aws.String("us-east-1"), | |
}) | |
if err != nil { | |
return nil, err | |
@@ -401,17 +404,39 @@ func markLatestArchive(svc s3I, o opts) { | |
log.Fatalf("downloading %s/%s: %s", o.BucketName, keyRelease, err) | |
} | |
oLatest := o | |
oLatest.VersionStr = latestStr | |
_, keyLatest := s3KeyArchive(oLatest) | |
log.Printf("Uploading to s3://%s/%s", o.BucketName, keyLatest) | |
putObjectInput := s3.PutObjectInput{ | |
Bucket: &o.BucketName, | |
Key: &keyLatest, | |
Body: bytes.NewReader(buf.Bytes()), | |
CacheControl: &release.NoCache, | |
} | |
if _, err := svc.PutObject(&putObjectInput); err != nil { | |
log.Fatalf("s3 upload %s: %s", keyLatest, err) | |
} | |
+ buildInfo := crdbbuild.GetInfo() | |
+ buildInfoJson, err := json.MarshalIndent(crdbbuild.GetInfo(), "", " ") | |
+ if err != nil { | |
+ log.Fatal("Cannot marshall build info") | |
+ } | |
+ putObjectInput = s3.PutObjectInput{ | |
+ Bucket: &o.BucketName, | |
+ // TODO: use predictable unique file name | |
+ // TODO: publish this file even the build is failed, | |
+ // including the status (fail/success) to make sure we can check the status. | |
+ // buildInfo.Tag => build ID in the release docs | |
+ // buildInfo.Revision => sha | |
+ // TODO: figure out if we need to include teamcity build URL for posterity (low priority) | |
+ // TODO: change build/release/teamcity-mark-build-qualified.sh | |
+ // to publish another status file with qualification results | |
+ Key: aws.String(fmt.Sprintf("cockroach-buildinfo-%s.json", buildInfo.Revision)), | |
+ Body: bytes.NewReader(buildInfoJson), | |
+ CacheControl: &release.NoCache, | |
+ } | |
+ if _, err := svc.PutObject(&putObjectInput); err != nil { | |
+ log.Fatalf("s3 upload %s: %s", keyLatest, err) | |
+ } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment