chore: fix versioning scripts
This commit is contained in:
@@ -2,7 +2,10 @@ param(
|
|||||||
[string]$Branch = "main"
|
[string]$Branch = "main"
|
||||||
)
|
)
|
||||||
|
|
||||||
$commits = git log $Branch..HEAD --format="%s"
|
$tag = git describe --tags --abbrev=0 2>$null
|
||||||
|
$base = if ($tag) { $tag } else { $Branch }
|
||||||
|
|
||||||
|
$commits = git log "$base..HEAD" --format="%s"
|
||||||
$commitList = $commits -split "`n"
|
$commitList = $commits -split "`n"
|
||||||
$major = 0
|
$major = 0
|
||||||
$minor = 0
|
$minor = 0
|
||||||
@@ -11,9 +14,9 @@ $patch = 0
|
|||||||
foreach ($message in $commitList) {
|
foreach ($message in $commitList) {
|
||||||
if ($message -match " BREAKING CHANGE|!:" -and $message.Trim().Length -gt 0) {
|
if ($message -match " BREAKING CHANGE|!:" -and $message.Trim().Length -gt 0) {
|
||||||
$major = 1
|
$major = 1
|
||||||
} elseif ($message -match "^feat(\(.*\))?:" -and $message.Trim().Length -gt 0) {
|
} elseif ($message -match "feat(\(.*\))?:" -and $message.Trim().Length -gt 0) {
|
||||||
$minor = 1
|
$minor = 1
|
||||||
} elseif ($message -match "^fix(\(.*\))?:" -and $message.Trim().Length -gt 0) {
|
} elseif ($message -match "fix(\(.*\))?:" -and $message.Trim().Length -gt 0) {
|
||||||
$patch = 1
|
$patch = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,7 +31,6 @@ if ($major -eq 1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$currentVersion = "0.0.0"
|
$currentVersion = "0.0.0"
|
||||||
$tag = git describe --tags --abbrev=0 2>$null
|
|
||||||
$hasExistingTag = $false
|
$hasExistingTag = $false
|
||||||
|
|
||||||
if ($tag) {
|
if ($tag) {
|
||||||
|
|||||||
@@ -2,7 +2,10 @@
|
|||||||
|
|
||||||
branch="${1:-main}"
|
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
|
major=0
|
||||||
minor=0
|
minor=0
|
||||||
patch=0
|
patch=0
|
||||||
@@ -10,9 +13,9 @@ patch=0
|
|||||||
while IFS= read -r message; do
|
while IFS= read -r message; do
|
||||||
if [[ -n "$message" ]] && [[ "$message" =~ " BREAKING CHANGE|!:" ]]; then
|
if [[ -n "$message" ]] && [[ "$message" =~ " BREAKING CHANGE|!:" ]]; then
|
||||||
major=1
|
major=1
|
||||||
elif [[ -n "$message" ]] && [[ "$message" =~ ^feat(\(.*\))?: ]]; then
|
elif [[ -n "$message" ]] && [[ "$message" =~ feat(\(.*\))?: ]]; then
|
||||||
minor=1
|
minor=1
|
||||||
elif [[ -n "$message" ]] && [[ "$message" =~ ^fix(\(.*\))?: ]]; then
|
elif [[ -n "$message" ]] && [[ "$message" =~ fix(\(.*\))?: ]]; then
|
||||||
patch=1
|
patch=1
|
||||||
fi
|
fi
|
||||||
done <<< "$commits"
|
done <<< "$commits"
|
||||||
@@ -27,7 +30,6 @@ elif [[ "$patch" -eq 0 ]] && [[ -n "$commits" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
currentVersion="0.0.0"
|
currentVersion="0.0.0"
|
||||||
tag=$(git describe --tags --abbrev=0 2>/dev/null)
|
|
||||||
hasExistingTag=false
|
hasExistingTag=false
|
||||||
|
|
||||||
if [[ -n "$tag" ]]; then
|
if [[ -n "$tag" ]]; then
|
||||||
@@ -54,12 +56,12 @@ fi
|
|||||||
if [[ "$majorNew" -eq "$majorCurrent" ]] && [[ "$minorNew" -eq "$minorCurrent" ]] && [[ "$patchNew" -eq "$patchCurrent" ]]; then
|
if [[ "$majorNew" -eq "$majorCurrent" ]] && [[ "$minorNew" -eq "$minorCurrent" ]] && [[ "$patchNew" -eq "$patchCurrent" ]]; then
|
||||||
if [[ "$hasExistingTag" == "false" ]]; then
|
if [[ "$hasExistingTag" == "false" ]]; then
|
||||||
version="0.0.0"
|
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"
|
echo "First release: publishing version 0.0.0"
|
||||||
else
|
else
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
version="$majorNew.$minorNew.$patchNew"
|
version="$majorNew.$minorNew.$patchNew"
|
||||||
echo "VERSION=$version" >> "$GITHUB_OUTPUT"
|
[[ -n "$GITHUB_OUTPUT" ]] && echo "VERSION=$version" >> "$GITHUB_OUTPUT" || echo "VERSION=$version"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user