Skip to content

Commit

Permalink
Release script fixes (#14686)
Browse files Browse the repository at this point in the history
  • Loading branch information
pakrym authored Aug 28, 2020
1 parent 39cf3fa commit 73ae481
Showing 1 changed file with 47 additions and 19 deletions.
66 changes: 47 additions & 19 deletions eng/scripts/Prepare-Release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand All @@ -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'"

Expand All @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 73ae481

Please sign in to comment.