Skip to content

feat(scripts): add PyPI proto version check to release version script - #510

Merged
slin1237 merged 1 commit into
mainfrom
slin/grpc-v
Feb 22, 2026
Merged

slin1237 merged 1 commit into
mainfrom
slin/grpc-v

Conversation

@slin1237

@slin1237 slin1237 commented Feb 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Extends check_release_versions.sh to also verify the smg-grpc-proto PyPI package version is bumped when proto files change, closing the gap where proto changes could ship without a PyPI version bump.

What changed

scripts/check_release_versions.sh

  • Phase 1b: New section after the Cargo crate loop that detects proto file changes in grpc_client/proto/ since the last tag, reads __version__ from grpc_client/python/smg_grpc_proto/__init__.py, and flags if the version wasn't bumped
  • Phase 2: Includes the PyPI package in the proposed fixes list with the conventional-commit-derived bump level
  • Phase 3: Auto-bumps __version__ in __init__.py via sed_inplace when the user accepts
  • Helpers: Added get_pypi_version, get_pypi_version_at_ref, and set_pypi_version following the same pattern as the existing Cargo helpers
  • Header: Updated to document the new checks (items 4-5)

Why

The script previously only checked Cargo crate versions. Proto file changes (which affect the PyPI-published smg-grpc-proto package) were not tracked, meaning proto changes could be released without a corresponding PyPI version bump.

How

The PyPI version lives in grpc_client/python/smg_grpc_proto/__init__.py as __version__ = "X.Y.Z" and is read dynamically by pyproject.toml. The script diffs grpc_client/proto/ against the tag, compares current vs tagged __version__, and uses detect_bump_level (conventional commits) to suggest the appropriate semver bump. The proto source of truth is grpc_client/proto/; the Python package already symlinks to it (smg_grpc_proto/proto -> ../../proto).

Test plan

  • Ran bash scripts/check_release_versions.sh against latest tag v1.0.1 — correctly detected 3 proto files changed and proposed v0.3.3 → v0.4.0 (minor)
  • Verified bash -n syntax check passes
  • Verified the script handles no-proto-changes case (prints green check)

Summary by CodeRabbit

  • New Features
    • Release version checks now automatically monitor and propose updates for the PyPI proto package alongside workspace crates.
    • Release workflow includes prompts to validate and apply PyPI version bumps when proto changes are detected.

Extend check_release_versions.sh to verify that the smg-grpc-proto
PyPI package version is bumped when proto files in grpc_client/proto/
change.

What changed:
- Phase 1b: detect proto file changes since the last tag, compare
  __version__ in grpc_client/python/smg_grpc_proto/__init__.py against
  the tagged version, and flag if unbumped
- Phase 2: include the PyPI package in proposed fixes with bump level
  from conventional commits
- Phase 3: auto-bump __version__ in __init__.py via sed when the user
  accepts the fix
- Added get_pypi_version, get_pypi_version_at_ref, and set_pypi_version
  helpers following the same pattern as the Cargo crate helpers
- Updated script header to document the new checks

The proto source of truth is grpc_client/proto/; the Python package
already symlinks to it (smg_grpc_proto/proto -> ../../proto), so no
file sync logic is needed.

Signed-off-by: Simo Lin <linsimo.mark@gmail.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @slin1237, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the release version checking script by adding robust validation for the smg-grpc-proto PyPI package. It ensures that any modifications to protocol buffer definitions are accompanied by a corresponding version bump in the Python package, thereby preventing inconsistencies and ensuring proper release management for proto-related changes.

Highlights

  • PyPI Proto Version Check: Extended the check_release_versions.sh script to include a new phase (Phase 1b) that verifies if the smg-grpc-proto PyPI package version has been bumped when changes are detected in the grpc_client/proto/ directory since the last git tag.
  • Helper Functions for PyPI Version Management: Introduced new shell functions: get_pypi_version, get_pypi_version_at_ref, and set_pypi_version to programmatically read and update the __version__ string within the grpc_client/python/smg_grpc_proto/__init__.py file.
  • Integration with Release Workflow: Integrated the PyPI proto package into the existing release version script's workflow, allowing it to be included in the list of proposed fixes (Phase 2) and enabling automatic version bumping via sed_inplace (Phase 3) when the user accepts the suggested changes.
  • Script Documentation Update: Updated the header comments of scripts/check_release_versions.sh to reflect the newly added checks for PyPI proto package versioning.
Changelog
  • scripts/check_release_versions.sh
    • Added a new section (Phase 1b) to check for changes in proto files and verify the smg-grpc-proto PyPI package version.
    • Introduced get_pypi_version, get_pypi_version_at_ref, and set_pypi_version helper functions for PyPI version handling.
    • Modified the total_fixes calculation to include potential PyPI version bumps.
    • Updated the fix proposal display to show smg-grpc-proto version changes.
    • Implemented the auto-bumping logic for the PyPI package version using set_pypi_version.
    • Updated the script's header comments to document the new PyPI proto version checks.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@coderabbitai

coderabbitai Bot commented Feb 22, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The release version check script is extended with Phase 1b to detect and manage smg-grpc-proto PyPI package versioning. It adds helper functions to read/write PyPI versions and integrate proto change detection and version bumping into the existing multi-phase workflow.

Changes

Cohort / File(s) Summary
PyPI Package Version Management
scripts/check_release_versions.sh
Added Phase 1b proto change detection and PyPI version extraction. New helper functions: get_pypi_version, get_pypi_version_at_ref, set_pypi_version. New variables: PROTO_DIR, PYPI_VERSION_FILE, PYPI_NEEDS_BUMP. Integrated PyPI version bumping into Phases 2–3 workflow with validation, bump computation, and version update application.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

grpc, ci

Suggested reviewers

  • CatherineSue
  • key4ng

Poem

🐰 A proto package bumps with grace,
PyPI versions find their place,
Phase by phase, the script does roam,
Versioning finds a newer home! ✨

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch slin/grpc-v

Comment @coderabbitai help to get the list of available commands and usage tips.

@slin1237
slin1237 merged commit 7bfa889 into main Feb 22, 2026
18 of 20 checks passed
@slin1237
slin1237 deleted the slin/grpc-v branch February 22, 2026 19:19

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

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.

Code Review

This pull request extends the release version checking script to also handle the smg-grpc-proto PyPI package, which is a valuable addition. The implementation is largely correct and follows the existing style of the script. I've identified one critical syntax error that would prevent the script from running correctly and a medium-severity suggestion to refactor some duplicated logic for better long-term maintainability. After addressing these points, the changes should be solid.

# Phase 2: Offer to fix
# ---------------------------------------------------------------------------
total_fixes=$(( ${#NEEDS_BUMP[@]} + ${#NEEDS_WS_SYNC[@]} ))
total_fixes=$(( ${#NEEDS_BUMP[@]} + ${#NEEDS_WS_SYNC[@]} + (${#PYPI_NEEDS_BUMP} > 0 ? 1 : 0) ))

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.

critical

This line introduces a syntax error. While bash's arithmetic context ((...)) supports a C-style ternary operator, the extra parentheses around the ternary expression (${#PYPI_NEEDS_BUMP} > 0 ? 1 : 0) are invalid and will cause the script to fail.

A more idiomatic and robust way to accomplish this in bash is to leverage the fact that a true condition evaluates to 1 in an arithmetic context. This is more concise and avoids the less common ternary syntax.

Suggested change
total_fixes=$(( ${#NEEDS_BUMP[@]} + ${#NEEDS_WS_SYNC[@]} + (${#PYPI_NEEDS_BUMP} > 0 ? 1 : 0) ))
total_fixes=$(( ${#NEEDS_BUMP[@]} + ${#NEEDS_WS_SYNC[@]} + (${#PYPI_NEEDS_BUMP} > 0) ))

Comment on lines +444 to +452
if [[ -n "$PYPI_NEEDS_BUMP" ]]; then
IFS='|' read -r pypi_ver pypi_level <<< "$PYPI_NEEDS_BUMP"
pypi_new=$(bump_version "$pypi_ver" "$pypi_level")
if set_pypi_version "$PYPI_VERSION_FILE" "$pypi_new"; then
echo -e " ${GREEN}✓${NC} $PYPI_VERSION_FILE → v$pypi_new"
else
fix_failed=$((fix_failed + 1))
fi
fi

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

The logic to parse PYPI_NEEDS_BUMP and calculate the new version (lines 445-446) is a duplicate of the logic in Phase 2 (lines 393-394). This code duplication can lead to maintenance issues, as any changes to the format of PYPI_NEEDS_BUMP would need to be updated in two separate places.

To improve maintainability and adhere to the DRY (Don't Repeat Yourself) principle, you could calculate the new version once in Phase 2, store it in a variable, and reuse that variable here in Phase 3.

For example:

# Before Phase 2
pypi_new_version=""

# In Phase 2 (lines 392-396)
if [[ -n "$PYPI_NEEDS_BUMP" ]]; then
    IFS='|' read -r pypi_ver pypi_level <<< "$PYPI_NEEDS_BUMP"
    pypi_new_version=$(bump_version "$pypi_ver" "$pypi_level")
    echo -e "  $(bump_label "$pypi_level") smg-grpc-proto v$pypi_ver → v$pypi_new_version ($PYPI_VERSION_FILE)"
fi

# In Phase 3 (this block)
if [[ -n "$PYPI_NEEDS_BUMP" ]]; then
    if set_pypi_version "$PYPI_VERSION_FILE" "$pypi_new_version"; then
        echo -e "  ${GREEN}✓${NC} $PYPI_VERSION_FILE → v$pypi_new_version"
    else
        fix_failed=$((fix_failed + 1))
    fi
fi

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