diff --git a/owlbot-postprocessor/Dockerfile b/owlbot-postprocessor/Dockerfile index bb0e56cc..da94207e 100644 --- a/owlbot-postprocessor/Dockerfile +++ b/owlbot-postprocessor/Dockerfile @@ -18,7 +18,7 @@ RUN apt-get update \ && apt-get -y autoremove \ && apt-get -y autoclean RUN mkdir /ruby-postprocessor \ - && gem install toys:0.21.0 rexml:3.4.4 + && gem install toys:0.21.0 rexml:3.4.4 json:2.19.2 WORKDIR /ruby-postprocessor COPY lib/*.rb /ruby-postprocessor/ COPY lib/owlbot /ruby-postprocessor/owlbot diff --git a/owlbot-postprocessor/cloudbuild.yaml b/owlbot-postprocessor/cloudbuild.yaml index 74db885c..94cd31f6 100644 --- a/owlbot-postprocessor/cloudbuild.yaml +++ b/owlbot-postprocessor/cloudbuild.yaml @@ -1,4 +1,17 @@ steps: + - name: 'gcr.io/cloud-builders/gcloud' + entrypoint: '/bin/bash' + args: + - '-c' + - | + PREV_DIGEST=$(gcloud container images list-tags gcr.io/cloud-devrel-public-resources/owlbot-ruby --filter="tags=latest" --format="value(digest)" 2>/dev/null || true) + if [ ! -z "$PREV_DIGEST" ]; then + HEX_DIGEST=${PREV_DIGEST#sha256:} + echo "Previous latest digest found: $PREV_DIGEST. Adding deprecation tag..." + gcloud container images add-tag gcr.io/cloud-devrel-public-resources/owlbot-ruby@$PREV_DIGEST gcr.io/cloud-devrel-public-resources/owlbot-ruby:deprecated-public-image-$HEX_DIGEST --quiet + else + echo "No previous latest image found to deprecate." + fi - name: 'gcr.io/cloud-builders/docker' entrypoint: '/bin/bash' args: @@ -6,9 +19,11 @@ steps: - | docker build \ -t gcr.io/cloud-devrel-public-resources/owlbot-ruby:${_VERSION} \ + -t gcr.io/cloud-devrel-public-resources/owlbot-ruby:public-image-${_VERSION} \ -t gcr.io/cloud-devrel-public-resources/owlbot-ruby:latest \ -f owlbot-postprocessor/Dockerfile \ owlbot-postprocessor images: - 'gcr.io/cloud-devrel-public-resources/owlbot-ruby:${_VERSION}' + - 'gcr.io/cloud-devrel-public-resources/owlbot-ruby:public-image-${_VERSION}' - 'gcr.io/cloud-devrel-public-resources/owlbot-ruby:latest' diff --git a/owlbot-postprocessor/test/test_owlbot_releases.rb b/owlbot-postprocessor/test/test_owlbot_releases.rb index 908cdf77..821a7f55 100644 --- a/owlbot-postprocessor/test/test_owlbot_releases.rb +++ b/owlbot-postprocessor/test/test_owlbot_releases.rb @@ -42,7 +42,7 @@ def run_process cmd, output: false ::FileUtils.rm_rf repo_dir ::FileUtils.mkdir_p repo_dir ::Dir.chdir repo_dir do - run_process ["git", "init"] + run_process ["git", "init", "--ref-format=files"] run_process ["git", "commit", "--allow-empty", "-m", "commit 1"] run_process ["git", "commit", "--allow-empty", "-m", "commit 2"] end