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

Publish charts to GCS #365

Merged
merged 1 commit into from
Jan 9, 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
14 changes: 13 additions & 1 deletion build/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
set -euxo pipefail

charts_hostname="${CHARTS_HOSTNAME:-charts.cockroachdb.com}"
case $charts_hostname in
charts.cockroachdb.com)
gcs_bucket=cockroach-helm-charts-prod
;;
charts-test.cockroachdb.com)
gcs_bucket=cockroach-helm-charts-test
;;
*)
echo "uknown host $charts_hostname"
exit 1
;;
esac

HELM_INSTALL_DIR=$PWD/bin
mkdir -p "$HELM_INSTALL_DIR"
Expand All @@ -15,7 +27,7 @@ artifacts_dir="build/artifacts/"
mkdir -p "$artifacts_dir"

# Grab the current index.yaml to merge into the new index.yaml.
curl -fsSL "https://s3.amazonaws.com/${charts_hostname}/index.yaml" > "${artifacts_dir}/old-index.yaml"
curl -fsSL "https://storage.googleapis.com/$gcs_bucket/index.yaml" > "${artifacts_dir}/old-index.yaml"

# Build the charts
$HELM_INSTALL_DIR/helm package cockroachdb --destination "${artifacts_dir}"
Expand Down
43 changes: 28 additions & 15 deletions build/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,35 @@
set -euo pipefail

charts_hostname="${CHARTS_HOSTNAME:-charts.cockroachdb.com}"
case $charts_hostname in
charts.cockroachdb.com)
lb_name=cockroach-helm-charts-prod-default
gcs_bucket=cockroach-helm-charts-prod
google_credentials="$GCS_CREDENTIALS_PROD"
;;
charts-test.cockroachdb.com)
lb_name=cockroach-helm-charts-test-default
gcs_bucket=cockroach-helm-charts-test
google_credentials="$GCS_CREDENTIALS_PROD"
;;
*)
echo "uknown host $charts_hostname"
exit 1
;;
esac

if [ -n "${DISTRIBUTION_ID-}" ] ; then
distribution_id="${DISTRIBUTION_ID}"
elif [ "${charts_hostname-}" = "charts.cockroachdb.com" ] ; then
distribution_id="E2PBFCZT8WAC7B"
elif [ "${charts_hostname-}" = "charts-test.cockroachdb.com" ] ; then
distribution_id="E20WB6NQP118CN"
fi
remove_files_on_exit() {
rm -f .google-credentials.json
}

# Push the new chart file and updated index.yaml file to S3
# We rely on the aws-cli version installed system-wide.
AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
aws s3 sync "build/artifacts/" "s3://${charts_hostname}" --exclude old-index.yaml
trap remove_files_on_exit EXIT

echo "${google_credentials}" > .google-credentials.json
gcloud auth activate-service-account --key-file=.google-credentials.json

# Push the new chart file and updated index.yaml file to GCS.
# We rely on the gcloud CLI version installed system-wide.
gsutil rsync "build/artifacts/" "gs://${gcs_bucket}/" -x old-index.yaml

# Invalidate any cached version of index.yaml (so this version is immediately available)
if [ -n "${distribution_id}" ] ; then
AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
aws cloudfront create-invalidation --distribution-id "${distribution_id}" --paths /index.yaml
fi
gcloud compute url-maps invalidate-cdn-cache $lb_name --path "/index.yaml"