chore: fix versioning scripts

This commit is contained in:
Stevan Freeborn
2026-03-30 17:55:53 -05:00
parent b4de87ed27
commit 2359f092fe
2 changed files with 14 additions and 10 deletions
+8 -6
View File
@@ -2,7 +2,10 @@
branch="${1:-main}"
commits=$(git log "$branch..HEAD" --format="%s")
tag=$(git describe --tags --abbrev=0 2>/dev/null)
base="${tag:-$branch}"
commits=$(git log "$base..HEAD" --format="%s")
major=0
minor=0
patch=0
@@ -10,9 +13,9 @@ patch=0
while IFS= read -r message; do
if [[ -n "$message" ]] && [[ "$message" =~ " BREAKING CHANGE|!:" ]]; then
major=1
elif [[ -n "$message" ]] && [[ "$message" =~ ^feat(\(.*\))?: ]]; then
elif [[ -n "$message" ]] && [[ "$message" =~ feat(\(.*\))?: ]]; then
minor=1
elif [[ -n "$message" ]] && [[ "$message" =~ ^fix(\(.*\))?: ]]; then
elif [[ -n "$message" ]] && [[ "$message" =~ fix(\(.*\))?: ]]; then
patch=1
fi
done <<< "$commits"
@@ -27,7 +30,6 @@ elif [[ "$patch" -eq 0 ]] && [[ -n "$commits" ]]; then
fi
currentVersion="0.0.0"
tag=$(git describe --tags --abbrev=0 2>/dev/null)
hasExistingTag=false
if [[ -n "$tag" ]]; then
@@ -54,12 +56,12 @@ fi
if [[ "$majorNew" -eq "$majorCurrent" ]] && [[ "$minorNew" -eq "$minorCurrent" ]] && [[ "$patchNew" -eq "$patchCurrent" ]]; then
if [[ "$hasExistingTag" == "false" ]]; then
version="0.0.0"
echo "VERSION=$version" >> "$GITHUB_OUTPUT"
[[ -n "$GITHUB_OUTPUT" ]] && echo "VERSION=$version" >> "$GITHUB_OUTPUT" || echo "VERSION=$version"
echo "First release: publishing version 0.0.0"
else
exit 0
fi
else
version="$majorNew.$minorNew.$patchNew"
echo "VERSION=$version" >> "$GITHUB_OUTPUT"
[[ -n "$GITHUB_OUTPUT" ]] && echo "VERSION=$version" >> "$GITHUB_OUTPUT" || echo "VERSION=$version"
fi