|
1 | 1 | # template-pipeline-stages.yml |
2 | 2 | # |
3 | | -# Unified pipeline stages template for the msal Python package. |
| 3 | +# Shared stages template for the msal Python package. |
4 | 4 | # |
5 | 5 | # Called from: |
6 | 6 | # pipeline-publish.yml — release build (runPublish: true) |
|
9 | 9 | # Parameters: |
10 | 10 | # packageVersion - Version to validate against msal/sku.py |
11 | 11 | # Required when runPublish is true; unused otherwise. |
12 | | -# publishTarget - 'test.pypi.org (Preview / RC)' or 'pypi.org (Pre-ESRP)' |
13 | | -# Required when runPublish is true; unused otherwise. |
14 | | -# runPublish - When true: also run Validate, Build, and Publish stages. |
| 12 | +# runPublish - When true: also runs the Validate stage before CI. |
15 | 13 | # When false (PR / merge builds): only PreBuildCheck + CI run. |
16 | 14 | # |
17 | 15 | # Stage flow: |
18 | 16 | # |
19 | | -# runPublish: true → PreBuildCheck ─► Validate ─► CI ─► Build ─► PublishMSALPython |
20 | | -# └─► PublishPyPI |
21 | | -# runPublish: false → PreBuildCheck ─► CI (Validate / Build / Publish are skipped) |
| 17 | +# runPublish: true → PreBuildCheck ─► Validate ─► CI |
| 18 | +# runPublish: false → PreBuildCheck ─► CI (Validate is skipped) |
| 19 | +# |
| 20 | +# Build and Publish stages are defined in pipeline-publish.yml (not here), |
| 21 | +# so that the PR build never references PyPI service connections. |
22 | 22 |
|
23 | 23 | parameters: |
24 | 24 | - name: packageVersion |
25 | 25 | type: string |
26 | 26 | default: '' |
27 | | -- name: publishTarget |
28 | | - type: string |
29 | | - default: '' |
30 | 27 | - name: runPublish |
31 | 28 | type: boolean |
32 | 29 | default: false |
@@ -193,144 +190,3 @@ stages: |
193 | 190 | - bash: rm -f "$(Agent.TempDirectory)/lab-auth.pfx" |
194 | 191 | displayName: 'Clean up lab certificate' |
195 | 192 | condition: always() |
196 | | - |
197 | | -# ══════════════════════════════════════════════════════════════════════════════ |
198 | | -# Stage 3 · Build — build sdist + wheel (release only) |
199 | | -# ══════════════════════════════════════════════════════════════════════════════ |
200 | | -- stage: Build |
201 | | - displayName: 'Build package' |
202 | | - dependsOn: CI |
203 | | - condition: and(eq(dependencies.CI.result, 'Succeeded'), eq(${{ parameters.runPublish }}, true)) |
204 | | - jobs: |
205 | | - - job: BuildDist |
206 | | - displayName: 'Build sdist + wheel (Python 3.12)' |
207 | | - pool: |
208 | | - vmImage: ubuntu-latest |
209 | | - steps: |
210 | | - - task: UsePythonVersion@0 |
211 | | - inputs: |
212 | | - versionSpec: '3.12' |
213 | | - displayName: 'Use Python 3.12' |
214 | | - |
215 | | - - script: | |
216 | | - python -m pip install --upgrade pip build twine |
217 | | - displayName: 'Install build toolchain' |
218 | | -
|
219 | | - - script: | |
220 | | - python -m build |
221 | | - displayName: 'Build sdist and wheel' |
222 | | -
|
223 | | - - script: | |
224 | | - python -m twine check dist/* |
225 | | - displayName: 'Verify distribution (twine check)' |
226 | | -
|
227 | | - - task: PublishPipelineArtifact@1 |
228 | | - displayName: 'Publish dist/ as pipeline artifact' |
229 | | - inputs: |
230 | | - targetPath: dist/ |
231 | | - artifact: python-dist |
232 | | - |
233 | | -# ══════════════════════════════════════════════════════════════════════════════ |
234 | | -# Stage 4a · Publish to test.pypi.org (Preview / RC) |
235 | | -# Runs when: runPublish is true AND publishTarget == 'test.pypi.org (Preview / RC)' |
236 | | -# Note: requires MSAL-Test-Python-Upload SC in ADO (pending test.pypi.org token) |
237 | | -# ══════════════════════════════════════════════════════════════════════════════ |
238 | | -- stage: PublishMSALPython |
239 | | - displayName: 'Publish to test.pypi.org (Preview)' |
240 | | - dependsOn: Build |
241 | | - condition: > |
242 | | - and( |
243 | | - eq(dependencies.Build.result, 'Succeeded'), |
244 | | - eq('${{ parameters.publishTarget }}', 'test.pypi.org (Preview / RC)') |
245 | | - ) |
246 | | - jobs: |
247 | | - - deployment: DeployMSALPython |
248 | | - displayName: 'Upload to test.pypi.org' |
249 | | - pool: |
250 | | - vmImage: ubuntu-latest |
251 | | - # Optional: add approval checks in ADO → Pipelines → Environments → MSAL-Python |
252 | | - environment: MSAL-Python |
253 | | - strategy: |
254 | | - runOnce: |
255 | | - deploy: |
256 | | - steps: |
257 | | - - task: DownloadPipelineArtifact@2 |
258 | | - displayName: 'Download python-dist artifact' |
259 | | - inputs: |
260 | | - artifactName: python-dist |
261 | | - targetPath: $(Pipeline.Workspace)/python-dist |
262 | | - |
263 | | - - task: UsePythonVersion@0 |
264 | | - inputs: |
265 | | - versionSpec: '3.12' |
266 | | - displayName: 'Use Python 3.12' |
267 | | - |
268 | | - - script: | |
269 | | - python -m pip install --upgrade pip |
270 | | - python -m pip install twine |
271 | | - displayName: 'Install twine' |
272 | | -
|
273 | | - - task: TwineAuthenticate@1 |
274 | | - displayName: 'Authenticate with MSAL-Test-Python-Upload' |
275 | | - inputs: |
276 | | - pythonUploadServiceConnection: MSAL-Test-Python-Upload |
277 | | - |
278 | | - - script: | |
279 | | - python -m twine upload \ |
280 | | - -r "MSAL-Test-Python-Upload" \ |
281 | | - --config-file $(PYPIRC_PATH) \ |
282 | | - --skip-existing \ |
283 | | - $(Pipeline.Workspace)/python-dist/* |
284 | | - displayName: 'Upload to MSAL-Test-Python-Upload (skip existing)' |
285 | | -
|
286 | | -# ══════════════════════════════════════════════════════════════════════════════ |
287 | | -# Stage 4b · Publish to PyPI (ESRP Production) |
288 | | -# Runs when: runPublish is true AND publishTarget == 'pypi.org (ESRP Production)' |
289 | | -# ══════════════════════════════════════════════════════════════════════════════ |
290 | | -- stage: PublishPyPI |
291 | | - displayName: 'Publish to PyPI (ESRP Production)' |
292 | | - dependsOn: Build |
293 | | - condition: > |
294 | | - and( |
295 | | - eq(dependencies.Build.result, 'Succeeded'), |
296 | | - eq('${{ parameters.publishTarget }}', 'pypi.org (ESRP Production)') |
297 | | - ) |
298 | | - jobs: |
299 | | - - deployment: DeployPyPI |
300 | | - displayName: 'Upload to pypi.org' |
301 | | - pool: |
302 | | - vmImage: ubuntu-latest |
303 | | - # IMPORTANT: configure a required manual approval on this environment in |
304 | | - # ADO → Pipelines → Environments → MSAL-Python-Release → Approvals and checks. |
305 | | - environment: MSAL-Python-Release |
306 | | - strategy: |
307 | | - runOnce: |
308 | | - deploy: |
309 | | - steps: |
310 | | - - task: DownloadPipelineArtifact@2 |
311 | | - displayName: 'Download python-dist artifact' |
312 | | - inputs: |
313 | | - artifactName: python-dist |
314 | | - targetPath: $(Pipeline.Workspace)/python-dist |
315 | | - |
316 | | - - task: UsePythonVersion@0 |
317 | | - inputs: |
318 | | - versionSpec: '3.12' |
319 | | - displayName: 'Use Python 3.12' |
320 | | - |
321 | | - - script: | |
322 | | - python -m pip install --upgrade pip |
323 | | - python -m pip install twine |
324 | | - displayName: 'Install twine' |
325 | | -
|
326 | | - - task: TwineAuthenticate@1 |
327 | | - displayName: 'Authenticate with MSAL-Prod-Python-Upload' |
328 | | - inputs: |
329 | | - pythonUploadServiceConnection: MSAL-Prod-Python-Upload |
330 | | - |
331 | | - - script: | |
332 | | - python -m twine upload \ |
333 | | - -r "MSAL-Prod-Python-Upload" \ |
334 | | - --config-file $(PYPIRC_PATH) \ |
335 | | - $(Pipeline.Workspace)/python-dist/* |
336 | | - displayName: 'Upload to PyPI (ESRP Production)' |
0 commit comments