From 5171a48c933cf1d5ae6756f71957fba9d8544df9 Mon Sep 17 00:00:00 2001 From: Leilei Zhang Date: Tue, 1 Sep 2026 14:50:47 +0800 Subject: [PATCH 1/5] Use NuGet proxy in ADO CI Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .pipelines/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pipelines/ci.yml b/.pipelines/ci.yml index c13690e7..1e9896b1 100644 --- a/.pipelines/ci.yml +++ b/.pipelines/ci.yml @@ -107,6 +107,7 @@ extends: $root = Join-Path "$(Agent.TempDirectory)" "win32metadata" nuget install Microsoft.Windows.SDK.Win32Metadata ` -Version 71.0.14-preview ` + -Source https://packagefeedproxy.microsoft.io/nuget/v3/index.json ` -OutputDirectory $root ` -DirectDownload ` -NonInteractive From 8be32f187c36a8df29f7357e2fbc193d537810de Mon Sep 17 00:00:00 2001 From: Leilei Zhang Date: Tue, 1 Sep 2026 14:53:56 +0800 Subject: [PATCH 2/5] Use hosted ARM64 runners for Python release Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/python-release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python-release.yml b/.github/workflows/python-release.yml index 01bbfaae..15ae8c2c 100644 --- a/.github/workflows/python-release.yml +++ b/.github/workflows/python-release.yml @@ -148,7 +148,7 @@ jobs: runtime-arm64: if: github.event_name != 'pull_request' needs: validate - runs-on: [self-hosted, Windows, ARM64, winui] + runs-on: windows-11-vs2026-arm strategy: fail-fast: false matrix: @@ -239,7 +239,7 @@ jobs: codegen-arm64: if: github.event_name != 'pull_request' needs: validate - runs-on: [self-hosted, Windows, ARM64, winui] + runs-on: windows-11-vs2026-arm steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -306,7 +306,7 @@ jobs: consume-codegen-arm64: if: github.event_name != 'pull_request' needs: [validate, codegen-arm64] - runs-on: [self-hosted, Windows, ARM64, winui] + runs-on: windows-11-vs2026-arm steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -363,7 +363,7 @@ jobs: consume-runtime-arm64: if: github.event_name != 'pull_request' needs: [validate, runtime-arm64, codegen-arm64] - runs-on: [self-hosted, Windows, ARM64, winui] + runs-on: windows-11-vs2026-arm strategy: fail-fast: false matrix: From 6f475787c6b92c73836fb952b432f5dbb82929b2 Mon Sep 17 00:00:00 2001 From: Leilei Zhang Date: Tue, 1 Sep 2026 15:27:00 +0800 Subject: [PATCH 3/5] Probe 1ES Windows ARM64 capacity Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .pipelines/ci.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.pipelines/ci.yml b/.pipelines/ci.yml index 1e9896b1..ec6280d0 100644 --- a/.pipelines/ci.yml +++ b/.pipelines/ci.yml @@ -26,6 +26,27 @@ extends: stages: - stage: Build jobs: + - job: ProbeArm64 + displayName: Probe hosted Windows ARM64 + pool: + name: Azure-Pipelines-1ESPT-ExDShared + image: windows-latest + os: windows + hostArchitecture: arm64 + steps: + - checkout: none + - task: PowerShell@2 + displayName: Verify native ARM64 host + inputs: + targetType: inline + script: | + $architecture = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture + Write-Host "OS architecture: $architecture" + Write-Host "PROCESSOR_ARCHITECTURE: $env:PROCESSOR_ARCHITECTURE" + if ($architecture -ne [System.Runtime.InteropServices.Architecture]::Arm64) { + throw "Expected an ARM64 host, got $architecture" + } + - job: Build pool: name: Azure-Pipelines-1ESPT-ExDShared From 8e747011cb8dcb824c62c3e5fb63d1a3472ee363 Mon Sep 17 00:00:00 2001 From: Leilei Zhang Date: Tue, 1 Sep 2026 16:19:36 +0800 Subject: [PATCH 4/5] Probe GitHub release artifact handoff Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .pipelines/ci.yml | 53 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/.pipelines/ci.yml b/.pipelines/ci.yml index ec6280d0..bf566fab 100644 --- a/.pipelines/ci.yml +++ b/.pipelines/ci.yml @@ -26,26 +26,61 @@ extends: stages: - stage: Build jobs: - - job: ProbeArm64 - displayName: Probe hosted Windows ARM64 + - job: ProbeGitHubHandoff + displayName: Probe GitHub artifact handoff pool: name: Azure-Pipelines-1ESPT-ExDShared image: windows-latest os: windows - hostArchitecture: arm64 + hostArchitecture: amd64 steps: - checkout: none + + - task: PowerShell@2 + displayName: Read GitHub Actions validation status + inputs: + targetType: inline + script: | + $headers = @{ + Accept = 'application/vnd.github+json' + 'User-Agent' = 'microsoft-dynwinrt-ado-ci' + 'X-GitHub-Api-Version' = '2022-11-28' + } + $jobs = Invoke-RestMethod ` + -Uri 'https://api.github.com/repos/microsoft/dynwinrt/actions/runs/33479627784/jobs?per_page=100' ` + -Headers $headers + $assembly = @($jobs.jobs | Where-Object name -EQ 'assemble-release') + if ($assembly.Count -ne 1 -or $assembly[0].conclusion -ne 'success') { + throw 'Could not verify the successful Python release assembly' + } + Write-Host "Verified GitHub Actions job: $($assembly[0].html_url)" + + - task: DownloadGitHubRelease@0 + displayName: Download existing GitHub release assets + inputs: + connection: 'github-service-connection' + userRepository: 'microsoft/dynwinrt' + defaultVersionType: 'specificTag' + version: 'v0.1.0-preview.19' + itemPattern: '*.tgz' + downloadPath: '$(Agent.TempDirectory)/github-release-probe' + - task: PowerShell@2 - displayName: Verify native ARM64 host + displayName: Verify downloaded release assets inputs: targetType: inline script: | - $architecture = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture - Write-Host "OS architecture: $architecture" - Write-Host "PROCESSOR_ARCHITECTURE: $env:PROCESSOR_ARCHITECTURE" - if ($architecture -ne [System.Runtime.InteropServices.Architecture]::Arm64) { - throw "Expected an ARM64 host, got $architecture" + $assets = @(Get-ChildItem '$(Agent.TempDirectory)/github-release-probe' ` + -Filter '*.tgz' -File -Recurse) + $expected = @( + 'microsoft-dynwinrt-0.1.0-preview.19.tgz', + 'microsoft-dynwinrt-codegen-0.1.0-preview.19.tgz' + ) + if ($assets.Count -ne 2 -or + @(Compare-Object $expected $assets.Name).Count -ne 0) { + throw "Unexpected GitHub release assets: $($assets.Name -join ', ')" } + Write-Host 'ADO downloaded and verified both existing GitHub release assets' - job: Build pool: From 55a1a61d464c5386508a9045b53936666f5b2bcd Mon Sep 17 00:00:00 2001 From: Leilei Zhang Date: Tue, 1 Sep 2026 16:59:32 +0800 Subject: [PATCH 5/5] Publish Python packages through ADO ESRP Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/python-release.yml | 75 +---- .pipelines/ci.yml | 56 ---- .pipelines/release.yml | 297 +++++++++++++++++++- README.md | 4 +- bindings/py/README.md | 32 +-- docs/status/PYTHON_CHECKLIST.md | 13 +- eng/release/python/verify_python_release.py | 66 ++++- 7 files changed, 387 insertions(+), 156 deletions(-) diff --git a/.github/workflows/python-release.yml b/.github/workflows/python-release.yml index 15ae8c2c..0f2acaaf 100644 --- a/.github/workflows/python-release.yml +++ b/.github/workflows/python-release.yml @@ -1,4 +1,4 @@ -name: Python wheels +name: Python release artifacts env: FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true @@ -21,14 +21,9 @@ on: workflow_dispatch: inputs: release_version: - description: Version to build; required as confirmation when publishing to PyPI + description: Version to build required: false type: string - publish_pypi: - description: Publish through the protected pypi environment (tag refs only) - required: true - default: false - type: boolean permissions: contents: read @@ -53,7 +48,6 @@ jobs: shell: pwsh env: RELEASE_VERSION: ${{ inputs.release_version }} - PUBLISH_PYPI: ${{ inputs.publish_pypi }} REF_NAME: ${{ github.ref_name }} REF_TYPE: ${{ github.ref_type }} run: | @@ -85,13 +79,6 @@ jobs: if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } Write-Host "Effective Python version: $pythonVersion" - if ($env:PUBLISH_PYPI -eq 'true' -and - ($env:REF_TYPE -ne 'tag' -or $env:REF_NAME -notlike 'v*')) { - throw 'PyPI publication requires dispatching an existing v tag' - } - if ($env:PUBLISH_PYPI -eq 'true' -and -not $env:RELEASE_VERSION) { - throw 'PyPI publication requires an explicit release_version confirmation' - } "version=$version" >> $env:GITHUB_OUTPUT "python_version=$pythonVersion" >> $env:GITHUB_OUTPUT @@ -472,61 +459,3 @@ jobs: $arguments += $wheels & gh @arguments if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } - - publish-runtime: - if: >- - github.event_name == 'workflow_dispatch' && - inputs.publish_pypi && - github.ref_type == 'tag' && - startsWith(github.ref_name, 'v') - needs: [validate, assemble-release] - runs-on: ubuntu-latest - environment: pypi - permissions: - contents: read - id-token: write - steps: - - uses: actions/download-artifact@v4 - with: - name: python-release-${{ needs.validate.outputs.version }} - path: dist - - name: Stage runtime wheels only - shell: bash - run: | - mkdir -p publish/runtime - find dist -type f -name 'dynwinrt-*.whl' -exec cp '{}' publish/runtime/ \; - test "$(find publish/runtime -type f -name '*.whl' | wc -l)" -eq 8 - - uses: pypa/gh-action-pypi-publish@release/v1 - with: - packages-dir: publish/runtime - attestations: true - skip-existing: true - - publish-codegen: - if: >- - github.event_name == 'workflow_dispatch' && - inputs.publish_pypi && - github.ref_type == 'tag' && - startsWith(github.ref_name, 'v') - needs: [validate, assemble-release, publish-runtime] - runs-on: ubuntu-latest - environment: pypi - permissions: - contents: read - id-token: write - steps: - - uses: actions/download-artifact@v4 - with: - name: python-release-${{ needs.validate.outputs.version }} - path: dist - - name: Stage codegen wheels only - shell: bash - run: | - mkdir -p publish/codegen - find dist -type f -name 'dynwinrt_codegen-*.whl' -exec cp '{}' publish/codegen/ \; - test "$(find publish/codegen -type f -name '*.whl' | wc -l)" -eq 2 - - uses: pypa/gh-action-pypi-publish@release/v1 - with: - packages-dir: publish/codegen - attestations: true - skip-existing: true diff --git a/.pipelines/ci.yml b/.pipelines/ci.yml index bf566fab..1e9896b1 100644 --- a/.pipelines/ci.yml +++ b/.pipelines/ci.yml @@ -26,62 +26,6 @@ extends: stages: - stage: Build jobs: - - job: ProbeGitHubHandoff - displayName: Probe GitHub artifact handoff - pool: - name: Azure-Pipelines-1ESPT-ExDShared - image: windows-latest - os: windows - hostArchitecture: amd64 - steps: - - checkout: none - - - task: PowerShell@2 - displayName: Read GitHub Actions validation status - inputs: - targetType: inline - script: | - $headers = @{ - Accept = 'application/vnd.github+json' - 'User-Agent' = 'microsoft-dynwinrt-ado-ci' - 'X-GitHub-Api-Version' = '2022-11-28' - } - $jobs = Invoke-RestMethod ` - -Uri 'https://api.github.com/repos/microsoft/dynwinrt/actions/runs/33479627784/jobs?per_page=100' ` - -Headers $headers - $assembly = @($jobs.jobs | Where-Object name -EQ 'assemble-release') - if ($assembly.Count -ne 1 -or $assembly[0].conclusion -ne 'success') { - throw 'Could not verify the successful Python release assembly' - } - Write-Host "Verified GitHub Actions job: $($assembly[0].html_url)" - - - task: DownloadGitHubRelease@0 - displayName: Download existing GitHub release assets - inputs: - connection: 'github-service-connection' - userRepository: 'microsoft/dynwinrt' - defaultVersionType: 'specificTag' - version: 'v0.1.0-preview.19' - itemPattern: '*.tgz' - downloadPath: '$(Agent.TempDirectory)/github-release-probe' - - - task: PowerShell@2 - displayName: Verify downloaded release assets - inputs: - targetType: inline - script: | - $assets = @(Get-ChildItem '$(Agent.TempDirectory)/github-release-probe' ` - -Filter '*.tgz' -File -Recurse) - $expected = @( - 'microsoft-dynwinrt-0.1.0-preview.19.tgz', - 'microsoft-dynwinrt-codegen-0.1.0-preview.19.tgz' - ) - if ($assets.Count -ne 2 -or - @(Compare-Object $expected $assets.Name).Count -ne 0) { - throw "Unexpected GitHub release assets: $($assets.Name -join ', ')" - } - Write-Host 'ADO downloaded and verified both existing GitHub release assets' - - job: Build pool: name: Azure-Pipelines-1ESPT-ExDShared diff --git a/.pipelines/release.yml b/.pipelines/release.yml index 4e8c5218..0eb086ef 100644 --- a/.pipelines/release.yml +++ b/.pipelines/release.yml @@ -235,9 +235,89 @@ extends: targetPath: artifacts artifactName: npm-packages + - stage: Wait_Python + displayName: Wait for tested Python wheels + dependsOn: Build + variables: + version: $[ stageDependencies.Build.Build.outputs['SetMeta.version'] ] + jobs: + - job: wait_python + pool: + name: Azure-Pipelines-1ESPT-ExDShared + image: windows-latest + os: windows + hostArchitecture: amd64 + displayName: Require successful Python release assembly + steps: + - checkout: none + - task: PowerShell@2 + displayName: Wait for GitHub ARM64 and x64 validation + inputs: + targetType: inline + script: | + $ErrorActionPreference = 'Stop' + $runsUri = "https://api.github.com/repos/microsoft/dynwinrt/actions/workflows/python-release.yml/runs?event=push&head_sha=$(Build.SourceVersion)&per_page=20" + $headers = @{ + Accept = 'application/vnd.github+json' + 'User-Agent' = 'microsoft-dynwinrt-ado-release' + 'X-GitHub-Api-Version' = '2022-11-28' + } + function Invoke-GitHubApi([string]$Uri) { + for ($requestAttempt = 1; $requestAttempt -le 3; $requestAttempt++) { + try { + return (Invoke-RestMethod -Uri $Uri -Headers $headers) + } catch { + if ($requestAttempt -eq 3) { throw } + Write-Warning "GitHub API request failed; retrying: $($_.Exception.Message)" + Start-Sleep -Seconds (10 * $requestAttempt) + } + } + } + $run = $null + for ($attempt = 1; $attempt -le 10; $attempt++) { + $runs = Invoke-GitHubApi $runsUri + $matches = @($runs.workflow_runs | + Where-Object head_branch -EQ "v$(version)") + if ($matches.Count -gt 1) { + throw "Expected one Python tag workflow, found $($matches.Count)" + } + if ($matches.Count -eq 1) { + $run = $matches[0] + break + } + Write-Host "Waiting for the Python tag workflow (attempt $attempt/10)..." + Start-Sleep -Seconds 30 + } + if (-not $run) { + throw 'The Python tag workflow did not start within 5 minutes' + } + + $ready = $false + for ($attempt = 1; $attempt -le 20; $attempt++) { + $jobs = Invoke-GitHubApi "$($run.jobs_url)?per_page=100" + $assembly = @($jobs.jobs | Where-Object name -EQ 'assemble-release') + if ($assembly.Count -eq 1 -and $assembly[0].status -eq 'completed') { + if ($assembly[0].conclusion -ne 'success') { + throw "Python release assembly concluded '$($assembly[0].conclusion)'" + } + $ready = $true + break + } + if ($run.status -eq 'completed' -and $run.conclusion -ne 'success') { + throw "Python tag workflow concluded '$($run.conclusion)'" + } + Write-Host "Waiting for Python release assembly (attempt $attempt/20)..." + Start-Sleep -Seconds 60 + } + if (-not $ready) { + throw 'Python release assembly did not pass within 20 minutes' + } + - stage: Release_GitHub displayName: Create GitHub Release - dependsOn: Build + dependsOn: + - Build + - Wait_Python variables: version: $[ stageDependencies.Build.Build.outputs['SetMeta.version'] ] isPrerelease: $[ stageDependencies.Build.Build.outputs['SetMeta.isPrerelease'] ] @@ -275,12 +355,15 @@ extends: **Packages:** - `@microsoft/dynwinrt` - JavaScript/TypeScript bindings for WinRT dynamic invocation - `@microsoft/dynwinrt-codegen` - Code generation tool for typed WinRT bindings + - `dynwinrt` - Native Python runtime for generated WinRT projections + - `dynwinrt-codegen` - Standalone Python code generation tool ## Installation ```bash npm install @microsoft/dynwinrt npm install -D @microsoft/dynwinrt-codegen + python -m pip install dynwinrt dynwinrt-codegen ``` ## What's Included @@ -288,6 +371,8 @@ extends: - ✅ Native addons for x64 and ARM64 - ✅ TypeScript type definitions - ✅ dynwinrt-codegen CLI for code generation + - ✅ CPython 3.11–3.14 runtime wheels for Windows x64 and ARM64 + - ✅ Standalone Python codegen wheels for Windows x64 and ARM64 For usage instructions, see the [README](https://github.com/microsoft/dynwinrt#readme). assets: '$(Pipeline.Workspace)/npm-packages/*.tgz' @@ -295,10 +380,109 @@ extends: isPreRelease: $(isPrerelease) addChangeLog: true + - stage: Collect_Python + displayName: Collect tested Python wheels + dependsOn: + - Build + - Release_GitHub + variables: + version: $[ stageDependencies.Build.Build.outputs['SetMeta.version'] ] + jobs: + - job: collect_python + pool: + name: Azure-Pipelines-1ESPT-ExDShared + image: windows-latest + os: windows + hostArchitecture: amd64 + displayName: Collect Python release artifacts + steps: + - checkout: self + + - task: PowerShell@2 + displayName: Wait for tested Python wheels + inputs: + targetType: inline + script: | + $ErrorActionPreference = 'Stop' + $uri = "https://api.github.com/repos/microsoft/dynwinrt/releases/tags/v$(version)" + $headers = @{ + Accept = 'application/vnd.github+json' + 'User-Agent' = 'microsoft-dynwinrt-ado-release' + 'X-GitHub-Api-Version' = '2022-11-28' + } + function Invoke-GitHubApi([string]$Uri) { + for ($requestAttempt = 1; $requestAttempt -le 3; $requestAttempt++) { + try { + return (Invoke-RestMethod -Uri $Uri -Headers $headers) + } catch { + if ($requestAttempt -eq 3) { throw } + Write-Warning "GitHub API request failed; retrying: $($_.Exception.Message)" + Start-Sleep -Seconds (10 * $requestAttempt) + } + } + } + $ready = $false + for ($attempt = 1; $attempt -le 40; $attempt++) { + $release = Invoke-GitHubApi $uri + if ($release.target_commitish -ne '$(Build.SourceVersion)') { + throw "GitHub release target '$($release.target_commitish)' does not match $(Build.SourceVersion)" + } + $wheels = @($release.assets | Where-Object name -Like '*.whl') + if ($wheels.Count -eq 10) { + $ready = $true + break + } + if ($wheels.Count -gt 10) { + throw "Expected 10 Python wheel assets, found $($wheels.Count)" + } + Write-Host "Waiting for Python release wheels ($($wheels.Count)/10, attempt $attempt/40)..." + Start-Sleep -Seconds 30 + } + if (-not $ready) { + throw 'The complete tested Python wheel set was not attached within 20 minutes' + } + + - task: DownloadGitHubRelease@0 + displayName: Download tested Python wheels + inputs: + connection: 'github-service-connection' + userRepository: 'microsoft/dynwinrt' + defaultVersionType: 'specificTag' + version: 'v$(version)' + itemPattern: '*.whl' + downloadPath: '$(Pipeline.Workspace)/python-packages' + + - task: UsePythonVersion@0 + displayName: Setup Python 3.12 + inputs: + versionSpec: '3.12' + + - task: PowerShell@2 + displayName: Verify complete Python release set + inputs: + targetType: inline + script: | + python -m pip install ` + --index-url https://packagefeedproxy.microsoft.io/pypi/simple/ ` + "packaging>=24,<27" --quiet + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + python eng\release\python\verify_python_release.py release-set ` + --directory "$(Pipeline.Workspace)/python-packages" ` + --version "$(version)" + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + + - task: 1ES.PublishPipelineArtifact@1 + displayName: Upload verified Python packages + inputs: + targetPath: '$(Pipeline.Workspace)/python-packages' + artifactName: python-packages + - ${{ if eq(parameters.DoEsrp, 'true') }}: - stage: Release_Npm displayName: Publish to NPM - dependsOn: Release_GitHub + dependsOn: + - Build + - Collect_Python variables: version: $[ stageDependencies.Build.Build.outputs['SetMeta.version'] ] jobs: @@ -347,3 +531,112 @@ extends: mainpublisher: 'ESRPRELPACMAN' domaintenantid: ${{ parameters.signingIdentity.tenantId }} + - stage: Release_PyPI + displayName: Publish to PyPI + dependsOn: + - Build + - Collect_Python + - Release_Npm + variables: + version: $[ stageDependencies.Build.Build.outputs['SetMeta.version'] ] + jobs: + - job: publish_python_runtime + pool: + name: Azure-Pipelines-1ESPT-ExDShared + image: windows-latest + os: windows + hostArchitecture: amd64 + displayName: Publish dynwinrt to PyPI + templateContext: + type: releaseJob + isProduction: true + inputs: + - input: pipelineArtifact + artifactName: python-packages + targetPath: $(Pipeline.Workspace)/python-packages + steps: + - task: PowerShell@2 + displayName: Stage runtime wheels + inputs: + targetType: inline + script: | + $destination = '$(Pipeline.Workspace)/python-runtime' + New-Item $destination -ItemType Directory -Force | Out-Null + $wheels = @(Get-ChildItem '$(Pipeline.Workspace)/python-packages' ` + -Filter 'dynwinrt-*.whl' -File -Recurse) + if ($wheels.Count -ne 8) { + throw "Expected 8 dynwinrt wheels, found $($wheels.Count)" + } + $wheels | Copy-Item -Destination $destination + + - task: EsrpRelease@10 + displayName: Publish dynwinrt to PyPI via ESRP + inputs: + ConnectedServiceName: ${{ parameters.signingIdentity.serviceName }} + usemanagedidentity: false + keyvaultname: ${{ parameters.signingIdentity.akvName }} + authcertname: ${{ parameters.signingIdentity.authCertName }} + signcertname: ${{ parameters.signingIdentity.signCertName }} + clientid: ${{ parameters.signingIdentity.appId }} + intent: 'PackageDistribution' + contenttype: 'PyPI' + contentsource: 'Folder' + folderlocation: '$(Pipeline.Workspace)/python-runtime' + waitforreleasecompletion: true + owners: '$(EsrpOwnersEmail)' + approvers: '$(EsrpApproversEmail)' + serviceendpointurl: 'https://api.esrp.microsoft.com' + mainpublisher: 'ESRPRELPACMAN' + domaintenantid: ${{ parameters.signingIdentity.tenantId }} + releasetitle: 'dynwinrt $(version)' + + - job: publish_python_codegen + dependsOn: publish_python_runtime + pool: + name: Azure-Pipelines-1ESPT-ExDShared + image: windows-latest + os: windows + hostArchitecture: amd64 + displayName: Publish dynwinrt-codegen to PyPI + templateContext: + type: releaseJob + isProduction: true + inputs: + - input: pipelineArtifact + artifactName: python-packages + targetPath: $(Pipeline.Workspace)/python-packages + steps: + - task: PowerShell@2 + displayName: Stage codegen wheels + inputs: + targetType: inline + script: | + $destination = '$(Pipeline.Workspace)/python-codegen' + New-Item $destination -ItemType Directory -Force | Out-Null + $wheels = @(Get-ChildItem '$(Pipeline.Workspace)/python-packages' ` + -Filter 'dynwinrt_codegen-*.whl' -File -Recurse) + if ($wheels.Count -ne 2) { + throw "Expected 2 dynwinrt-codegen wheels, found $($wheels.Count)" + } + $wheels | Copy-Item -Destination $destination + + - task: EsrpRelease@10 + displayName: Publish dynwinrt-codegen to PyPI via ESRP + inputs: + ConnectedServiceName: ${{ parameters.signingIdentity.serviceName }} + usemanagedidentity: false + keyvaultname: ${{ parameters.signingIdentity.akvName }} + authcertname: ${{ parameters.signingIdentity.authCertName }} + signcertname: ${{ parameters.signingIdentity.signCertName }} + clientid: ${{ parameters.signingIdentity.appId }} + intent: 'PackageDistribution' + contenttype: 'PyPI' + contentsource: 'Folder' + folderlocation: '$(Pipeline.Workspace)/python-codegen' + waitforreleasecompletion: true + owners: '$(EsrpOwnersEmail)' + approvers: '$(EsrpApproversEmail)' + serviceendpointurl: 'https://api.esrp.microsoft.com' + mainpublisher: 'ESRPRELPACMAN' + domaintenantid: ${{ parameters.signingIdentity.tenantId }} + releasetitle: 'dynwinrt-codegen $(version)' diff --git a/README.md b/README.md index 4a18bc2f..533acbd6 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ cargo test -p dynwinrt # JS bindings (napi-rs) cd bindings/js && npm install && npm run build -# Python bindings (PyO3 + maturin) — experimental, not published to PyPI +# Python bindings (PyO3 + maturin) cd bindings/py && maturin develop && pytest # Codegen tool @@ -151,7 +151,7 @@ cargo run -p dynwinrt-codegen -- generate --namespace Windows.Foundation --cla Python runtime wheels target CPython 3.11–3.14 on Windows x64 and ARM64. The standalone `dynwinrt-codegen` Python wheel targets CPython 3.8–3.14 and needs no -Rust installation at consumption time. Release and trusted-publishing +Rust installation at consumption time. Release and ESRP publishing instructions are in [`bindings/py/README.md`](bindings/py/README.md). Python runtime, codegen, packaging, and WinUI readiness are tracked in diff --git a/bindings/py/README.md b/bindings/py/README.md index 66cfa67b..a4b58380 100644 --- a/bindings/py/README.md +++ b/bindings/py/README.md @@ -36,11 +36,9 @@ The wheel includes `__init__.pyi` and `py.typed` for static type checking. installed command with Rust removed from `PATH`. Pull requests run the x64 matrix. ARM64 jobs run only for manual dispatches and -`v*` release tags on the repository's existing -`[self-hosted, Windows, ARM64, winui]` runner. This avoids executing untrusted -pull-request code on a self-hosted machine. A release remains blocked rather -than producing ARM64 artifacts if that runner or one of its native CPython -versions is unavailable. +`v*` release tags on GitHub-hosted `windows-11-vs2026-arm` runners. A release +remains blocked rather than producing ARM64 artifacts if one of its native +CPython versions cannot build or pass its isolated consumer test. To release: @@ -48,17 +46,19 @@ To release: `v0.1.0-preview.20`). The workflow derives the Python package version from the tag and updates its build workspaces without modifying the repository. PEP 440 normalizes `preview.N` wheel versions to `rcN`. -2. The JavaScript release pipeline creates the GitHub release. After all ten - Python wheels pass their consumption tests, this workflow waits for that - release and uploads the wheels alongside the npm tarballs. It never creates - a separate Python GitHub release. -3. Configure the protected `pypi` GitHub environment with required reviewers - and PyPI trusted publishers for `dynwinrt` and `dynwinrt-codegen`. To - publish, manually dispatch the workflow **from that existing tag** with - `publish_pypi` enabled and `release_version` set. OIDC trusted publishing is - used; no API token is stored in the repository. - -Do not enable publication from a branch, pull request, or ordinary push. +2. The official 1ES ADO release pipeline creates the shared GitHub release and + publishes the npm packages. After all ten Python wheels pass their + consumption tests, the GitHub workflow uploads them alongside the npm + tarballs. It never creates a separate Python GitHub release. +3. The ADO pipeline waits for the complete wheel set, downloads it through the + repository's GitHub service connection, and revalidates every filename, + platform tag, Python ABI tag, metadata record, type stub, and native payload. +4. ADO publishes the eight `dynwinrt` wheels first and the two + `dynwinrt-codegen` wheels second through the Microsoft ESRP release identity. + PyPI publication is not available from GitHub Actions. + +Before the first release, onboard both PyPI project names to the configured ESRP +service connection and confirm the signing identity, owners, and approvers. Generated `IReference` values are projected as `T | None`; native values, `None`, and generated `IReference_*` wrappers are accepted as inputs. diff --git a/docs/status/PYTHON_CHECKLIST.md b/docs/status/PYTHON_CHECKLIST.md index 62d44378..a08f65d1 100644 --- a/docs/status/PYTHON_CHECKLIST.md +++ b/docs/status/PYTHON_CHECKLIST.md @@ -93,17 +93,18 @@ of a dynamic projection. - [x] Execute all tests under `bindings/py/tests` in CI. - [x] Build and install wheels before running Python E2E. -- [ ] Complete the first live CPython 3.11–3.14 x64/ARM64 release-matrix run. - The native ARM64 jobs are configured on the existing self-hosted WinUI - runner and fail closed; local x64 validation does not count as ARM64 - validation. +- [x] Complete the first live CPython 3.11–3.14 x64/ARM64 release-matrix run. + Native ARM64 builds and isolated consumers run on GitHub-hosted Windows + ARM64 runners. - [x] Remove unverified PyPy metadata. - [x] Derive Python artifact versions from ordinary `v` release tags, inject them only into ephemeral CI workspaces, and attach the complete wheel set to the shared JavaScript GitHub release. - [ ] Publish signed/provenanced wheels to an approved internal Python feed. -- [x] Add a protected-environment, OIDC trusted-publishing path that requires - manual opt-in from an existing release tag. +- [x] Route production PyPI publication through the official 1ES ADO release + pipeline and Microsoft ESRP identity. +- [ ] Complete one-time ESRP/PyPI onboarding for `dynwinrt` and + `dynwinrt-codegen`, including release owners and approvers. - [x] Add complete tested Python wheel assets and installation notes to GitHub releases. - [x] Provide a Python-native codegen CLI wheel using maturin binary bindings. diff --git a/eng/release/python/verify_python_release.py b/eng/release/python/verify_python_release.py index 2d0c7ad8..f872a5e6 100644 --- a/eng/release/python/verify_python_release.py +++ b/eng/release/python/verify_python_release.py @@ -19,6 +19,7 @@ RUNTIME_REQUIRES = ">=3.11,<3.15" CODEGEN_REQUIRES = ">=3.8,<3.15" RUNTIME_MINORS = tuple(f"3.{minor}" for minor in range(11, 15)) +PLATFORM_TAGS = ("win_amd64", "win_arm64") def load_toml(path: Path) -> dict: @@ -127,6 +128,63 @@ def verify_wheel(args: argparse.Namespace) -> None: print(f"wheel metadata OK: {wheel.name}") +def release_wheels(version: str) -> list[tuple[str, str, str, str, str]]: + normalized_version = str(Version(version)) + wheels = [] + for platform_tag in PLATFORM_TAGS: + for minor in RUNTIME_MINORS: + python_tag = f"cp{minor.replace('.', '')}" + wheels.append( + ( + f"dynwinrt-{normalized_version}-{python_tag}-{python_tag}-{platform_tag}.whl", + "dynwinrt", + python_tag, + python_tag, + platform_tag, + ) + ) + wheels.append( + ( + f"dynwinrt_codegen-{normalized_version}-py3-none-{platform_tag}.whl", + "dynwinrt-codegen", + "py3", + "none", + platform_tag, + ) + ) + return wheels + + +def verify_release_set(args: argparse.Namespace) -> None: + directory = Path(args.directory).resolve() + wheels = list(directory.rglob("*.whl")) + actual_names = [wheel.name for wheel in wheels] + assert len(actual_names) == len(set(actual_names)), ( + f"Release wheel filenames must be unique: {actual_names}" + ) + + expected = release_wheels(args.version) + expected_names = {wheel[0] for wheel in expected} + assert set(actual_names) == expected_names, ( + f"Release wheel set mismatch; missing={sorted(expected_names - set(actual_names))}, " + f"unexpected={sorted(set(actual_names) - expected_names)}" + ) + + wheels_by_name = {wheel.name: wheel for wheel in wheels} + for name, package, python_tag, abi_tag, platform_tag in expected: + verify_wheel( + argparse.Namespace( + wheel=wheels_by_name[name], + package=package, + version=args.version, + python_tag=python_tag, + abi_tag=abi_tag, + platform_tag=platform_tag, + ) + ) + print(f"complete Python release set OK: {len(wheels)} wheels") + + def main() -> None: parser = argparse.ArgumentParser() subparsers = parser.add_subparsers(dest="command", required=True) @@ -143,11 +201,17 @@ def main() -> None: wheel.add_argument("--abi-tag", required=True) wheel.add_argument("--platform-tag", required=True) + release_set = subparsers.add_parser("release-set") + release_set.add_argument("--directory", required=True) + release_set.add_argument("--version", required=True) + args = parser.parse_args() if args.command == "source": verify_source(args.tag, args.release_version) - else: + elif args.command == "wheel": verify_wheel(args) + else: + verify_release_set(args) if __name__ == "__main__":