From 54086d7c2d62798163ef4e4032837a9b0a5b5916 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Thu, 4 Feb 2021 12:14:23 -0800 Subject: [PATCH 1/2] Update Contributing.md --- CONTRIBUTING.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 939885924fd3d..bfdb5b000de96 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -292,17 +292,14 @@ To consume the a dev package set the exact version in your project or to consume ## Preparing to a release of the new library -To update the CHANGELOG, version and release tracking information use the `.\eng\scripts\Prepare-Release.ps1` script. - -The syntax is `.\eng\scripts\Prepare-Release.ps1 `. The script would ask you for a new version or `NA` if you are not releasing in this cycle. +To prepare a package for release you should make use of `.\eng\common\scripts\Prepare-Release.ps1` script passing it appropriate arguments for the package intended for release as well as the release date. This script will correctly update the package version in the repo as well as update DevOps release work items for that release. If you are releasing out-of-band please use the `-ReleaseDate` parameter to specify the release data. `ReleaseDate` should be in `yyyy-MM-dd` format. Example invocations: ```powershell -.\eng\scripts\Prepare-Release.ps1 Azure.Core -.\eng\scripts\Prepare-Release.ps1 Azure.Core -ReleaseDate 2020-10-01 +.\eng\scripts\Prepare-Release.ps1 -PackageName "Azure.Core" -SerivceDirectory "core" -ReleaseDate "2020-10-01" ``` ## On-boarding New Libraries From d5443ba50aeff402a486a6c88bf09fa418c55177 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Thu, 4 Feb 2021 12:32:59 -0800 Subject: [PATCH 2/2] Remove eng/scripts/Prepare-Release.ps1 --- eng/scripts/Prepare-Release.ps1 | 295 -------------------------------- 1 file changed, 295 deletions(-) delete mode 100644 eng/scripts/Prepare-Release.ps1 diff --git a/eng/scripts/Prepare-Release.ps1 b/eng/scripts/Prepare-Release.ps1 deleted file mode 100644 index 868153f87eb58..0000000000000 --- a/eng/scripts/Prepare-Release.ps1 +++ /dev/null @@ -1,295 +0,0 @@ -#Requires -Version 6.0 - -[CmdletBinding()] -param( - [Parameter(Mandatory=$true)] - [string]$package, - [string]$ReleaseDate -) - -function Get-LevenshteinDistance { - <# - .SYNOPSIS - Get the Levenshtein distance between two strings. - .DESCRIPTION - The Levenshtein Distance is a way of quantifying how dissimilar two strings (e.g., words) are to one another by counting the minimum number of operations required to transform one string into the other. - .EXAMPLE - Get-LevenshteinDistance 'kitten' 'sitting' - .LINK - http://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance#C.23 - http://en.wikipedia.org/wiki/Edit_distance - https://communary.wordpress.com/ - https://github.com/gravejester/Communary.PASM - .NOTES - Author: Øyvind Kallstad - Date: 07.11.2014 - Version: 1.0 - #> - [CmdletBinding()] - param( - [Parameter(Position = 0)] - [string]$String1, - - [Parameter(Position = 1)] - [string]$String2, - - # Makes matches case-sensitive. By default, matches are not case-sensitive. - [Parameter()] - [switch] $CaseSensitive, - - # A normalized output will fall in the range 0 (perfect match) to 1 (no match). - [Parameter()] - [switch] $NormalizeOutput - ) - - if (-not($CaseSensitive)) { - $String1 = $String1.ToLowerInvariant() - $String2 = $String2.ToLowerInvariant() - } - - $d = New-Object 'Int[,]' ($String1.Length + 1), ($String2.Length + 1) - for ($i = 0; $i -le $d.GetUpperBound(0); $i++) { - $d[$i,0] = $i - } - - for ($i = 0; $i -le $d.GetUpperBound(1); $i++) { - $d[0,$i] = $i - } - - for ($i = 1; $i -le $d.GetUpperBound(0); $i++) { - for ($j = 1; $j -le $d.GetUpperBound(1); $j++) { - $cost = [Convert]::ToInt32((-not($String1[$i-1] -ceq $String2[$j-1]))) - $min1 = $d[($i-1),$j] + 1 - $min2 = $d[$i,($j-1)] + 1 - $min3 = $d[($i-1),($j-1)] + $cost - $d[$i,$j] = [Math]::Min([Math]::Min($min1,$min2),$min3) - } - } - - $distance = ($d[$d.GetUpperBound(0),$d.GetUpperBound(1)]) - - if ($NormalizeOutput) { - return (1 - ($distance) / ([Math]::Max($String1.Length,$String2.Length))) - } - - else { - return $distance - } -} - -function Get-ReleaseDay($baseDate) -{ - # Find first friday - while ($baseDate.DayOfWeek -ne 5) - { - $baseDate = $baseDate.AddDays(1) - } - - # Go to Tuesday - $baseDate = $baseDate.AddDays(4) - - return $baseDate; -} - -$ErrorPreference = 'Stop' -$repoRoot = Resolve-Path "$PSScriptRoot/../.."; -$commonParameter = @("--organization", "https://dev.azure.com/azure-sdk", "-o", "json", "--only-show-errors") - -if (!(Get-Command az)) { - throw 'You must have the Azure CLI installed: https://aka.ms/azure-cli' -} - -az extension show -n azure-devops > $null - -if (!$?){ - throw 'You must have the azure-devops extension run `az extension add --name azure-devops`' -} - -. ${repoRoot}\eng\common\scripts\SemVer.ps1 -. ${repoRoot}\eng\common\scripts\ChangeLog-Operations.ps1 - -$packageDirectory = Get-ChildItem "$repoRoot/sdk" -Directory -Recurse -Depth 2 -Filter $package -$serviceDirectory = $packageDirectory.Parent.Name - -Write-Host "Source directory $serviceDirectory" - -try -{ - $existing = Invoke-WebRequest "https://api.nuget.org/v3-flatcontainer/$($package.ToLower())/index.json" | ConvertFrom-Json; -} -catch -{ - $existing = @() -} - - -if (!$ReleaseDate) -{ - $currentDate = Get-Date - $thisMonthReleaseDate = Get-ReleaseDay((Get-Date -Day 1)); - $nextMonthReleaseDate = Get-ReleaseDay((Get-Date -Day 1).AddMonths(1)); - - if ($thisMonthReleaseDate -ge $currentDate) - { - # On track for this month release - $ParsedReleaseDate = $thisMonthReleaseDate - } - elseif ($currentDate.Day -lt 15) - { - # Catching up to this month release - $ParsedReleaseDate = $currentDate - } - else - { - # Next month release - $ParsedReleaseDate = $nextMonthReleaseDate - } -} -else -{ - $ParsedReleaseDate = [datetime]::ParseExact($ReleaseDate, 'yyyy-MM-dd', [Globalization.CultureInfo]::InvariantCulture) -} - -$releaseDateString = $ParsedReleaseDate.ToString("yyyy-MM-dd") -$month = $ParsedReleaseDate.ToString("MMMM") - -Write-Host -Write-Host "Assuming release is in $month with release date $releaseDateString" -ForegroundColor Green - -$isNew = "True"; -$libraryType = "Beta"; -$latestVersion = $null; -foreach ($existingVersion in $existing.versions) -{ - $isNew = "False" - $parsedVersion = [AzureEngSemanticVersion]::new($existingVersion) - if (!$parsedVersion.IsPrerelease) - { - $libraryType = "GA" - } - - $latestVersion = $existingVersion; -} - -$currentProjectVersion = ([xml](Get-Content "$packageDirectory/src/*.csproj")).Project.PropertyGroup.Version -$currentProjectVersion = "$currentProjectVersion".Trim() - -if ($latestVersion) -{ - Write-Host - Write-Host "Latest released version $latestVersion, library type $libraryType" -ForegroundColor Green -} -else -{ - Write-Host - Write-Host "No released version, library type $libraryType" -ForegroundColor Green -} - -$newVersion = Read-Host -Prompt "Input the new version, NA if you are not releasing, or press Enter to use use current project version '$currentProjectVersion'" -$releasing = $true - -if (!$newVersion) -{ - $newVersion = $currentProjectVersion; -} - -if ($newVersion -eq "NA") -{ - $releasing = $false -} - -if ($releasing) -{ - if ($latestVersion) - { - $releaseType = "None"; - $parsedNewVersion = [AzureEngSemanticVersion]::new($newVersion) - if ($parsedNewVersion.Major -ne $parsedVersion.Major) - { - $releaseType = "Major" - } - elseif ($parsedNewVersion.Minor -ne $parsedVersion.Minor) - { - $releaseType = "Minor" - } - elseif ($parsedNewVersion.Patch -ne $parsedVersion.Patch) - { - $releaseType = "Patch" - } - elseif ($parsedNewVersion.IsPrerelease) - { - $releaseType = "Patch" - } - } - else - { - $releaseType = "Major"; - } - - Write-Host - Write-Host "Detected released type $releaseType" -ForegroundColor Green - - Write-Host - Write-Host "Updating versions to $newVersion with date $releaseDateString" -ForegroundColor Green - - & "$repoRoot\eng\scripts\Update-PkgVersion.ps1" -ServiceDirectory $serviceDirectory -PackageName $package -NewVersionString $newVersion -ReleaseDate $releaseDateString - - $fields = @{ - "Permalink usetag"="https://github.com/Azure/azure-sdk-for-net/sdk/$serviceDirectory/$package/README.md" - "Package Registry Permalink"="https://nuget.org/packages/$package/$newVersion" - "Library Type"=$libraryType - "Release Type"=$releaseType - "Version Number"=$newVersion - "Planned Release Date"=$releaseDateString - "New Library Only"=$isNew - } - $state = "Active" -} -else -{ - $fields = @{} - $state = "Not In Release" -} - -$workItems = az boards query @commonParameter --project Release --wiql "SELECT [ID], [State], [Iteration Path], [Title] FROM WorkItems WHERE [State] <> 'Closed' AND [Iteration Path] under 'Release\2020\$month' AND [Title] contains '.NET'" | ConvertFrom-Json; - -Write-Host -Write-Host "The following work items exist:" -foreach ($item in $workItems) -{ - $id = $item.fields."System.ID"; - $title = $item.fields."System.Title"; - $path = $item.fields."System.IterationPath"; - Write-Host "$id - $path - $title" -} - -# Sort using fuzzy match -$workItems = $workItems | Sort-Object -property @{Expression = { Get-LevenshteinDistance $_.fields."System.Title" $package -NormalizeOutput }} -$mostProbable = $workItems | Select-Object -Last 1 - -$issueId = Read-Host -Prompt "Input the work item ID or press Enter to use '$($mostProbable.fields."System.ID") - $($mostProbable.fields."System.Title")' (fuzzy matched based on title)" - -if (!$issueId) -{ - $issueId = $mostProbable.fields."System.ID" -} - -Write-Host -Write-Host "Going to set the following fields:" -ForegroundColor Green -Write-Host " State = $state" - -foreach ($field in $fields.Keys) -{ - Write-Host " $field = $($fields[$field])" -} - -$decision = $Host.UI.PromptForChoice("Updating work item https://dev.azure.com/azure-sdk/Release/_workitems/edit/$issueId", 'Are you sure you want to proceed?', @('&Yes'; '&No'), 0) - -if ($decision -eq 0) -{ - az boards work-item update @commonParameter --id $issueId --state $state > $null - foreach ($field in $fields.Keys) - { - az boards work-item update @commonParameter --id $issueId -f "$field=$($fields[$field])" > $null - } -}