Skip to content

ci: support release candidate publishing #893

ci: support release candidate publishing

ci: support release candidate publishing #893

name: Check Version Bump
on:
pull_request:
branches:
- main
permissions:
contents: read
jobs:
check-version-bump:
name: Check Version Bump
runs-on: ${{ contains(github.server_url, 'github.com') && 'ubuntu-latest' || fromJSON('["self-hosted"]') }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install version comparison dependency
run: python -m pip install packaging
- name: Check that version was bumped if src/ was modified
run: |
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
CHANGED_FILES=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA")
if echo "$CHANGED_FILES" | grep -qE "^src/.*\.(py|pyi|proto)$"; then
BASE_VERSION=$(git show "$BASE_SHA:pyproject.toml" | grep "^version = " | cut -d'"' -f2)
HEAD_VERSION=$(git show "$HEAD_SHA:pyproject.toml" | grep "^version = " | cut -d'"' -f2)
# Use PEP 440 ordering because sort -V ranks RCs above final releases
python .github/scripts/check_version_bump.py \
"$BASE_VERSION" "$HEAD_VERSION"
else
echo "No source file changes under src/. Version bump not required."
fi