-
Notifications
You must be signed in to change notification settings - Fork 7
48 lines (41 loc) · 1.4 KB
/
python-version-consistency.yml
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
48
name: Python Version Consistency Check
on:
push:
paths:
- 'python/**/pyproject.toml'
pull_request:
paths:
- 'python/**/pyproject.toml'
jobs:
check_versions:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check version consistency
run: |
# Find all pyproject.toml files in the python/ directory
PYPROJECT_FILES=$(find python -name pyproject.toml)
# Initialize variables
FIRST_VERSION=""
INCONSISTENT=false
# Check each pyproject.toml file
for file in $PYPROJECT_FILES; do
VERSION=$(grep -oP 'version = "\K[^"]+' $file)
if [ -z "$FIRST_VERSION" ]; then
FIRST_VERSION=$VERSION
echo "Reference version: $FIRST_VERSION (from $file)"
elif [ "$VERSION" != "$FIRST_VERSION" ]; then
echo "Inconsistent version found in $file: $VERSION"
INCONSISTENT=true
else
echo "Consistent version found in $file: $VERSION"
fi
done
# Exit with error if versions are inconsistent
if [ "$INCONSISTENT" = true ]; then
echo "Error: Inconsistent versions found across pyproject.toml files"
exit 1
else
echo "Success: All pyproject.toml files have consistent versions"
fi