From d6d0a8032cee796a438d986f09a473c444589966 Mon Sep 17 00:00:00 2001 From: kislovdm Date: Tue, 9 Jan 2024 21:26:14 +0300 Subject: [PATCH] ver --- src/build/GetBuildVersion.psm1 | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/build/GetBuildVersion.psm1 diff --git a/src/build/GetBuildVersion.psm1 b/src/build/GetBuildVersion.psm1 new file mode 100644 index 0000000..11ea5d0 --- /dev/null +++ b/src/build/GetBuildVersion.psm1 @@ -0,0 +1,34 @@ +Function GetBuildVersion { + Param ( + [string]$VersionString + ) + + # Process through regex + $VersionString -match "(?\d+)(\.(?\d+))?(\.(?\d+))?(\-(?
[0-9A-Za-z\-\.]+))?(\+(?\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
+}
\ No newline at end of file