File tree Expand file tree Collapse file tree 1 file changed +22
-5
lines changed
Expand file tree Collapse file tree 1 file changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ MERGE_BASE=$(git merge-base "$HEAD_SHA" "$PR_BASE") # Find the merge base. This
1010SRC_DIFF_TO_BASE=$( git diff " $HEAD_SHA " .." $MERGE_BASE " --name-status -- " $DIR_TO_CRATE /src" " $DIR_TO_CRATE /Cargo.toml" )
1111CHANGELOG_DIFF=$( git diff " $HEAD_SHA " .." $MERGE_BASE " --name-only -- " $DIR_TO_CRATE /CHANGELOG.md" )
1212
13+ RELEASED_VERSION=$( git tag --sort=version:refname | grep " ^$CRATE -v" | tail -n1 | grep -Po " \d+\.\d+\.\d+" )
14+
15+
1316# If the source files of this crate weren't touched in this PR, exit early.
1417if [ -z " $SRC_DIFF_TO_BASE " ]; then
1518 exit 0;
@@ -21,8 +24,22 @@ if [ -z "$CHANGELOG_DIFF" ]; then
2124 exit 1
2225fi
2326
24- # Code was touched, ensure the version used in the manifest hasn't been released yet.
25- if git tag | grep -q " ^$CRATE -v${CRATE_VERSION} $" ; then
26- echo " v$CRATE_VERSION of '$CRATE ' has already been released, please bump the version."
27- exit 1
28- fi
27+ IFS=' .' read -r -a current <<< " $CRATE_VERSION"
28+ IFS=' .' read -r -a released <<< " $RELEASED_VERSION"
29+
30+ for i in $( seq 0 2) ;
31+ do
32+ case $(( current[i]- released[i])) in
33+ 0) continue ;;
34+ 1) if [[ -n $( printf " %s\n" " ${current[@]: i+1} " | grep -vFx ' 0' ) ]]; then
35+ echo " Patch version has been bumped even though minor isn't released yet" .
36+ exit 1
37+ fi
38+ exit 0 ;;
39+ * ) echo " Version of '$CRATE ' has been bumped more than once since last release v$RELEASED_VERSION ."
40+ exit 1 ;;
41+ esac
42+ done
43+
44+ echo " v$CRATE_VERSION of '$CRATE ' has already been released, please bump the version."
45+ exit 1
You can’t perform that action at this time.
0 commit comments