-
Notifications
You must be signed in to change notification settings - Fork 0
37 lines (32 loc) · 1.06 KB
/
Copy pathversion-bump.yml
File metadata and controls
37 lines (32 loc) · 1.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
name: Enforce Version Bump on Merge to Master
on:
push:
branches:
- main
jobs:
check-version-bump:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2 # fetch previous commit
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: Verify version bump
run: |
PREV_VERSION=$(git show HEAD~1:package.json | jq -r .version)
CUR_VERSION=$(jq -r .version package.json)
echo "Previous version: $PREV_VERSION"
echo "Current version: $CUR_VERSION"
# Compare semantic versions
if [ "$(printf '%s\n' "$PREV_VERSION" "$CUR_VERSION" | sort -V | head -n1)" = "$CUR_VERSION" ]; then
echo "❌ Version was not bumped (or decreased) compared to previous commit."
exit 1
else
echo "✅ Version bump detected."
fi