chore: partial release script to handle sdk-platform-java#12713
chore: partial release script to handle sdk-platform-java#12713suztomo wants to merge 1 commit intogoogleapis:mainfrom
Conversation
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
| required=False, | |
| required=False, | |
| default="", |
| @click.option( | ||
| "--artifact-ids", | ||
| required=True, | ||
| required=False, |
| 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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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.
| 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 |
| 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" |
There was a problem hiding this comment.
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.
…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.
No description provided.