Repository navigation
Expand file tree
/
Copy pathplugin-version-verification.yml
More file actions
57 lines (47 loc) · 2.06 KB
/
Copy pathplugin-version-verification.yml
File metadata and controls
57 lines (47 loc) · 2.06 KB
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
name: QA - Plugin Version Verification
permissions: read-all
on:
workflow_dispatch:
workflow_call:
inputs:
plugin_repo:
required: false
type: string
default: 'WPDevelopers/notificationx'
plugin_branch:
required: false
type: string
default: 'master'
jobs:
version-check:
runs-on: ubuntu-24.04
name: Version Consistency Check
steps:
- name: Checkout NotificationX plugin
uses: actions/checkout@v4
with:
repository: ${{ inputs.plugin_repo }}
ref: ${{ inputs.plugin_branch }}
- name: Check all version numbers are consistent
run: |
# Extract each version string from its canonical location
V_HEADER=$(grep -oP "^\s*\*\s*Version:\s*\K[\d.]+" notificationx.php | head -1)
V_CONST=$(grep -oP "define\(\s*'NOTIFICATIONX_VERSION',\s*'?\K[\d.]+" notificationx.php | head -1)
echo "Plugin header (Version:): $V_HEADER"
echo "NOTIFICATIONX_VERSION constant: $V_CONST"
MISMATCH=0
[ "$V_HEADER" != "$V_CONST" ] && echo "::error::MISMATCH: Plugin header ($V_HEADER) ≠ NOTIFICATIONX_VERSION ($V_CONST)" && MISMATCH=1
# README.txt is optional — only check if present
if [ -f README.txt ]; then
V_README=$(grep -oP "Stable tag:\s*\K[\d.]+" README.txt | head -1)
echo "README.txt Stable tag: $V_README"
[ "$V_HEADER" != "$V_README" ] && echo "::error::MISMATCH: Plugin header ($V_HEADER) ≠ README.txt Stable tag ($V_README)" && MISMATCH=1
fi
# package.json version check (optional)
if [ -f package.json ]; then
V_PKG=$(grep -oP '"version":\s*"\K[\d.]+' package.json | head -1)
echo "package.json version: $V_PKG"
[ "$V_HEADER" != "$V_PKG" ] && echo "::warning::package.json version ($V_PKG) differs from plugin header ($V_HEADER)"
fi
[ "$MISMATCH" -eq 1 ] && exit 1
echo "✅ All version numbers are consistent: $V_HEADER"