Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools repository (#7393)
Browse files Browse the repository at this point in the history
  • Loading branch information
azure-sdk authored Feb 21, 2020
1 parent 0aac01c commit 30b4503
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions eng/common/Extract-ReleaseNotes.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# given a CHANGELOG.md file, extract the relevant info we need to decorate a release
param (
[Parameter(Mandatory = $true)]
[String]$ChangeLogLocation
)

$RELEASE_TITLE_REGEX = "(?<releaseNoteTitle>^\#+.*(?<version>\b\d+\.\d+\.\d+([^0-9\s][^\s:]+)?))"

$releaseNotes = @{}
$contentArrays = @{}
if ($ChangeLogLocation.Length -eq 0)
{
return $releaseNotes
}

try
{
$contents = Get-Content $ChangeLogLocation

# walk the document, finding where the version specifiers are and creating lists
$version = ""
foreach($line in $contents){
if ($line -match $RELEASE_TITLE_REGEX)
{
$version = $matches["version"]
$contentArrays[$version] = @()
}

$contentArrays[$version] += $line
}

# resolve each of discovered version specifier string arrays into real content
foreach($key in $contentArrays.Keys)
{
$releaseNotes[$key] = New-Object PSObject -Property @{
ReleaseVersion = $key
ReleaseContent = $contentArrays[$key] -join [Environment]::NewLine
}
}
}
catch
{
Write-Host "Error parsing $ChangeLogLocation."
Write-Host $_.Exception.Message
}

return $releaseNotes

0 comments on commit 30b4503

Please sign in to comment.