Skip to content
Open
Show file tree
Hide file tree
Changes from 7 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
5 changes: 2 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,12 @@ jobs:
- name: validate generation configuration
shell: bash
run: |
docker run \
--rm \
bash generation/run_generator_docker.sh "${library_generation_image_tag}" "${{ github.base_ref || 'main' }}" \
--quiet \
-u "$(id -u):$(id -g)" \
-v "$(pwd):${workspace_name}" \
--entrypoint python \
gcr.io/cloud-devrel-public-resources/java-library-generation:"${library_generation_image_tag}" \
-- \
/src/library_generation/cli/entry_point.py validate-generation-config
env:
library_generation_image_tag: 2.68.0
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/generated_files_sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ jobs:
- name: Generate root pom.xml file
shell: bash
run: |
docker run \
--rm \
bash generation/run_generator_docker.sh "${library_generation_image_tag}" "${{ github.base_ref }}" \
--quiet \
-u "$(id -u):$(id -g)" \
-v "$(pwd):/workspace" \
--entrypoint python \
gcr.io/cloud-devrel-public-resources/java-library-generation:"${library_generation_image_tag}" \
-- \
/src/library_generation/cli/generate_monorepo_root_pom.py \
generate \
--repository-path=/workspace
Expand All @@ -48,13 +47,12 @@ jobs:
- name: Generate gapic-libraries-bom/pom.xml
shell: bash
run: |
docker run \
--rm \
bash generation/run_generator_docker.sh "${library_generation_image_tag}" "${{ github.base_ref }}" \
--quiet \
-u "$(id -u):$(id -g)" \
-v "$(pwd):/workspace" \
--entrypoint python \
gcr.io/cloud-devrel-public-resources/java-library-generation:"${library_generation_image_tag}" \
-- \
/src/library_generation/cli/generate_monorepo_gapic_bom.py \
generate \
--repository-path=/workspace \
Expand Down
61 changes: 61 additions & 0 deletions generation/run_generator_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/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
PREVIOUS_TAG=$(git show "${TARGET_BRANCH}":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[@]}"
1 change: 0 additions & 1 deletion generation_config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
gapic_generator_version: 2.70.0
Copy link
Copy Markdown
Member Author

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.

googleapis_commitish: 62e4ecb2f4390728990514fea14aad0431881a52
libraries_bom_version: 26.79.0
libraries:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ set -exo pipefail
# the default value is generation_config.yaml in the repository root.
# 5. [optional] showcase_mode, true if we wish to download the showcase api
# definitions, which are necessary for generating the showcase library.
IMAGE_NAME="gcr.io/cloud-devrel-public-resources/java-library-generation"
while [[ $# -gt 0 ]]; do
key="$1"
case "${key}" in
Expand Down Expand Up @@ -123,13 +124,12 @@ changed_libraries="$(cat "${changed_libraries_file}")"
echo "Changed libraries are: ${changed_libraries:-"No changed library"}."

# run hermetic code generation docker image.
docker run \
--rm \
bash generation/run_generator_docker.sh "${image_tag}" "${target_branch}" \
-u "$(id -u):$(id -g)" \
-v "$(pwd):${workspace_name}" \
-v "${api_def_dir}:${workspace_name}/googleapis" \
-e GENERATOR_VERSION="${image_tag}" \
gcr.io/cloud-devrel-public-resources/java-library-generation:"${image_tag}" \
-- \
--generation-config-path="${workspace_name}/${generation_config}" \
--library-names="${changed_libraries}" \
--api-definitions-path="${workspace_name}/googleapis"
Expand Down
Loading