-
Notifications
You must be signed in to change notification settings - Fork 1.1k
build: fall back to previous image version on release PRs #12848
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
Changes from all commits
3c59412
5fa7830
823b98c
c1395d2
53d67a1
16cfa1b
ef92609
54269dc
b74fe50
1ae26cc
d19bfbb
43835e2
68519fb
2cbaa3c
7dc57e7
d07cfd9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #!/bin/bash | ||
| # Copyright 2026 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| set -exo pipefail | ||
|
|
||
| REQUESTED_TAG="$1" | ||
| TARGET_BRANCH="$2" | ||
| shift 2 | ||
|
|
||
| # Parse arguments using '--' as delimiter | ||
| DOCKER_OPTS=() | ||
| CONTAINER_CMD=() | ||
| found_delimiter=false | ||
|
|
||
| for arg in "$@"; do | ||
| if [ "$arg" == "--" ]; then | ||
| found_delimiter=true | ||
| continue | ||
| fi | ||
| if $found_delimiter; then | ||
| CONTAINER_CMD+=("$arg") | ||
| else | ||
| DOCKER_OPTS+=("$arg") | ||
| fi | ||
| done | ||
|
|
||
| IMAGE_NAME="gcr.io/cloud-devrel-public-resources/java-library-generation" | ||
| # Support both local git and GitHub Actions environment variables | ||
| CURRENT_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME:-$(git branch --show-current)}}" | ||
| IMAGE_TAG="$REQUESTED_TAG" | ||
|
|
||
| # Fallback logic on Release PR branches | ||
| if [[ "$CURRENT_BRANCH" =~ ^release-please-- ]]; then | ||
| echo "Detected release PR branch: $CURRENT_BRANCH" | ||
| if ! docker pull "${IMAGE_NAME}:${IMAGE_TAG}"; then | ||
| echo "Image not found for version ${IMAGE_TAG}. Falling back to previous version from ${TARGET_BRANCH}." | ||
| # Extract tag from target branch's versions.txt using explicit fetch | ||
| git fetch origin "${TARGET_BRANCH}" --depth=1 || true | ||
| PREVIOUS_TAG=$(git show FETCH_HEAD:versions.txt | grep "^gapic-generator-java:" | cut -d ':' -f 2 || true) | ||
| if [ -n "$PREVIOUS_TAG" ]; then | ||
| echo "Using previous image version: $PREVIOUS_TAG" | ||
| IMAGE_TAG="$PREVIOUS_TAG" | ||
| else | ||
| echo "Failed to extract fallback tag. Proceeding with requested tag." | ||
| fi | ||
| fi | ||
| fi | ||
|
|
||
| # Execute Docker run with proper ordering | ||
| docker run --rm "${DOCKER_OPTS[@]}" "${IMAGE_NAME}:${IMAGE_TAG}" "${CONTAINER_CMD[@]}" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,10 @@ ARG GRPC_VERSION=1.80.0 | |
| ENV HOME=/home | ||
| ENV OS_ARCHITECTURE="linux-x86_64" | ||
|
|
||
| # {x-version-update-start:gapic-generator-java:current} | ||
| ENV GENERATOR_VERSION="2.71.0" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is needed?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes,
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. We are already setting it in the CI hermetic_library_generation.yaml though, so this is for scenarios that are not triggered through CI? |
||
| # {x-version-update-end} | ||
|
|
||
| # install OS tools | ||
| RUN apt update && apt install -y curl unzip rsync jq nodejs npm git openjdk-17-jdk | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blakeli0 Note that I'm removing this version declaration because it's confusing as it doesn't get updated, and it's not used anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. We used to update this version in the daily generation PR to trigger a full generation, but we always use the latest snapshot version now after monorepo migration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you intend to fix this file in the split repositories?
E.g, https://github.com/googleapis/java-firestore/blob/main/generation_config.yaml#L1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's OK to wait until the other repos migrate to the monorepo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this is resulted from monorepo migration. I don't think we want to do it for split repos.