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

build: add shared tags to docker images #1911

Merged
merged 4 commits into from
Aug 15, 2023
Merged
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
21 changes: 20 additions & 1 deletion .build/release_artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ gcloud builds submit --async --config .build/bullseye.yaml --substitutions _VERS

# Build the binarys and upload to GCS
gcloud builds submit --config .build/gcs_upload.yaml --substitutions _VERSION=$VERSION
# cleam up any artifacts.json left by previous builds
# clean up any artifacts.json left by previous builds
gsutil rm -f gs://cloud-sql-connectors/cloud-sql-proxy/v$VERSION/*.json 2> /dev/null || true

# Generate sha256 hashes for authentication
Expand All @@ -58,11 +58,30 @@ done

tag_latest() {
local new_version=$1
# strip patch version from version, x.y.z -> x.y
# https://stackoverflow.com/questions/49252680/bash-get-major-minor-version-from-string
local major_minor_version=${new_version%.*}
# strip minor and patch version from version, x.y.z -> x
local major_version=${new_version%.*.*}
for registry in "gcr.io" "us.gcr.io" "eu.gcr.io" "asia.gcr.io"
do
local base_image="$registry/cloud-sql-connectors/cloud-sql-proxy"
echo "Tagging $new_version as latest in $registry"
gcloud container images add-tag --quiet "$base_image:$new_version" "$base_image:latest"
gcloud container images add-tag --quiet "$base_image:$new_version" "$base_image:$major_minor_version"
gcloud container images add-tag --quiet "$base_image:$new_version" "$base_image:$major_version"
echo "Addings tags to $new_version-alpine image in $registry"
gcloud container images add-tag --quiet "$base_image:$new_version-alpine" "$base_image:alpine"
gcloud container images add-tag --quiet "$base_image:$new_version-alpine" "$base_image:$major_minor_version-alpine"
gcloud container images add-tag --quiet "$base_image:$new_version-alpine" "$base_image:$major_version-alpine"
echo "Addings tags to $new_version-buster image in $registry"
gcloud container images add-tag --quiet "$base_image:$new_version-buster" "$base_image:buster"
gcloud container images add-tag --quiet "$base_image:$new_version-buster" "$base_image:$major_minor_version-buster"
gcloud container images add-tag --quiet "$base_image:$new_version-buster" "$base_image:$major_version-buster"
echo "Addings tags to $new_version-bullseye image in $registry"
gcloud container images add-tag --quiet "$base_image:$new_version-bullseye" "$base_image:bullseye"
gcloud container images add-tag --quiet "$base_image:$new_version-bullseye" "$base_image:$major_minor_version-bullseye"
gcloud container images add-tag --quiet "$base_image:$new_version-bullseye" "$base_image:$major_version-bullseye"
done
}

Expand Down
Loading