Skip to content

Commit 6a01893

Browse files
authored
Automatically tag previous image during release (#10367)
1 parent 3b658b4 commit 6a01893

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

scripts/publish/cloudbuild.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,27 @@ steps:
159159
echo "Skipping firepit build for preview version."
160160
fi
161161
162+
# Tag the previous version of the docker image
163+
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk:slim"
164+
entrypoint: "bash"
165+
args:
166+
- "-c"
167+
- |
168+
if [ "${_VERSION}" != "preview" ]; then
169+
IMAGE_NAME="us-docker.pkg.dev/${_ARTIFACT_REGISTRY_PROJECT}/us/firebase"
170+
TAGS=$(gcloud container images list-tags $${IMAGE_NAME} --filter="tags:latest" --format="value(tags)")
171+
echo "Tags for latest: $${TAGS}"
172+
PREVIOUS_VERSION=$(echo $${TAGS} | tr ',' '\n' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$$' | head -n 1)
173+
echo "Detected previous version: $${PREVIOUS_VERSION}"
174+
if [ -n "$${PREVIOUS_VERSION}" ]; then
175+
gcloud container images add-tag $${IMAGE_NAME}:latest $${IMAGE_NAME}:no-new-use-public-image-$${PREVIOUS_VERSION} --quiet
176+
else
177+
echo "Could not detect previous version tag. Skipping tagging."
178+
fi
179+
else
180+
echo "Skipping for preview version."
181+
fi
182+
162183
# Publish the Firebase docker image
163184
- name: "gcr.io/cloud-builders/docker"
164185
entrypoint: "bash"

0 commit comments

Comments
 (0)