-
Notifications
You must be signed in to change notification settings - Fork 5
33 lines (32 loc) · 1.19 KB
/
pr-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
name: version-check
on:
pull_request:
branches:
- master
paths-ignore:
- '.github/**'
jobs:
release:
name: Check Version
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Version diff
run: |
# read version from file: ZonPHP/inc/version_info.php of head branch
HEAD_VERSION=$( grep '$version = ' ZonPHP/inc/version_info.php | cut -d '"' -f 2 )
echo "HEAD_VERSION --> $HEAD_VERSION"
git checkout master
# read version from file: ZonPHP/inc/version_info.php of master branch
MASTER_VERSION=$( grep '$version = ' ZonPHP/inc/version_info.php | cut -d '"' -f 2 )
echo "MASTER_VERSION --> $MASTER_VERSION"
#if [ "$HEAD_VERSION" \> "$MASTER_VERSION" ]; then
if [ "$(printf '%s\n' "$HEAD_VERSION" "$MASTER_VERSION" | sort -V | head -n 1)" != "$HEAD_VERSION" ]; then
echo "Great job, master version $MASTER_VERSION will become $HEAD_VERSION soon"
else
echo "Head $HEAD_VERSION not updated before merging into master"
exit 1
fi