azure-sdk-for-cpp/eng/common/scripts/Collect-ChangeLogs.ps1
Azure SDK Bot 6a8aff701c
Fix bug in Changelog URL path using packageDirectoryName (#1878)
Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com>
2021-03-11 16:50:56 -08:00

61 lines
2.0 KiB
PowerShell

[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[DateTime] $FromDate
)
. (Join-Path $PSScriptRoot common.ps1)
$releaseHighlights = @{}
if ($FromDate -as [DateTime])
{
$date = ([DateTime]$FromDate).ToString($CHANGELOG_DATE_FORMAT)
}
else {
LogWarning "Invalid date passed. Switch to using the current date"
$date = Get-Date -Format $CHANGELOG_DATE_FORMAT
}
$allPackageProps = Get-AllPkgProperties
foreach ($packageProp in $allPackageProps) {
$changeLogLocation = $packageProp.ChangeLogPath
if (!(Test-Path $changeLogLocation))
{
continue
}
$changeLogEntries = Get-ChangeLogEntries -ChangeLogLocation $changeLogLocation
$packageName = $packageProp.Name
$serviceDirectory = $packageProp.ServiceDirectory
$packageDirectoryname = Split-Path -Path $packageProp.DirectoryPath -Leaf
foreach ($changeLogEntry in $changeLogEntries.Values) {
if ([System.String]::IsNullOrEmpty($changeLogEntry.ReleaseStatus))
{
continue;
}
$ReleaseStatus = $changeLogEntry.ReleaseStatus.Trim("(",")")
if (!($ReleaseStatus -as [DateTime]) -or $ReleaseStatus -lt $date)
{
continue;
}
$releaseVersion = $changeLogEntry.ReleaseVersion
$githubAnchor = $changeLogEntry.ReleaseTitle.Replace("## ", "").Replace(".", "").Replace("(", "").Replace(")", "").Replace(" ", "-")
$releaseTag = "${packageName}_${releaseVersion}"
$key = "${packageName}:${releaseVersion}"
$releaseHighlights[$key] = @{}
$releaseHighlights[$key]["PackageProperties"] = $packageProp
$releaseHighlights[$key]["ChangelogUrl"] = "https://github.com/Azure/azure-sdk-for-${LanguageShort}/blob/${releaseTag}/sdk/${serviceDirectory}/${packageDirectoryname}/CHANGELOG.md#${githubAnchor}"
$releaseHighlights[$key]["Content"] = @()
$changeLogEntry.ReleaseContent | %{
$releaseHighlights[$key]["Content"] += $_.Replace("###", "####")
}
}
}
return $releaseHighlights