This commit is contained in:
kislovdm
2024-01-09 21:27:35 +03:00
parent 6c926d5623
commit 553079cdc8
+34
View File
@@ -0,0 +1,34 @@
Function GetBuildVersion {
Param (
[string]$VersionString
)
# Process through regex
$VersionString -match "(?<major>\d+)(\.(?<minor>\d+))?(\.(?<patch>\d+))?(\-(?<pre>[0-9A-Za-z\-\.]+))?(\+(?<build>\d+))?" | Out-Null
if ($matches -eq $null) {
return "1.0.0-build"
}
# Extract the build metadata
$BuildRevision = [uint64]$matches['build']
# Extract the pre-release tag
$PreReleaseTag = [string]$matches['pre']
# Extract the patch
$Patch = [uint64]$matches['patch']
# Extract the minor
$Minor = [uint64]$matches['minor']
# Extract the major
$Major = [uint64]$matches['major']
$Version = [string]$Major + '.' + [string]$Minor + '.' + [string]$Patch;
if ($PreReleaseTag -ne [string]::Empty) {
$Version = $Version + '-' + $PreReleaseTag
}
if ($BuildRevision -ne 0) {
$Version = $Version + '.' + [string]$BuildRevision
}
return $Version
}