azure-sdk-for-cpp/eng/scripts/Get-PkgVersion.ps1
Daniel Jurek 919610f429
Use version.hpp for package versions (#572)
* Add version.txt
* Add doc generation for template
* Add version.hpp parsing and update capabilities to cmake and engsys
* Get-SdkVersion -> Get-PkgVersion
* Move Update-PkgVersion.ps1 under eng/scripts
* Get-PackageVersion -> Get-PkgVersion
* Update paths, params, verbosity
* Couple fixes to output and make use of new SemVer version
* Add fallback support for verison.txt in cases where we still use it to unblock release artifact generation
* Use version information in release pipeline
* Add workaround to generate storage pipeline artifacts
* eng/scripts/
* Write warning
* Haven't released storage-file-shares yet according to releases on GitHub
* Set release date on changelog.md
* Update CHANGELOG.md to indicate this is a test release
* Remove fallback exception for storage
* Re-add Rick's suggestions
* Revert "Remove fallback exception for storage"
2020-09-02 18:53:46 -07:00

39 lines
967 B
PowerShell

[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] $ServiceDirectory,
[Parameter(Mandatory = $true)]
[string] $PackageName
)
. ${PSScriptRoot}/SdkVersion-Common.ps1
$versionFileLocation = Get-VersionHppLocaiton `
-ServiceDirectory $ServiceDirectory `
-PackageName $PackageName
if (!$versionFileLocation) {
$fallback = Get-Content $RepoRoot/sdk/$ServiceDirectory/$PackageName/version.txt
if ($fallback) {
return $fallback
} else {
Write-Error "Cannot locate package version"
exit 1
}
}
$versionFileContents = Get-Content $versionFileLocation -Raw
if (!($versionFileContents -match $VersionRegex)) {
Write-Error "does not match version information schema"
}
$VersionString = if ($Matches.prerelease) {
"$($Matches.major).$($Matches.minor).$($Matches.patch)-$($Matches.prerelease)"
} else {
"$($Matches.major).$($Matches.minor).$($Matches.patch)"
}
return $VersionString