Skip to content

chore: partial release script to handle sdk-platform-java#12713

Draft
suztomo wants to merge 1 commit intogoogleapis:mainfrom
suztomo:partial-release-script
Draft

chore: partial release script to handle sdk-platform-java#12713
suztomo wants to merge 1 commit intogoogleapis:mainfrom
suztomo:partial-release-script

Conversation

@suztomo
Copy link
Copy Markdown
Member

@suztomo suztomo commented Apr 8, 2026

No description provided.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a flag to automate versioning for Java artifacts in partial_release.py and refactors apply_versions.sh to support XML, YAML, and Java files with a progress bar. Feedback identifies potential crashes from missing default values, a division-by-zero risk in the progress calculation, and opportunities to improve the accuracy and performance of the version replacement logic.

@click.option(
"--artifact-ids",
required=True,
required=False,
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.

high

The --artifact-ids option is now optional, but it lacks a default value. If this option is omitted and --sdk-platform-java is not set, artifact_ids will be None, which will cause an AttributeError when bump_version attempts to call artifact_ids.split(","). Adding default="" ensures the variable is always a string and avoids the crash.

Suggested change
required=False,
required=False,
default="",

@click.option(
"--artifact-ids",
required=True,
required=False,
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.

high

Similar to the bump-snapshot-version command, the --artifact-ids option here should have a default value to prevent a NoneType error in bump_version when the flag is omitted.

Suggested change
required=False,
required=False,
default="",

Comment on lines +40 to +44
echo "/x-version-update:$K:\(current\|released\)/{s|>\([^<]*\)<|>$V<|;}" >> "$SED_SCRIPT"
# Pattern 2: YAML _VERSION: '...' or "..."
echo "/x-version-update:$K:\(current\|released\)/{s|: [\'\"][^\'\"]*[\'\"]|: \'$V\'|;}" >> "$SED_SCRIPT"
# Pattern 3: Java static final String VERSION = "..."
echo "/x-version-update-start:$K:\(current\|released\)/{n;s|\".*\"|\"$V\"|;}" >> "$SED_SCRIPT"
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.

high

The sed replacement patterns for XML, YAML, and Java are quite generic and rely on the marker being the only relevant content on the line (or the next line for Java). For example, the XML pattern s|>\([^<]*\)<|>$V<| will replace the first tag's content on the line, which might not be the version tag if multiple tags exist (e.g., <groupId>foo</groupId><version>1.0</version>). \n\nConsider making these patterns more specific by anchoring them to the marker or the expected tag name (e.g., <version>) to avoid accidental replacements in complex files.

CURRENT_FILE=0
while read -r FILE; do
CURRENT_FILE=$((CURRENT_FILE + 1))
echo -ne "Progress: $CURRENT_FILE/$TOTAL_FILES ($((CURRENT_FILE * 100 / TOTAL_FILES))%)\r"
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.

medium

If no files are found matching the search criteria, TOTAL_FILES will be 0, resulting in a division by zero error in the progress calculation. It is safer to wrap the progress output in a conditional check.

Suggested change
echo -ne "Progress: $CURRENT_FILE/$TOTAL_FILES ($((CURRENT_FILE * 100 / TOTAL_FILES))%)\r"
if [ "$TOTAL_FILES" -gt 0 ]; then
echo -ne "Progress: $CURRENT_FILE/$TOTAL_FILES ($((CURRENT_FILE * 100 / TOTAL_FILES))%)\r"
fi

Comment on lines +53 to +57
while read -r FILE; do
CURRENT_FILE=$((CURRENT_FILE + 1))
echo -ne "Progress: $CURRENT_FILE/$TOTAL_FILES ($((CURRENT_FILE * 100 / TOTAL_FILES))%)\r"
sed -i -f "$SED_SCRIPT" "$FILE"
done <<< "$FILES"
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.

medium

Spawning a new sed process for every file in a loop is significantly slower than processing all files in a single sed invocation (e.g., using xargs sed -i -f "$SED_SCRIPT"). While the progress bar provides feedback, it introduces a performance bottleneck that may become substantial in large repositories. Consider batching the files or using xargs if execution time becomes a concern.

suztomo added a commit that referenced this pull request Apr 8, 2026
…se (#12712)

Version.java was not updated by the `apply_versions.sh`
#12713.

The spanner artifacts were not having correct version. This pull request
fixes them. This source tree passed the check in
https://github.com/googleapis/google-cloud-java/pull/12714/changes#diff-4dd8a804177e94b35097216011c8ccae349a9792ec7b0c8ba62209a69814f48b.

The empty line in google-cloud-pom-parent/pom.xml is for the release
script to consider this commit is the full repository release.

This skips google-auth-library-java module and other modules are using
the version already available in Maven Central. This is to remove the
circular dependency of POM references.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant