forked from novateams/nova.core
-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (61 loc) · 2.08 KB
/
version_check.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
---
name: Comparing PR version with the main version
on:
pull_request_target:
types:
- opened
- synchronize
branches:
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
version_check:
runs-on: ubuntu-latest
steps:
- name: Cloning the repository pull request repo...
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
path: pr
- name: Cloning Catapult main repository...
uses: actions/checkout@v4
with:
fetch-depth: 0
path: main
- name: Comparing PR version with main...
run: |
export C_RED="\x1b[91m"
export C_GREEN="\x1b[92m"
export C_YELLOW="\x1b[93m"
export C_RST="\x1b[0m"
VERSION_FILE="nova/core/galaxy.yml"
if [[ -e "pr/$VERSION_FILE" ]]; then
PR_VERSION=$(cat pr/$VERSION_FILE | grep "version:" | cut -d " " -f 2)
else
echo "pr/$VERSION_FILE does not exist."
exit 1
fi
if [[ -e "main/$VERSION_FILE" ]]; then
CURRENT_VERSION=$(cat main/$VERSION_FILE | grep "version:" | cut -d " " -f 2)
else
echo "main/$VERSION_FILE does not exist."
exit 1
fi
echo -n -e "${C_YELLOW}"
echo -e "Pull Request Version - $PR_VERSION"
echo -e "Current Version - $CURRENT_VERSION"
echo -n -e "${C_RST}"
if dpkg --compare-versions $PR_VERSION le $CURRENT_VERSION; then
echo -n -e "${C_RED}"
echo -e "Pull request version $PR_VERSION is <= than current version $CURRENT_VERSION."
echo -e "Please update the version in $VERSION_FILE file."
echo -n -e "${C_RST}"
exit 1
else
echo -n -e "${C_GREEN}"
echo "Version has been updated moving on"
echo -n -e "${C_RST}"
fi