azure-sdk-for-cpp/eng/scripts/Get-PkgVersion.ps1
Wes Haggard e1d53996dc
Fix Prepare-Release and version update code (#2469)
- Passes through ReleaseDate
- Removes old version.txt logic
- Cleans up version scripts to import common.ps1
2021-06-23 16:56:49 -07:00

34 lines
914 B
PowerShell

[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] $ServiceDirectory,
[Parameter(Mandatory = $true)]
[string] $PackageName
)
. (Join-Path $PSScriptRoot ".." common scripts common.ps1)
$versionFileLocation = Get-VersionHppLocation `
-ServiceDirectory $ServiceDirectory `
-PackageName $PackageName
if (!$versionFileLocation) {
LogWarning "Failed to retrieve package version for '$ServiceDirectory/$PackageName'. No version file found."
return $null
}
$versionFileContents = Get-Content $versionFileLocation -Raw
if (!($versionFileContents -match $VersionRegex)) {
LogWarning "does not match version information schema"
return $null
}
$VersionString = if ($Matches.prerelease) {
"$($Matches.major).$($Matches.minor).$($Matches.patch)-$($Matches.prerelease)"
} else {
"$($Matches.major).$($Matches.minor).$($Matches.patch)"
}
return $VersionString