-
Notifications
You must be signed in to change notification settings - Fork 12
60 lines (52 loc) · 2.14 KB
/
check_package_version.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
49
50
51
52
53
54
55
56
57
58
59
name: Compare the package version of the PR with the main branch
# The workflow gets triggered by pushes and pull requests
on:
pull_request:
branches: [ "main" ]
jobs:
compare-versions:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
# Checks out the code in the repository
- uses: actions/checkout@v3
- name: Compile CLUEstering modules
working-directory: ${{github.workspace}}
run: |
git fetch
RED="\033[0;31m"
pr_version=$(cat setup.py | grep "__version__ " | awk -F '"' '{print $2}')
pr_major=$(echo "$pr_version" | awk -F '.' '{print $1}')
pr_minor=$(echo "$pr_version" | awk -F '.' '{print $2}')
pr_patch=$(echo "$pr_version" | awk -F '.' '{print $3}')
echo "Switching to 'main' branch"
git switch main
main_version=$(cat setup.py | grep "__version__ " | awk -F '"' '{print $2}')
main_major=$(echo "$main_version" | awk -F '.' '{print $1}')
main_minor=$(echo "$main_version" | awk -F '.' '{print $2}')
main_patch=$(echo "$main_version" | awk -F '.' '{print $3}')
if [ "$main_major" -le "$pr_major" ]; then
if [ "$main_minor" -le "$pr_minor" ]; then
if [ "$main_patch" -lt "$pr_patch" ] ||
[ "$main_major" -lt "$pr_major" ] ||
[ "$main_minor" -lt "$pr_minor" ]; then
exit 0 # at least one version counters has been updated
else
echo -e "${RED}ERROR: Patch version is behind main. Update the version in setup.py"
echo -e "${RED}main -> $main_version"
echo -e "${RED}pr -> $pr_version"
exit 1
fi
else
echo -e "${RED}ERROR: Minor version is behind main. Update the version in setup.py"
echo -e "${RED}main -> $main_version"
echo -e "${RED}pr -> $pr_version"
exit 1
fi
else
echo -e "${RED}ERROR: Major version is behind main. Update the version in setup.py"
echo -e "${RED}main -> $main_version"
echo -e "${RED}pr -> $pr_version"
exit 1
fi