-
Notifications
You must be signed in to change notification settings - Fork 8
37 lines (31 loc) · 1.18 KB
/
check-version-bump.yaml
File metadata and controls
37 lines (31 loc) · 1.18 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
name: Check Version Bump
on:
pull_request:
branches:
- main
jobs:
check-version-bump:
name: Enforce version bump when src/ is modified
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: 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 -q "^src/"; then
VERSION_BUMPED=$(git diff -U0 "$BASE_SHA" "$HEAD_SHA" -- pyproject.toml \
| grep "^+version = ")
if [ -z "$VERSION_BUMPED" ]; then
echo "ERROR: Files under src/ were modified but the version in pyproject.toml was not bumped."
exit 1
else
echo "Version bump detected: $VERSION_BUMPED"
fi
else
echo "No src/ changes. Version bump not required."
fi