diff --git a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml new file mode 100644 index 000000000000..2e10f695c998 --- /dev/null +++ b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml @@ -0,0 +1,12 @@ +# This script fragment is used across our repos to set a variable "SetDevVersion" which +# is used when this pipeline is going to be generating and publishing daily dev builds. + +steps: +- pwsh: | + $setDailyDevBuild = "false" + if (('$(Build.Reason)' -eq 'Schedule') -and ('$(System.TeamProject)' -eq 'internal')) { + $setDailyDevBuild = "true" + } + echo "##vso[task.setvariable variable=SetDevVersion]$setDailyDevBuild" + displayName: "Setup Versioning Properties" + condition: eq(variables['SetDevVersion'], '') diff --git a/eng/common/scripts/Verify-ChangeLog.ps1 b/eng/common/scripts/Verify-ChangeLog.ps1 index 7a821a1d54b0..c9ad4d295644 100644 --- a/eng/common/scripts/Verify-ChangeLog.ps1 +++ b/eng/common/scripts/Verify-ChangeLog.ps1 @@ -15,18 +15,25 @@ $ProgressPreference = "SilentlyContinue" . (Join-Path $PSScriptRoot SemVer.ps1) Import-Module (Join-Path $PSScriptRoot modules ChangeLog-Operations.psm1) -if ((Test-Path $ChangeLogLocation) -and -not([System.String]::IsNullOrEmpty($VersionString))) +$validChangeLog = $false +if ($ChangeLogLocation -and $VersionString) { - Confirm-ChangeLogEntry -ChangeLogLocation $ChangeLogLocation -VersionString $VersionString -ForRelease $ForRelease + $validChangeLog = 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) - } + 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-ChangeLogEntry -ChangeLogLocation $PackageProp.pkgChangeLogPath -VersionString $PackageProp.pkgVersion -ForRelease $ForRelease -} \ No newline at end of file + $PackageProp = Get-PkgProperties -PackageName $PackageName -ServiceName $ServiceName -Language $Language -RepoRoot $RepoRoot + $validChangeLog = Confirm-ChangeLogEntry -ChangeLogLocation $PackageProp.pkgChangeLogPath -VersionString $PackageProp.pkgVersion -ForRelease $ForRelease +} + +if (!$validChangeLog) { + exit 1 +} + +exit 0 \ 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 e92070b195b3..5aed584d018b 100644 --- a/eng/common/scripts/modules/ChangeLog-Operations.psm1 +++ b/eng/common/scripts/modules/ChangeLog-Operations.psm1 @@ -11,8 +11,8 @@ function Get-ChangeLogEntries { $changeLogEntries = @{} if (!(Test-Path $ChangeLogLocation)) { - Write-Host "ChangeLog '{0}' was not found" -f $ChangeLogLocation - exit 1 + Write-Error "ChangeLog[${ChangeLogLocation}] does not exist" + return $null } try { @@ -51,14 +51,12 @@ function Get-ChangeLogEntry { [Parameter(Mandatory = $true)] [String]$VersionString ) - $changeLogEntries = Get-ChangeLogEntries -ChangeLogLocation $ChangeLogLocation - if ($changeLogEntries.ContainsKey($VersionString)) { + if ($changeLogEntries -and $changeLogEntries.ContainsKey($VersionString)) { return $changeLogEntries[$VersionString] } - Write-Error "Release Notes for the Specified version ${VersionString} was not found" - exit 1 + return $null } #Returns the changelog for a particular version as string @@ -70,9 +68,16 @@ function Get-ChangeLogEntryAsString { [String]$VersionString ) - $changeLogEntries = Get-ChangeLogEntry -ChangeLogLocation $ChangeLogLocation -VersionString $VersionString - [string]$releaseTitle = $changeLogEntries.ReleaseTitle - [string]$releaseContent = $changeLogEntries.ReleaseContent -Join [Environment]::NewLine + $changeLogEntry = Get-ChangeLogEntry -ChangeLogLocation $ChangeLogLocation -VersionString $VersionString + return ChangeLogEntryAsString $changeLogEntry +} + +function ChangeLogEntryAsString($changeLogEntry) { + if (!$changeLogEntry) { + return "[Missing change log entry]" + } + [string]$releaseTitle = $changeLogEntry.ReleaseTitle + [string]$releaseContent = $changeLogEntry.ReleaseContent -Join [Environment]::NewLine return $releaseTitle, $releaseContent -Join [Environment]::NewLine } @@ -87,27 +92,33 @@ function Confirm-ChangeLogEntry { $changeLogEntry = Get-ChangeLogEntry -ChangeLogLocation $ChangeLogLocation -VersionString $VersionString + if (!$changeLogEntry) { + Write-Error "ChangeLog[${ChangeLogLocation}] does not have an entry for version ${VersionString}." + return $false + } + + Write-Host "Found the following change log entry for version '${VersionString}' in [${ChangeLogLocation}]." + Write-Host "-----" + Write-Host (ChangeLogEntryAsString $changeLogEntry) + Write-Host "-----" + 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 + Write-Error "Entry does not have a correct release status. Please ensure the status is set to a date '(yyyy-MM-dd)' or '(Unreleased)' if not yet released." + return $false } if ($ForRelease -eq $True) { if ($changeLogEntry.ReleaseStatus -eq "(Unreleased)") { - Write-Host ("##[error]No release date set. Please set a release date with format 'yyyy-MM-dd' in the heading for version '{0}' in the changelog '{1}'." -f $VersionString, $ChangelogLocation) - exit 1 + Write-Error "Entry has no release date set. Please ensure to set a release date with format 'yyyy-MM-dd'." + return $false } 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-Error "Entry has no content. Please ensure to provide some content of what changed in this version." + return $false } } - - Write-Host $changeLogEntry.ReleaseTitle - Write-Host $changeLogEntry.ReleaseContent + return $true } Export-ModuleMember -Function 'Get-ChangeLogEntries' diff --git a/eng/common/scripts/modules/Package-Properties.psm1 b/eng/common/scripts/modules/Package-Properties.psm1 index 01865594f6cf..fa6920bec349 100644 --- a/eng/common/scripts/modules/Package-Properties.psm1 +++ b/eng/common/scripts/modules/Package-Properties.psm1 @@ -3,13 +3,24 @@ class PackageProps { [string]$pkgName - [AzureEngSemanticVersion]$pkgVersion + [string]$pkgVersion [string]$pkgDirectoryPath [string]$pkgServiceName [string]$pkgReadMePath [string]$pkgChangeLogPath + [string]$pkgGroup - PackageProps( + PackageProps([string]$pkgName,[string]$pkgVersion,[string]$pkgDirectoryPath,[string]$pkgServiceName) + { + $this.Initialize($pkgName, $pkgVersion, $pkgDirectoryPath, $pkgServiceName) + } + + PackageProps([string]$pkgName,[string]$pkgVersion,[string]$pkgDirectoryPath,[string]$pkgServiceName,[string]$pkgGroup="") + { + $this.Initialize($pkgName, $pkgVersion, $pkgDirectoryPath, $pkgServiceName, $pkgGroup) + } + + hidden [void]Initialize( [string]$pkgName, [string]$pkgVersion, [string]$pkgDirectoryPath, @@ -17,11 +28,7 @@ class PackageProps ) { $this.pkgName = $pkgName - $this.pkgVersion = [AzureEngSemanticVersion]::ParseVersionString($pkgVersion) - if ($this.pkgVersion -eq $null) - { - Write-Error "Invalid version in $pkgDirectoryPath" - } + $this.pkgVersion = $pkgVersion $this.pkgDirectoryPath = $pkgDirectoryPath $this.pkgServiceName = $pkgServiceName @@ -43,6 +50,18 @@ class PackageProps $this.pkgChangeLogPath = $null } } + + hidden [void]Initialize( + [string]$pkgName, + [string]$pkgVersion, + [string]$pkgDirectoryPath, + [string]$pkgServiceName, + [string]$pkgGroup + ) + { + $this.Initialize($pkgName, $pkgVersion, $pkgDirectoryPath, $pkgServiceName) + $this.pkgGroup = $pkgGroup + } } $ProgressPreference = "SilentlyContinue" @@ -127,10 +146,11 @@ function Extract-JavaPkgProps ($pkgPath, $serviceName, $pkgName) $projectData.load($projectPath) $projectPkgName = $projectData.project.artifactId $pkgVersion = $projectData.project.version + $pkgGroup = $projectData.project.groupId if ($projectPkgName -eq $pkgName) { - return [PackageProps]::new($pkgName, $pkgVersion.ToString(), $pkgPath, $serviceName) + return [PackageProps]::new($pkgName, $pkgVersion.ToString(), $pkgPath, $serviceName, $pkgGroup) } } return $null