diff --git a/eng/common/Extract-ReleaseNotes.ps1 b/eng/common/Extract-ReleaseNotes.ps1 deleted file mode 100644 index 6fff6a11d..000000000 --- a/eng/common/Extract-ReleaseNotes.ps1 +++ /dev/null @@ -1,65 +0,0 @@ -# given a CHANGELOG.md file, extract the relevant info we need to decorate a release -param ( - [Parameter(Mandatory = $true)] - [String]$ChangeLogLocation, - [String]$VersionString -) - -$ErrorActionPreference = 'Stop' - -$RELEASE_TITLE_REGEX = "(?^\#+.*(?\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 -} - -if ([System.String]::IsNullOrEmpty($VersionString)) -{ - return $releaseNotes -} -else -{ - if ($releaseNotes.ContainsKey($VersionString)) - { - $releaseNotesForVersion = $releaseNotes[$VersionString].ReleaseContent - $processedNotes = $releaseNotesForVersion -Split [Environment]::NewLine | where { $_ -notmatch $RELEASE_TITLE_REGEX } - return $processedNotes -Join [Environment]::NewLine - } - Write-Error "Release Notes for the Specified version ${VersionString} was not found" - exit 1 -} - diff --git a/eng/common/pipelines/templates/steps/verify-changelog.yml b/eng/common/pipelines/templates/steps/verify-changelog.yml index f90238471..f6005124a 100644 --- a/eng/common/pipelines/templates/steps/verify-changelog.yml +++ b/eng/common/pipelines/templates/steps/verify-changelog.yml @@ -12,14 +12,14 @@ parameters: steps: - task: Powershell@2 inputs: - filePath: /eng/common/scripts/Verify-ChangeLog.ps1 + filePath: $(Build.SourcesDirectory)/eng/common/scripts/Verify-ChangeLog.ps1 arguments: > -PackageName ${{ parameters.PackageName }} -ServiceName ${{ parameters.ServiceName }} -RepoRoot $(Build.SourcesDirectory) -RepoName $(Build.Repository.Name) - -ForRelease ${{ parameters.ForRelease }} + -ForRelease $${{ parameters.ForRelease }} pwsh: true workingDirectory: $(Pipeline.Workspace) - displayName: Verify ChangeLog / Release Notes + displayName: Verify ChangeLogEntry for ${{ parameters.PackageName }} continueOnError: false \ No newline at end of file diff --git a/eng/common/scripts/Verify-ChangeLog.ps1 b/eng/common/scripts/Verify-ChangeLog.ps1 index 1f9991bfd..816a82f5b 100644 --- a/eng/common/scripts/Verify-ChangeLog.ps1 +++ b/eng/common/scripts/Verify-ChangeLog.ps1 @@ -1,8 +1,8 @@ # Wrapper Script for ChangeLog Verification param ( - [Parameter(Mandatory=$true)] + [String]$ChangeLogLocation, + [String]$VersionString, [string]$PackageName, - [Parameter(Mandatory=$true)] [string]$ServiceName, [string]$RepoRoot, [ValidateSet("net","java","js","python")] @@ -11,12 +11,21 @@ param ( [boolean]$ForRelease=$False ) -Import-Module "${PSScriptRoot}/modules/common-manifest.psd1" +. (Join-Path $PSScriptRoot SemVer.ps1) +Import-Module (Join-Path $PSScriptRoot modules ChangeLog-Operations.psm1) -if ([System.String]::IsNullOrEmpty($Language)) +if ((Test-Path $ChangeLogLocation) -and -not([System.String]::IsNullOrEmpty($VersionString))) { - $Language = $RepoName.Substring($RepoName.LastIndexOf('-') + 1) + Confirm-ChangeLogEntry -ChangeLogLocation $ChangeLogLocation -VersionString $VersionString -ForRelease $ForRelease } +else +{ + Import-Module (Join-Path $PSScriptRoot modules Package-Properties.psm1) + if ([System.String]::IsNullOrEmpty($Language)) + { + $Language = $RepoName.Substring($RepoName.LastIndexOf('-') + 1) + } -$PackageProp = Get-PkgProperties -PackageName $PackageName -ServiceName $ServiceName -Language $Language -RepoRoot $RepoRoot -Confirm-ChangeLog -ChangeLogLocation $PackageProp.pkgChangeLogPath -VersionString $PackageProp.pkgReadMePath -ForRelease $ForRelease \ No newline at end of file + $PackageProp = Get-PkgProperties -PackageName $PackageName -ServiceName $ServiceName -Language $Language -RepoRoot $RepoRoot + Confirm-ChangeLogEntry -ChangeLogLocation $PackageProp.pkgChangeLogPath -VersionString $PackageProp.pkgVersion -ForRelease $ForRelease +} \ No newline at end of file diff --git a/eng/common/scripts/modules/ChangeLog-Operations.psm1 b/eng/common/scripts/modules/ChangeLog-Operations.psm1 index 527966841..5c1738761 100644 --- a/eng/common/scripts/modules/ChangeLog-Operations.psm1 +++ b/eng/common/scripts/modules/ChangeLog-Operations.psm1 @@ -85,9 +85,9 @@ function Confirm-ChangeLogEntry { [boolean]$ForRelease = $false ) - $changeLogEntries = Get-ChangeLogEntry -ChangeLogLocation $ChangeLogLocation -VersionString $VersionString + $changeLogEntry = Get-ChangeLogEntry -ChangeLogLocation $ChangeLogLocation -VersionString $VersionString - if ([System.String]::IsNullOrEmpty($changeLogEntries.ReleaseStatus)) { + if ([System.String]::IsNullOrEmpty($changeLogEntry.ReleaseStatus)) { Write-Host ("##[error]Changelog '{0}' has wrong release note title" -f $ChangeLogLocation) Write-Host "##[info]Ensure the release date is included i.e. (yyyy-MM-dd) or (Unreleased) if not yet released" exit 1 @@ -95,19 +95,20 @@ function Confirm-ChangeLogEntry { if ($ForRelease -eq $True) { $CurrentDate = Get-Date -Format "yyyy-MM-dd" - if ($changeLogEntries.ReleaseStatus -ne "($CurrentDate)") { + if ($changeLogEntry.ReleaseStatus -ne "($CurrentDate)") { Write-Host ("##[warning]Incorrect Date: Please use the current date in the Changelog '{0}' before releasing the package" -f $ChangeLogLocation) exit 1 } - if ([System.String]::IsNullOrWhiteSpace($changeLogEntries.ReleaseContent)) { + if ([System.String]::IsNullOrWhiteSpace($changeLogEntry.ReleaseContent)) { Write-Host ("##[error]Empty Release Notes for '{0}' in '{1}'" -f $VersionString, $ChangeLogLocation) Write-Host "##[info]Please ensure there is a release notes entry before releasing the package." exit 1 } } - Write-Host ($changeLogEntries | Format-Table | Out-String) + Write-Host $changeLogEntry.ReleaseTitle + Write-Host $changeLogEntry.ReleaseContent } Export-ModuleMember -Function 'Get-ChangeLogEntries'