File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments