From a469ff32b3fa741e43b48666bbcb8e30fe0a4407 Mon Sep 17 00:00:00 2001 From: Victoria Hall Date: Tue, 17 Nov 2026 10:19:04 -0600 Subject: [PATCH] Use shared engineering ESRP template for library releases --- eng/ci/library-release.yml | 9 +- .../official/release/publish-release.yml | 171 +++++++++--------- 2 files changed, 91 insertions(+), 89 deletions(-) diff --git a/eng/ci/library-release.yml b/eng/ci/library-release.yml index 28d0214..4da21f4 100644 --- a/eng/ci/library-release.yml +++ b/eng/ci/library-release.yml @@ -24,6 +24,13 @@ resources: type: git name: 1ESPipelineTemplates/1ESPipelineTemplates ref: refs/tags/release + - repository: eng + type: git + name: engineering + ref: refs/tags/release + +variables: + - group: azure-functions-python-release extends: template: v1/1ES.Official.PipelineTemplate.yml@1es @@ -87,7 +94,6 @@ extends: releaseBranchPrefix: 'release' pythonVersionRequirement: '>=3.10,<3.13' tagPrefix: '' - blobPath: 'azure-functions/python/azure-functions' artifactName: 'azure-functions' - stage: ReleaseV2_BumpVersion @@ -138,5 +144,4 @@ extends: releaseBranchPrefix: 'release' pythonVersionRequirement: '>=3.13' tagPrefix: '' - blobPath: 'azure-functions/python/azure-functions' artifactName: 'azure-functions' \ No newline at end of file diff --git a/eng/templates/official/release/publish-release.yml b/eng/templates/official/release/publish-release.yml index 178ca04..c3d977e 100644 --- a/eng/templates/official/release/publish-release.yml +++ b/eng/templates/official/release/publish-release.yml @@ -16,10 +16,6 @@ parameters: type: string default: '' displayName: 'Optional prefix for git tags' - - name: blobPath - type: string - default: 'azure-functions/python/azure-functions' - displayName: 'Blob path under drops container' - name: githubOrg type: string default: 'Azure' @@ -32,10 +28,15 @@ parameters: type: string default: 'azure-functions' displayName: 'Pipeline artifact name produced by the Build stage' - - name: partnerReleasePipelineUrl + - name: esrpOwners + type: string + default: '$(EsrpOwners)' + - name: esrpApprovers + type: string + default: '$(EsrpApprovers)' + - name: esrpManualApprovers type: string - default: 'https://dev.azure.com/azure-sdk/internal/_build?definitionId=6991' - displayName: 'Azure SDK partner-release pipeline URL (used in manual PyPI publish instructions)' + default: '$(EsrpManualApprovers)' jobs: - job: "CreateReleaseTag" @@ -272,97 +273,93 @@ jobs: 2. Merge the PR into the worker dev branch when ready. 3. If automatic PR creation failed, review the TestWithWorker logs and create or update the PR manually, or explicitly approve continuing the release with worker testing deferred. - - job: PublishRelease + - job: ESRPApproval dependsOn: ['WaitForPythonWorkerPR'] - displayName: 'Upload artifacts to partner blob for release' - + displayName: 'Approve PyPI release' + timeoutInMinutes: 1440 + pool: server + steps: + - task: ManualValidation@1 + inputs: + notifyUsers: '' + approvers: '${{ parameters.esrpManualApprovers }}' + allowApproversToApproveTheirOwnRuns: false + instructions: 'Approve publishing the Python package to PyPI through ESRP.' + + - job: ESRPRelease + dependsOn: ESRPApproval + displayName: 'Publish package to PyPI with ESRP' + templateContext: + type: releaseJob + isProduction: true + inputs: + - input: pipelineArtifact + artifactName: ${{ parameters.artifactName }} + targetPath: $(Pipeline.Workspace)/${{ parameters.artifactName }} pool: name: 1es-pool-azfunc image: 1es-ubuntu-22.04 os: linux - steps: - checkout: none + - pwsh: | + $ErrorActionPreference = 'Stop' + $distFolder = '$(Pipeline.Workspace)/${{ parameters.artifactName }}/dist' + $packageName = 'azure-functions' + $libraryVersion = '${{ parameters.libraryVersion }}' - - download: current - artifact: ${{ parameters.artifactName }} - displayName: 'Download build artifacts' + if (-not (Test-Path -LiteralPath $distFolder -PathType Container)) { + throw "Distribution folder not found: $distFolder" + } - - task: AzurePowerShell@5 - displayName: 'Upload files to partner drop folder' - inputs: - azureSubscription: 'azure-sdk-partner-drops' - ScriptType: 'InlineScript' - azurePowerShellVersion: LatestVersion - pwsh: true - Inline: | - $version = "${{ parameters.libraryVersion }}" - $blobPath = "${{ parameters.blobPath }}" - $distFolder = '$(Pipeline.Workspace)/${{ parameters.artifactName }}/dist' - - Write-Host "Uploading Python artifacts for version: $version" - Write-Host "Source folder: $distFolder" - Write-Host "Destination: https://azuresdkpartnerdrops.blob.core.windows.net/drops/$blobPath/$version/" - - Get-ChildItem -Path $distFolder -Recurse | ForEach-Object { - Write-Host " - $($_.Name)" - } - - azcopy copy "$distFolder/*" "https://azuresdkpartnerdrops.blob.core.windows.net/drops/$blobPath/$version/" - - $blobPathFull = "$blobPath/$version" - $partnerReleaseUrl = "${{ parameters.partnerReleasePipelineUrl }}" - - Write-Host "" - Write-Host "##[section]Upload complete. The partner-release pipeline will be triggered automatically in the next job." - Write-Host " BlobPath: $blobPathFull" - Write-Host " Partner pipeline: $partnerReleaseUrl" - env: - AZCOPY_AUTO_LOGIN_TYPE: 'PSCRED' + $wheels = @(Get-ChildItem -LiteralPath $distFolder -File -Filter '*.whl') + $sourceDistributions = @(Get-ChildItem -LiteralPath $distFolder -File -Filter '*.tar.gz') + $unsupportedFiles = @( + Get-ChildItem -LiteralPath $distFolder -File | + Where-Object { $_.Name -notlike '*.whl' -and $_.Name -notlike '*.tar.gz' } + ) - - job: "TriggerPartnerRelease" - dependsOn: ['PublishRelease'] - displayName: 'Trigger partner-release pipeline' + if ($wheels.Count -ne 1 -or $sourceDistributions.Count -ne 1) { + throw "Expected one wheel and one source distribution in $distFolder; found $($wheels.Count) wheel(s) and $($sourceDistributions.Count) source distribution(s)." + } + if ($unsupportedFiles.Count -ne 0) { + throw "Unexpected files found in the ESRP package folder: $($unsupportedFiles.Name -join ', ')" + } - pool: - name: 1es-pool-azfunc - image: 1es-ubuntu-22.04 - os: linux + Add-Type -AssemblyName System.IO.Compression.FileSystem + $archive = [System.IO.Compression.ZipFile]::OpenRead($wheels[0].FullName) + try { + $metadataEntry = $archive.Entries | + Where-Object { $_.FullName -like '*.dist-info/METADATA' } | + Select-Object -First 1 + if (-not $metadataEntry) { + throw "Wheel metadata was not found in $($wheels[0].Name)." + } - steps: - - checkout: none + $reader = [System.IO.StreamReader]::new($metadataEntry.Open()) + try { + $metadata = $reader.ReadToEnd() + } finally { + $reader.Dispose() + } + } finally { + $archive.Dispose() + } - - pwsh: | - Write-Host "Target folder: ${{ parameters.blobPath }}/${{ parameters.libraryVersion }}" - Write-Host "Storage container: https://ms.portal.azure.com/#blade/Microsoft_Azure_Storage/ContainerMenuBlade/overview/storageAccountId/%2Fsubscriptions%2Fa18897a6-7e44-457d-9260-f2854c0aca42%2FresourceGroups%2Fazuresdkpartnerdrops%2Fproviders%2FMicrosoft.Storage%2FstorageAccounts%2Fazuresdkpartnerdrops/path/drops" - Write-Host "Partner pipeline: ${{ parameters.partnerReleasePipelineUrl }}" - displayName: 'Log partner pipeline information' + $actualName = [regex]::Match($metadata, '(?m)^Name:\s*(.+)\r?$').Groups[1].Value.Trim() + $actualVersion = [regex]::Match($metadata, '(?m)^Version:\s*(.+)\r?$').Groups[1].Value.Trim() + if ($actualName -ne $packageName -or $actualVersion -ne $libraryVersion) { + throw "Artifact metadata mismatch. Expected $packageName $libraryVersion; found $actualName $actualVersion." + } - - task: AzureCLI@2 - displayName: 'Run partner pipeline for PyPI publish' - inputs: - azureSubscription: 'azure-sdk-partner-drops' - scriptType: pscore - scriptLocation: inlineScript - inlineScript: | - $ErrorActionPreference = "Stop" - $blobPath = "${{ parameters.blobPath }}/${{ parameters.libraryVersion }}" - Write-Host "Running partner pipeline for blob path: $blobPath" - - $result = az pipelines run ` - --project internal ` - --organization https://dev.azure.com/azure-sdk ` - --id 6991 ` - --branch refs/heads/main ` - --parameters "BlobPath=$blobPath" - - if (!$result) { - Write-Host "##vso[task.LogIssue type=error;]Failed to start partner pipeline." - exit 1 - } - - $result = $result | ConvertFrom-Json - Write-Host "##[section]Partner pipeline started successfully." - Write-Host "Build ID: $($result.id)" - Write-Host "Partner pipeline may require manual approval to proceed." - Write-Host "Please check the pipeline at: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=$($result.id)" \ No newline at end of file + Write-Host "Validated ESRP release contents for $packageName ${libraryVersion}:" + Write-Host " - $($wheels[0].Name)" + Write-Host " - $($sourceDistributions[0].Name)" + displayName: 'Validate ESRP package contents' + + - template: /ci/internal/publish-pypi-esrp.yml@eng + parameters: + folderLocation: '$(Pipeline.Workspace)/${{ parameters.artifactName }}/dist' + owners: ${{ parameters.esrpOwners }} + approvers: ${{ parameters.esrpApprovers }} + displayName: 'ESRP Release azure-functions ${{ parameters.libraryVersion }}' \ No newline at end of file