diff --git a/eng/common/scripts/AutoRelease-Operations.ps1 b/eng/common/scripts/AutoRelease-Operations.ps1 index 511ed0241219..7fe90013690d 100644 --- a/eng/common/scripts/AutoRelease-Operations.ps1 +++ b/eng/common/scripts/AutoRelease-Operations.ps1 @@ -87,6 +87,8 @@ function Get-GitHubAutoReleasePullRequestForCommit { # PullRequestNumber : the PR number recorded in the diff object. # PullRequestFiles : the file entries returned by Get-GitHubPullRequestFiles. # ExcludePaths : optional paths to record on the diff object. +# ExcludeServiceRootFiles : excludes files directly under sdk/ so they do not resolve every +# package in that service. # # Returns a PSCustomObject with ChangedFiles, ChangedServices, ExcludePaths, DeletedFiles, PRNumber. function New-GitHubPullRequestDiffObject { @@ -97,7 +99,8 @@ function New-GitHubPullRequestDiffObject { [AllowEmptyCollection()] [array] $PullRequestFiles, [AllowEmptyCollection()] - [array] $ExcludePaths = @() + [array] $ExcludePaths = @(), + [switch] $ExcludeServiceRootFiles ) $changedFiles = @() @@ -119,6 +122,12 @@ function New-GitHubPullRequestDiffObject { } } + if ($ExcludeServiceRootFiles) { + $serviceRootFilePattern = '^sdk/[^/]+/[^/]+$' + $changedFiles = @($changedFiles | Where-Object { $_ -notmatch $serviceRootFilePattern }) + $deletedFiles = @($deletedFiles | Where-Object { $_ -notmatch $serviceRootFilePattern }) + } + $changedFiles = @($changedFiles | Where-Object { $_ } | Sort-Object -Unique) $deletedFiles = @($deletedFiles | Where-Object { $_ } | Sort-Object -Unique) diff --git a/eng/common/scripts/Resolve-AutoReleasePackages.ps1 b/eng/common/scripts/Resolve-AutoReleasePackages.ps1 index 2be70bcd53a4..06cd79a43519 100644 --- a/eng/common/scripts/Resolve-AutoReleasePackages.ps1 +++ b/eng/common/scripts/Resolve-AutoReleasePackages.ps1 @@ -10,8 +10,9 @@ commit, this script: 'auto-release' label. 2. Builds a PR diff object (New-GitHubPullRequestDiffObject) from the PR's changed files and reuses the repo's existing package-detection logic (Get-PrPkgProperties) to identify the changed packages - (honoring triggering paths, deleted files and service-level changes), excluding - validation-only packages. Get-PrPkgProperties delegates to each repo's own + (honoring triggering paths and deleted files while ignoring only files directly under + sdk//, not files in package subdirectories), excluding validation-only packages. + Get-PrPkgProperties delegates to each repo's own Get-AllPackageInfoFromRepo (language-settings.ps1), so this script works for any language repo. 3. Intersects those packages with this pipeline's declared artifacts and emits Azure DevOps output variables consumed by the release stages. Both consumption styles are emitted: @@ -135,7 +136,10 @@ function Invoke-AutoReleaseResolution { # package-detection logic to identify the changed packages. Write-Host "Fetching changed files for PR $prLink..." $files = @(Get-GitHubPullRequestFiles -RepoId $RepoId -PullRequestNumber $pr.number -AuthToken $AuthToken) - $diff = New-GitHubPullRequestDiffObject -PullRequestNumber $pr.number -PullRequestFiles $files + $diff = New-GitHubPullRequestDiffObject ` + -PullRequestNumber $pr.number ` + -PullRequestFiles $files ` + -ExcludeServiceRootFiles Write-Host "PR $prLink changed $($diff.ChangedFiles.Count) file(s) and deleted $($diff.DeletedFiles.Count) file(s)." $diffPath = Join-Path ([System.IO.Path]::GetTempPath()) ("autorelease-diff-" + [System.Guid]::NewGuid().ToString('N') + ".json")