-
Notifications
You must be signed in to change notification settings - Fork 44
47 lines (37 loc) · 1.5 KB
/
Copy pathcheck-version-bump.yaml
File metadata and controls
47 lines (37 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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 }}"
MERGE_BASE=$(git merge-base "$BASE_SHA" "$HEAD_SHA")
CHANGED_FILES=$(git diff --name-only "$MERGE_BASE" "$HEAD_SHA")
if echo "$CHANGED_FILES" | grep -qE "^src/.*\.(py|pyi|proto)$"; then
BASE_VERSION=$(git show "$MERGE_BASE: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