|
| 1 | +# pipeline-publish.yml |
| 2 | +# |
| 3 | +# Release pipeline for the msal Python package — manually triggered only. |
| 4 | +# Source: https://github.com/AzureAD/microsoft-authentication-library-for-python |
| 5 | +# |
| 6 | +# Publish targets: |
| 7 | +# test.pypi.org (Preview / RC) — preview releases via MSAL-Test-Python-Upload SC |
| 8 | +# (SC creation pending test.pypi.org API token) |
| 9 | +# pypi.org (ESRP Production) — production releases via ESRP (EsrpRelease@9) using MSAL-ESRP-AME SC |
| 10 | +# |
| 11 | +# For pipeline documentation, see .Pipelines/CI-AND-RELEASE-PIPELINES.md. |
| 12 | + |
| 13 | +parameters: |
| 14 | +- name: packageVersion |
| 15 | + displayName: 'Package version to publish (must match msal/sku.py, e.g. 1.36.0 or 1.36.0rc1)' |
| 16 | + type: string |
| 17 | + |
| 18 | +- name: publishTarget |
| 19 | + displayName: 'Publish target' |
| 20 | + type: string |
| 21 | + values: |
| 22 | + - 'test.pypi.org (Preview / RC)' |
| 23 | + - 'pypi.org (ESRP Production)' |
| 24 | + |
| 25 | +trigger: none # manual runs only — no automatic branch or tag triggers |
| 26 | +pr: none |
| 27 | + |
| 28 | +# Stage flow: |
| 29 | +# |
| 30 | +# PreBuildCheck ─► Validate ─► CI ─► Build ─► PublishMSALPython (publishTarget == Preview) |
| 31 | +# └─► PublishPyPI (publishTarget == ESRP Production) |
| 32 | + |
| 33 | +stages: |
| 34 | + |
| 35 | +# PreBuildCheck, Validate, and CI stages are defined in the shared template. |
| 36 | +- template: template-pipeline-stages.yml |
| 37 | + parameters: |
| 38 | + packageVersion: ${{ parameters.packageVersion }} |
| 39 | + runPublish: true |
| 40 | + |
| 41 | +# ══════════════════════════════════════════════════════════════════════════════ |
| 42 | +# Stage 3 · Build — build sdist + wheel |
| 43 | +# ══════════════════════════════════════════════════════════════════════════════ |
| 44 | +- stage: Build |
| 45 | + displayName: 'Build package' |
| 46 | + dependsOn: CI |
| 47 | + condition: eq(dependencies.CI.result, 'Succeeded') |
| 48 | + jobs: |
| 49 | + - job: BuildDist |
| 50 | + displayName: 'Build sdist + wheel (Python 3.12)' |
| 51 | + pool: |
| 52 | + vmImage: ubuntu-latest |
| 53 | + steps: |
| 54 | + - task: UsePythonVersion@0 |
| 55 | + inputs: |
| 56 | + versionSpec: '3.12' |
| 57 | + displayName: 'Use Python 3.12' |
| 58 | + |
| 59 | + - script: | |
| 60 | + python -m pip install --upgrade pip build twine |
| 61 | + displayName: 'Install build toolchain' |
| 62 | +
|
| 63 | + - script: | |
| 64 | + python -m build |
| 65 | + displayName: 'Build sdist and wheel' |
| 66 | +
|
| 67 | + - script: | |
| 68 | + python -m twine check dist/* |
| 69 | + displayName: 'Verify distribution (twine check)' |
| 70 | +
|
| 71 | + - task: PublishPipelineArtifact@1 |
| 72 | + displayName: 'Publish dist/ as pipeline artifact' |
| 73 | + inputs: |
| 74 | + targetPath: dist/ |
| 75 | + artifact: python-dist |
| 76 | + |
| 77 | +# ══════════════════════════════════════════════════════════════════════════════ |
| 78 | +# Stage 4a · Publish to test.pypi.org (Preview / RC) |
| 79 | +# Note: requires MSAL-Test-Python-Upload SC in ADO (pending test.pypi.org API token) |
| 80 | +# ══════════════════════════════════════════════════════════════════════════════ |
| 81 | +- stage: PublishMSALPython |
| 82 | + displayName: 'Publish to test.pypi.org (Preview)' |
| 83 | + dependsOn: Build |
| 84 | + condition: > |
| 85 | + and( |
| 86 | + eq(dependencies.Build.result, 'Succeeded'), |
| 87 | + eq('${{ parameters.publishTarget }}', 'test.pypi.org (Preview / RC)') |
| 88 | + ) |
| 89 | + jobs: |
| 90 | + - deployment: DeployMSALPython |
| 91 | + displayName: 'Upload to test.pypi.org' |
| 92 | + pool: |
| 93 | + vmImage: ubuntu-latest |
| 94 | + environment: MSAL-Python |
| 95 | + strategy: |
| 96 | + runOnce: |
| 97 | + deploy: |
| 98 | + steps: |
| 99 | + - task: DownloadPipelineArtifact@2 |
| 100 | + displayName: 'Download python-dist artifact' |
| 101 | + inputs: |
| 102 | + artifactName: python-dist |
| 103 | + targetPath: $(Pipeline.Workspace)/python-dist |
| 104 | + |
| 105 | + - task: UsePythonVersion@0 |
| 106 | + inputs: |
| 107 | + versionSpec: '3.12' |
| 108 | + displayName: 'Use Python 3.12' |
| 109 | + |
| 110 | + - script: | |
| 111 | + python -m pip install --upgrade pip twine |
| 112 | + displayName: 'Install twine' |
| 113 | +
|
| 114 | + # TODO: create MSAL-Test-Python-Upload SC with test.pypi.org API token, then uncomment: |
| 115 | + # - task: TwineAuthenticate@1 |
| 116 | + # displayName: 'Authenticate with MSAL-Test-Python-Upload' |
| 117 | + # inputs: |
| 118 | + # pythonUploadServiceConnection: MSAL-Test-Python-Upload |
| 119 | + |
| 120 | + # - script: | |
| 121 | + # python -m twine upload \ |
| 122 | + # -r "MSAL-Test-Python-Upload" \ |
| 123 | + # --config-file $(PYPIRC_PATH) \ |
| 124 | + # --skip-existing \ |
| 125 | + # $(Pipeline.Workspace)/python-dist/* |
| 126 | + # displayName: 'Upload to test.pypi.org' |
| 127 | + |
| 128 | + - script: echo "Publish to test.pypi.org skipped — MSAL-Test-Python-Upload SC not yet created." |
| 129 | + displayName: 'Skip upload (SC pending)' |
| 130 | + |
| 131 | +# ══════════════════════════════════════════════════════════════════════════════ |
| 132 | +# Stage 4b · Publish to PyPI (ESRP Production) |
| 133 | +# Uses EsrpRelease@9 via the MSAL-ESRP-AME service connection. |
| 134 | +# IMPORTANT: configure a required manual approval on this environment in |
| 135 | +# ADO → Pipelines → Environments → MSAL-Python-Release → Approvals and checks. |
| 136 | +# IMPORTANT: EsrpRelease@9 requires a Windows agent. |
| 137 | +# ══════════════════════════════════════════════════════════════════════════════ |
| 138 | +- stage: PublishPyPI |
| 139 | + displayName: 'Publish to PyPI (ESRP Production)' |
| 140 | + dependsOn: Build |
| 141 | + condition: > |
| 142 | + and( |
| 143 | + eq(dependencies.Build.result, 'Succeeded'), |
| 144 | + eq('${{ parameters.publishTarget }}', 'pypi.org (ESRP Production)') |
| 145 | + ) |
| 146 | + jobs: |
| 147 | + - deployment: DeployPyPI |
| 148 | + displayName: 'Upload to PyPI via ESRP' |
| 149 | + pool: |
| 150 | + vmImage: windows-latest |
| 151 | + environment: MSAL-Python-Release |
| 152 | + strategy: |
| 153 | + runOnce: |
| 154 | + deploy: |
| 155 | + steps: |
| 156 | + - task: DownloadPipelineArtifact@2 |
| 157 | + displayName: 'Download python-dist artifact' |
| 158 | + inputs: |
| 159 | + artifactName: python-dist |
| 160 | + targetPath: $(Pipeline.Workspace)/python-dist |
| 161 | + |
| 162 | + - task: EsrpRelease@9 |
| 163 | + displayName: 'Publish to PyPI via ESRP' |
| 164 | + inputs: |
| 165 | + connectedservicename: 'MSAL-ESRP-AME' |
| 166 | + usemanagedidentity: true |
| 167 | + keyvaultname: 'MSALVault' |
| 168 | + signcertname: 'MSAL-ESRP-Release-Signing' |
| 169 | + clientid: '8650ce2b-38d4-466a-9144-bc5c19c88112' |
| 170 | + intent: 'PackageDistribution' |
| 171 | + contenttype: 'PyPi' |
| 172 | + contentsource: 'Folder' |
| 173 | + folderlocation: '$(Pipeline.Workspace)/python-dist' |
| 174 | + waitforreleasecompletion: true |
| 175 | + owners: 'ryauld@microsoft.com,avdunn@microsoft.com' |
| 176 | + approvers: 'avdunn@microsoft.com,bogavril@microsoft.com' |
| 177 | + serviceendpointurl: 'https://api.esrp.microsoft.com' |
| 178 | + mainpublisher: 'ESRPRELPACMAN' |
| 179 | + domaintenantid: '33e01921-4d64-4f8c-a055-5bdaffd5e33d' |
0 commit comments