Skip to content

Commit 323897f

Browse files
committed
Add missing script
1 parent 0e41da7 commit 323897f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

scripts/is_valid_increment.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/bash
2+
# Determines whether a version increment to a package is valid
3+
4+
is_valid_increment() {
5+
local current="$1"
6+
local next="$2"
7+
8+
if [[ "$current" == "null" ]]; then
9+
if [[ "$next" == "1.0.0" ]]; then
10+
return 0 # valid initial version
11+
else
12+
return 1 # invalid first version
13+
fi
14+
fi
15+
16+
IFS='.' read -r curr_major curr_minor curr_patch <<< "$current"
17+
IFS='.' read -r new_major new_minor new_patch <<< "$next"
18+
19+
if (( new_major == curr_major && new_minor == curr_minor && new_patch == curr_patch + 1 )); then
20+
return 0 # valid patch bump
21+
elif (( new_major == curr_major && new_minor == curr_minor + 1 && new_patch == 0 )); then
22+
return 0 # valid minor bump
23+
elif (( new_major == curr_major + 1 && new_minor == 0 && new_patch == 0 )); then
24+
return 0 # valid major bump
25+
else
26+
return 1 # invalid or skipped
27+
fi
28+
}

0 commit comments

Comments
 (0)