Skip to content
Merged
Changes from 4 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
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,28 @@ changed_libraries="$(cat "${changed_libraries_file}")"
echo "Changed libraries are: ${changed_libraries:-"No changed library"}."

# run hermetic code generation docker image.
# Attempt to pull the image to see if it exists on release PRs.
if [[ "$current_branch" =~ ^release-please-- ]]; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could create release-please PRs from CLI as well.

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.

That's fine, as long as the branch prefix is release-please--.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that means we have to remember using release-please-- as the branch name, is there any harm we do this for every branches?

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.

You shouldn't have to use the Release Please CLI going forward which should eliminate the need to remember the branch prefix. The risk of always falling back is that if someone configures and invalid generator version, they won't get a CI failure as feedback.

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}."
previous_tag=$(git show "${target_branch}":.github/workflows/hermetic_library_generation.yaml | grep -m 1 "^[[:space:]]*image_tag:" | cut -d ':' -f 2- | cut -d '#' -f 1 | xargs || true)
Comment thread
suztomo marked this conversation as resolved.
Outdated
if [ -n "$previous_tag" ]; then
echo "Using previous image version: $previous_tag"
image_tag="$previous_tag"
else
echo "Failed to extract previous version from ${target_branch}. Proceeding with original tag."
fi
fi
fi

docker run \
--rm \
-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}" \
"${IMAGE_NAME}:${image_tag}" \
--generation-config-path="${workspace_name}/${generation_config}" \
--library-names="${changed_libraries}" \
--api-definitions-path="${workspace_name}/googleapis"
Expand Down
Loading