Skip to content

Commit 4e36bec

Browse files
Copilotscbedd
andauthored
Fix scoped builds: check BuildTargetingString glob match instead of directory existence
When BuildTargetingString is set, split it by comma and test each artifact name against the glob patterns using PowerShell -like before attempting to publish. Non-matching packages are skipped with a clear log message. Closes #42014 Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-python/sessions/88e37a34-ffce-4971-91c0-223321039c44 Co-authored-by: scbedd <45376673+scbedd@users.noreply.github.com>
1 parent 2348e21 commit 4e36bec

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

eng/pipelines/templates/stages/archetype-python-release.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -387,25 +387,29 @@ stages:
387387
- ${{if ne(artifact.skipPublishDevFeed, 'true')}}:
388388

389389
- pwsh: |
390-
$artifactDir = "$(Pipeline.Workspace)/${{parameters.ArtifactName}}/${{artifact.name}}"
391-
392-
# When a build is scoped via BuildTargetingString, only targeted packages have
393-
# artifact directories. Skip gracefully if this package was not part of the build.
394-
if (-not (Test-Path $artifactDir)) {
395-
Write-Host "Artifact directory for ${{artifact.name}} not found at '$artifactDir'. Package was not targeted by the current build scope, skipping publish."
396-
exit 0
390+
# If BuildTargetingString is set, check whether this artifact matches any of the
391+
# (possibly comma-separated) glob patterns before attempting to publish.
392+
# This handles scoped builds where only a subset of packages are built.
393+
$targetingString = $env:BUILDTARGETINGSTRING
394+
if ($targetingString) {
395+
$globs = $targetingString -split ","
396+
$isTargeted = $globs | Where-Object { "${{artifact.name}}" -like $_.Trim() }
397+
if (-not $isTargeted) {
398+
Write-Host "Package '${{artifact.name}}' does not match BuildTargetingString '$targetingString'. Skipping integration publish."
399+
exit 0
400+
}
397401
}
398402
399-
$fileCount = (Get-ChildItem $artifactDir | ? {$_.Name -match "-[0-9]*.[0-9]*.[0-9]*a[0-9]*" } | Measure-Object).Count
403+
$fileCount = (Get-ChildItem $(Pipeline.Workspace)/${{parameters.ArtifactName}}/${{artifact.name}} | ? {$_.Name -match "-[0-9]*.[0-9]*.[0-9]*a[0-9]*" } | Measure-Object).Count
400404
401405
if ($fileCount -eq 0) {
402406
Write-Host "No alpha packages for ${{artifact.name}} to publish."
403407
exit 0
404408
}
405409
406-
twine upload --repository $(DevFeedName) --config-file $(PYPIRC_PATH) $artifactDir/*-*a*.whl
410+
twine upload --repository $(DevFeedName) --config-file $(PYPIRC_PATH) $(Pipeline.Workspace)/${{parameters.ArtifactName}}/${{artifact.name}}/*-*a*.whl
407411
echo "Uploaded whl to devops feed $(DevFeedName)"
408-
twine upload --repository $(DevFeedName) --config-file $(PYPIRC_PATH) $artifactDir/*-*a*.tar.gz
412+
twine upload --repository $(DevFeedName) --config-file $(PYPIRC_PATH) $(Pipeline.Workspace)/${{parameters.ArtifactName}}/${{artifact.name}}/*-*a*.tar.gz
409413
echo "Uploaded sdist to devops feed $(DevFeedName)"
410414
displayName: 'Publish ${{artifact.name}} alpha package'
411415

0 commit comments

Comments
 (0)