azure-sdk-for-cpp/eng/scripts/Update-PkgVersion.ps1
Ahson Khan fd9c3e5ebb
Fix true spelling errors across all source and header files within the SDK and add exceptions for false positives. (#2209)
Part of https://github.com/Azure/azure-sdk-for-cpp/issues/1277, checking what types of warnings the CI emits.

Verified all SDK product `.cpp`, `.hpp`, `.txt`, and `.md` files, primarily focused on azure-core. They are all clean now. There are some exceptions that needs to be added for keyvault and storage, but they are false positives, so not a concern.

> `cspell lint --config .vscode/cspell.json *.hpp */**/*.hpp`

CSpell: Files checked: 188, Issues found: 0 in 0 files

> `cspell lint --config .vscode/cspell.json *.cpp */**/*.cpp`

CSpell: Files checked: 186, Issues found: 88 in 15 files (keyvault and storage false positives, or tests)

> `cspell lint --config .vscode/cspell.json *.md */**/*.md`

CSpell: Files checked: 45, Issues found: 5 in 2 files (eng/common)

> `cspell lint --config .vscode/cspell.json *.txt */**/*.txt`

CSpell: Files checked: 44, Issues found: 0 in 0 files

> `cspell lint --config .vscode/cspell.json *.* */**/*`

CSpell: Files checked: 646, Issues found: 328 in 69 files (most of these are in eng\docs\api\assets\style.css or eng/common)

Deprioritize and ignored the errors from the test files (including test resource json files), and `eng/common` since those need to be centrally fixed.
2021-05-07 21:04:58 +00:00

100 lines
3.1 KiB
PowerShell

<#
.SYNOPSIS
Bumps up package versions after release
.PARAMETER RepoRoot
The root of the repo (defaults to ${PSScriptRoot}/..)
.PARAMETER ServiceDirectory
The service directory under <repo-root>/sdk/ used to find package_version.hpp
.PARAMETER PackageName
The package name under <repo-root>/sdk/<service-directory> used to find
package_version.hpp
.PARAMETER NewVersionString
New version string to use. Must follow SemVer conventions.
.DESCRIPTION
This script bumps up package versions following conventions defined at https://github.com/Azure/azure-sdk/blob/master/docs/policies/releases.md#incrementing-after-release-cpp
#>
[CmdletBinding()]
Param (
[ValidateNotNullOrEmpty()]
[string] $RepoRoot = "${PSScriptRoot}/..",
[Parameter(Mandatory=$True)]
[string] $ServiceDirectory,
[Parameter(Mandatory=$True)]
[string] $PackageName,
[string] $NewVersionString
)
. ${RepoRoot}\common\scripts\SemVer.ps1
. ${PSScriptRoot}\SdkVersion-Common.ps1
# Updated Version in version file and changelog using computed or set NewVersionString
function Update-Version(
[AzureEngSemanticVersion]$SemVer,
$VersionHppLocation,
$Unreleased=$True,
$ReplaceLatestEntryTitle=$False)
{
Write-Verbose "New Version: $SemVer"
if ($SemVer.HasValidPrereleaseLabel() -ne $true){
Write-Error "Invalid prerelease label: $SemVer"
exit 1
}
Write-Verbose "Saving package_version.hpp file..."
$versionHppContent = Get-Content $VersionHppLocation -Raw
if ($SemVer.IsPrerelease) {
$newContent = $versionHppContent -replace $VersionRegex, "`${1}$($SemVer.Major)`${2}$($SemVer.Minor)`${3}$($SemVer.Patch)`${4}`"$($SemVer.PrereleaseLabel).$($SemVer.PrereleaseNumber)`""
} else {
$newContent = $versionHppContent -replace $VersionRegex, "`${1}$($SemVer.Major)`${2}$($SemVer.Minor)`${3}$($SemVer.Patch)`${4}`"`""
}
$newContent | Set-Content $VersionHppLocation -NoNewline
# Set Version in ChangeLog file
& "${RepoRoot}/eng/common/scripts/Update-ChangeLog.ps1" `
-Version $SemVer.ToString() `
-ServiceDirectory $ServiceDirectory `
-PackageName $PackageName `
-Unreleased $Unreleased `
-ReplaceLatestEntryTitle $ReplaceLatestEntryTitle
}
$versionHppLocation = Get-VersionHppLocation `
-ServiceDirectory $ServiceDirectory `
-PackageName $PackageName
Write-Verbose "VERSION FILE: $versionHppLocation"
# Obtain Current Package Version
if ([System.String]::IsNullOrEmpty($NewVersionString))
{
$PackageVersion = & $PSScriptRoot/Get-PkgVersion.ps1 `
-ServiceDirectory $ServiceDirectory `
-PackageName $PackageName
$SemVer = [AzureEngSemanticVersion]::new($PackageVersion)
Write-Verbose "Current Version: ${PackageVersion}"
$SemVer.IncrementAndSetToPrerelease()
Update-Version -SemVer $SemVer -VersionHppLocation $versionHppLocation
}
else
{
# Use specified VersionString
$SemVer = [AzureEngSemanticVersion]::new($NewVersionString)
Update-Version `
-SemVer $SemVer `
-VersionHppLocation $versionHppLocation `
-Unreleased $False `
-ReplaceLatestEntryTitle $True
}