diff --git a/eng/scripts/Prepare-Release.ps1 b/eng/scripts/Prepare-Release.ps1 index 25e54c35dd490..29682e0d09432 100644 --- a/eng/scripts/Prepare-Release.ps1 +++ b/eng/scripts/Prepare-Release.ps1 @@ -81,6 +81,12 @@ 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 @@ -89,10 +95,17 @@ $serviceDirectory = $packageDirectory.Parent.Name Write-Host "Source directory $serviceDirectory" -$existing = Invoke-WebRequest "https://api.nuget.org/v3-flatcontainer/$($package.ToLower())/index.json" | ConvertFrom-Json; +try +{ + $existing = Invoke-WebRequest "https://api.nuget.org/v3-flatcontainer/$($package.ToLower())/index.json" | ConvertFrom-Json; +} +catch +{ + $existing = @() +} $libraryType = "Preview"; -$latestVersion = "unknown"; +$latestVersion = $null; foreach ($existingVersion in $existing.versions) { $parsedVersion = [AzureEngSemanticVersion]::new($existingVersion) @@ -106,8 +119,16 @@ foreach ($existingVersion in $existing.versions) $currentProjectVersion = ([xml](Get-Content "$packageDirectory/src/*.csproj")).Project.PropertyGroup.Version -Write-Host -Write-Host "Latest released version $latestVersion, library type $libraryType" -ForegroundColor Green +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 or press Enter to use use current project version '$currentProjectVersion'" @@ -116,23 +137,30 @@ if (!$newVersion) $newVersion = $currentProjectVersion; } -$releaseType = "None"; -$parsedNewVersion = [AzureEngSemanticVersion]::new($newVersion) -if ($parsedNewVersion.Major -ne $parsedVersion.Major) +if ($latestVersion) { - $releaseType = "Major" -} -elseif ($parsedNewVersion.Minor -ne $parsedVersion.Minor) -{ - $releaseType = "Minor" -} -elseif ($parsedNewVersion.Patch -ne $parsedVersion.Patch) -{ - $releaseType = "Bugfix" + $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 = "Bugfix" + } + elseif ($parsedNewVersion.IsPrerelease) + { + $releaseType = "Bugfix" + } } -elseif ($parsedNewVersion.IsPrerelease) +else { - $releaseType = "Bugfix" + $releaseType = "Major"; } Write-Host @@ -170,7 +198,7 @@ foreach ($item in $workItems) $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")'" +$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) {