-
-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (43 loc) · 1.33 KB
/
master-pr-check-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
name: "Check for version update in PR to Master"
on:
pull_request:
# Sequence of patterns matched against refs/heads
branches:
- master
jobs:
master-pr-check-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Check if version changed
run: |
check_versions() {
git diff origin/master package.json | grep version
}
version_changed=`check_versions | wc -l | tr -d '[:space:]'`
if [ $version_changed -gt 1 ]; then
echo "Versions are different; verifying that the version increased"
check_versions
version_increased=`check_versions | awk -F\" '{
split($4, old, ".");
getline;
split($4, new, ".");
if(new[1] > old[1] \
|| (new[1] == old[1] && new[2] > old[2]) \
|| (new[1] == old[1] && new[2] == old[2] && new[3] > old[3])) {
print 1
} else {
print 0
}
}'`
if [ $version_increased -eq 1 ]; then
echo "Version is properly increased!"
exit 0
else
echo "Version is not properly increased; failing..."
exit 1
fi
else
echo "Version has not been modified; failing..."
exit 1
fi