From 5cc057a184a0ed7c8dbfa655378840f35a49d20f Mon Sep 17 00:00:00 2001 From: Victoria Hall Date: Tue, 17 Nov 2026 10:32:25 -0600 Subject: [PATCH] Use shared ESRP publishing for V1 and V2 runtimes --- eng/ci/worker-release.yml | 4 +- .../official/release/publish-release.yml | 182 +++++++++--------- 2 files changed, 91 insertions(+), 95 deletions(-) diff --git a/eng/ci/worker-release.yml b/eng/ci/worker-release.yml index 5ebcb0ea..74468d81 100644 --- a/eng/ci/worker-release.yml +++ b/eng/ci/worker-release.yml @@ -31,6 +31,8 @@ resources: variables: - template: /eng/templates/utils/byoc-variables.yml@self + - ${{ if or(eq(parameters.V1LibraryRelease, true), eq(parameters.V2LibraryRelease, true)) }}: + - group: azure-functions-python-release - name: codeql.excludePathPatterns value: deps/,build/ # Maps the single ReleaseVersion parameter to the worker release, which @@ -88,7 +90,6 @@ extends: projectDisplayName: 'Azure Functions Runtime V2' releaseBranchPrefix: 'release-v2' tagPrefix: 'runtimes/v2-' - blobPath: 'azure-functions/python/azure-functions-runtime' artifactName: 'azure-functions-runtime' - stage: ReleasePythonV1Library_BumpVersion dependsOn: [] @@ -126,5 +127,4 @@ extends: projectDisplayName: 'Azure Functions Runtime V1' releaseBranchPrefix: 'release-v1' tagPrefix: 'runtimes/v1-' - blobPath: 'azure-functions/python/azure-functions-runtime-v1' artifactName: 'azure-functions-runtime-v1' \ 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 6e1bce22..ff16908f 100644 --- a/eng/templates/official/release/publish-release.yml +++ b/eng/templates/official/release/publish-release.yml @@ -13,10 +13,6 @@ parameters: type: string default: '' displayName: 'Optional prefix for git tags (e.g., runtimes/v2-)' - - name: blobPath - type: string - default: 'azure-functions/python/azure-functions-runtime' - displayName: 'Blob path under drops container' - name: githubOrg type: string default: 'Azure' @@ -29,10 +25,15 @@ parameters: type: string default: 'azure-functions-runtime' displayName: 'Pipeline artifact name produced by the Build stage' - - name: partnerReleasePipelineUrl + - name: esrpOwners + type: string + default: '$(EsrpOwners)' + - name: esrpApprovers 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: '$(EsrpApprovers)' + - name: esrpManualApprovers + type: string + default: '$(EsrpManualApprovers)' jobs: - job: "CreateReleaseTag" @@ -180,99 +181,94 @@ jobs: notifyUsers: '' instructions: 'Please head to https://github.com/${{ parameters.githubOrg }}/${{ parameters.githubRepo }}/releases to finish the release note' - - job: PublishRelease + - job: ESRPApproval dependsOn: ['CheckGitHubRelease'] - displayName: 'Upload artifacts to partner blob for release' - - pool: - name: 1es-pool-azfunc - image: 1es-ubuntu-22.04 - os: linux - + displayName: 'Approve PyPI release' + timeoutInMinutes: 1440 + pool: server steps: - - checkout: none - - - download: current - artifact: ${{ parameters.artifactName }} - displayName: 'Download build artifacts' - - - task: AzurePowerShell@5 - displayName: 'Upload files to partner drop folder' + - task: ManualValidation@1 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/" - - # List files to be uploaded - Get-ChildItem -Path $distFolder -Recurse | ForEach-Object { - Write-Host " - $($_.Name)" - } - - # Upload all distribution files (whl and tar.gz) to partner blob - 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' - - - job: "TriggerPartnerRelease" - dependsOn: ['PublishRelease'] - displayName: 'Trigger partner-release pipeline' - + 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: | - 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' - - - 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)" + $ErrorActionPreference = 'Stop' + $distFolder = '$(Pipeline.Workspace)/${{ parameters.artifactName }}/dist' + # Runtime artifact names match their PyPI project names for V1 and V2. + $packageName = '${{ parameters.artifactName }}' + $libraryVersion = '${{ parameters.libraryVersion }}' + + if (-not (Test-Path -LiteralPath $distFolder -PathType Container)) { + throw "Distribution folder not found: $distFolder" + } + + $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' } + ) + + 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 ', ')" + } + + 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)." + } + + $reader = [System.IO.StreamReader]::new($metadataEntry.Open()) + try { + $metadata = $reader.ReadToEnd() + } finally { + $reader.Dispose() + } + } finally { + $archive.Dispose() + } + + $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." + } + + 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 ${{ parameters.artifactName }} ${{ parameters.libraryVersion }}'