Fix Prepare-Release and version update code (#2469)

- Passes through ReleaseDate
- Removes old version.txt logic
- Cleans up version scripts to import common.ps1
This commit is contained in:
Wes Haggard 2021-06-23 16:56:49 -07:00 committed by GitHub
parent 7a31ca5dd3
commit e1d53996dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 45 deletions

View File

@ -1,35 +1,20 @@
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] $ServiceDirectory,
[Parameter(Mandatory = $true)]
[string] $PackageName
)
$repoRoot = Resolve-Path "$PSScriptRoot/../..";
. (Join-Path ${repoRoot} eng common scripts logging.ps1)
. (Join-Path ${repoRoot} eng scripts SdkVersion-Common.ps1)
. (Join-Path $PSScriptRoot ".." common scripts common.ps1)
$versionFileLocation = Get-VersionHppLocation `
-ServiceDirectory $ServiceDirectory `
-PackageName $PackageName
if (!$versionFileLocation) {
$fallbackpath = Join-Path $RepoRoot sdk $ServiceDirectory $PackageName version.txt
if (!(Test-Path $fallbackpath))
{
LogWarning "Failed to retrieve package version. No version file found."
return $null
}
$fallback = Get-Content $fallbackpath
if ($fallback) {
return $fallback
} else {
LogWarning "Cannot locate package version"
return $null
}
LogWarning "Failed to retrieve package version for '$ServiceDirectory/$PackageName'. No version file found."
return $null
}
$versionFileContents = Get-Content $versionFileLocation -Raw

View File

@ -5,9 +5,14 @@ $packagePattern = "package-info.json"
$MetadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/releases/latest/cpp-packages.csv"
$BlobStorageUrl = "https://azuresdkdocs.blob.core.windows.net/%24web?restype=container&comp=list&prefix=cpp%2F&delimiter=%2F"
$VersionRegex = '(#define AZURE_\w+_VERSION_MAJOR )(?<major>[0-9]+)(\s+#define AZURE_\w+_VERSION_MINOR )(?<minor>[0-9]+)(\s+#define AZURE_\w+_VERSION_PATCH )(?<patch>[0-9]+)(\s+#define AZURE_\w+_VERSION_PRERELEASE )"(?<prerelease>[a-zA-Z0-9.]*)"';
function Get-VersionHppLocation ($ServiceDirectory, $PackageName) {
$versionHppLocation = Get-ChildItem package_version.hpp -Path "$RepoRoot/sdk/$ServiceDirectory/$PackageName" -Recurse
Write-Verbose "package_version.hpp location: $versionHppLocation"
return $versionHppLocation
}
function Get-cpp-PackageInfoFromRepo($pkgPath, $serviceDirectory)
function Get-cpp-PackageInfoFromRepo($pkgPath, $serviceDirectory)
{
$pkgName = Split-Path -Leaf $pkgPath
$packageVersion = & $PSScriptRoot/Get-PkgVersion.ps1 -ServiceDirectory $serviceDirectory -PackageName $pkgName
@ -15,13 +20,15 @@ function Get-cpp-PackageInfoFromRepo($pkgPath, $serviceDirectory)
{
$packageProps = [PackageProps]::new($pkgName, $packageVersion, $pkgPath, $serviceDirectory)
$packageProps.ArtifactName = $pkgName
$packageProps.IsNewSDK = "true"
$packageProps.SdkType = "client"
return $packageProps
}
return $null
}
# Parse out package publishing information from a package-info.json file.
function Get-cpp-PackageInfoFromPackageFile($pkg, $workingDirectory)
function Get-cpp-PackageInfoFromPackageFile($pkg, $workingDirectory)
{
$packageInfo = Get-Content -Raw -Path $pkg | ConvertFrom-Json
$packageArtifactLocation = (Get-ItemProperty $pkg).Directory.FullName
@ -63,7 +70,7 @@ function Publish-cpp-GithubIODocs ($DocLocation, $PublicArtifactLocation)
Upload-Blobs -DocDir $DocLocation -PkgName $packageInfo.name -DocVersion $packageInfo.version -ReleaseTag $releaseTag
}
function Get-cpp-GithubIoDocIndex()
function Get-cpp-GithubIoDocIndex()
{
# Update the main.js and docfx.json language content
UpdateDocIndexFiles -appTitleLang "C++"
@ -77,8 +84,11 @@ function Get-cpp-GithubIoDocIndex()
GenerateDocfxTocContent -tocContent $tocContent -lang "C++"
}
function SetPackageVersion ($PackageName, $Version, $ServiceDirectory)
function SetPackageVersion ($PackageName, $Version, $ServiceDirectory, $ReleaseDate)
{
& "$EngDir/scripts/Update-PkgVersion.ps1" -ServiceDirectory $ServiceDirectory -PackageName $PackageName `
-NewVersionString $Version
& "$EngDir/scripts/Update-PkgVersion.ps1" `
-ServiceDirectory $ServiceDirectory `
-PackageName $PackageName `
-NewVersionString $Version `
-ReleaseDate $ReleaseDate
}

View File

@ -1,15 +0,0 @@
# NOTE: Update-PkgVersion and Get-PkgVersion relies on these variables and
# functions
$RepoRoot = "${PSScriptRoot}/../.."
$VersionRegex = '(#define AZURE_\w+_VERSION_MAJOR )(?<major>[0-9]+)(\s+#define AZURE_\w+_VERSION_MINOR )(?<minor>[0-9]+)(\s+#define AZURE_\w+_VERSION_PATCH )(?<patch>[0-9]+)(\s+#define AZURE_\w+_VERSION_PRERELEASE )"(?<prerelease>[a-zA-Z0-9.]*)"';
function Get-VersionHppLocation ($ServiceDirectory, $PackageName) {
$versionHppLocation = Get-ChildItem package_version.hpp -Path "$RepoRoot/sdk/$ServiceDirectory/$PackageName" -Recurse
Write-Verbose "package_version.hpp location: $versionHppLocation"
if (!$versionHppLocation) {
Write-Warning "Could not locate package_version.hpp file in sdk/$ServiceDirectory/$PackageName"
}
return $versionHppLocation
}

View File

@ -29,11 +29,11 @@ Param (
[string] $ServiceDirectory,
[Parameter(Mandatory=$True)]
[string] $PackageName,
[string] $NewVersionString
[string] $NewVersionString,
[string] $ReleaseDate
)
. ${RepoRoot}\common\scripts\SemVer.ps1
. ${PSScriptRoot}\SdkVersion-Common.ps1
. (Join-Path $PSScriptRoot ".." common scripts common.ps1)
# Updated Version in version file and changelog using computed or set NewVersionString
function Update-Version(
@ -65,14 +65,18 @@ function Update-Version(
-ServiceDirectory $ServiceDirectory `
-PackageName $PackageName `
-Unreleased $Unreleased `
-ReplaceLatestEntryTitle $ReplaceLatestEntryTitle
-ReplaceLatestEntryTitle $ReplaceLatestEntryTitle `
-ReleaseDate $ReleaseDate
}
$versionHppLocation = Get-VersionHppLocation `
-ServiceDirectory $ServiceDirectory `
-PackageName $PackageName
Write-Verbose "VERSION FILE: $versionHppLocation"
if (!$versionHppLocation) {
LogError "Failed to retrieve package version for '$ServiceDirectory/$PackageName'. No version file found."
exit 1
}
# Obtain Current Package Version
if ([System.String]::IsNullOrEmpty($NewVersionString))