Skip to content

Commit d342947

Browse files
committed
Consolidate 4 step templates into shared template-pipeline-stages.yml; slim pipeline-publish.yml to thin wrapper
1 parent 7ec5fb3 commit d342947

7 files changed

Lines changed: 301 additions & 373 deletions

.Pipelines/ADO-PUBLISH-SETUP.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ The `.Pipelines/` folder follows the same template convention as [MSAL.NET](http
88

99
| File | Purpose |
1010
|------|---------|
11-
| [`pipeline-publish.yml`](pipeline-publish.yml) | Top-level orchestrator — triggers, variables, stage wiring |
12-
| [`template-run-tests.yml`](template-run-tests.yml) | Reusable step template — pytest across Python version matrix |
13-
| [`template-build-package.yml`](template-build-package.yml) | Reusable step template — `python -m build` + `twine check` + artifact publish |
14-
| [`template-publish-package.yml`](template-publish-package.yml) | Reusable step template — `TwineAuthenticate` + `twine upload` (parameterized for MSAL-Python/PyPI) |
11+
| [`pipeline-publish.yml`](pipeline-publish.yml) | Thin top-level wrapper — triggers, parameters, calls `template-pipeline-stages.yml` with `runPublish: true` |
12+
| [`template-pipeline-stages.yml`](template-pipeline-stages.yml) | Shared stages template — Validate, CI, Build, Publish stages; reusable by PR-gate and post-merge CI pipelines |
1513

1614
---
1715

@@ -22,9 +20,9 @@ Every publish requires explicitly entering a version and selecting a destination
2220

2321
| Stage | Trigger | Target |
2422
|-------|---------|--------|
25-
| **Validate** | always | asserts `packageVersion` matches `msal/sku.py` |
26-
| **CI** (tests on Py 3.9–3.14) | after Validate ||
27-
| **Build** (sdist + wheel) | after CI | dist artifact |
23+
| **Validate** | release runs only (`runPublish: true`) | asserts `packageVersion` matches `msal/sku.py` |
24+
| **CI** (tests on Py 3.9–3.14) | after Validate (or immediately on PR/merge runs) ||
25+
| **Build** (sdist + wheel) | after CI, release runs only | dist artifact |
2826
| **PublishMSALPython** | `publishTarget = test.pypi.org (Preview / RC)` | test.pypi.org |
2927
| **PublishPyPI** | `publishTarget = pypi.org (Production)` | PyPI (production) |
3028

.Pipelines/pipeline-publish.yml

Lines changed: 11 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
# pipeline-publish.yml
22
#
3-
# Publish pipeline for the msal Python package.
3+
# Release pipeline for the msal Python package — manually triggered only.
44
# Source: https://github.com/AzureAD/microsoft-authentication-library-for-python
55
#
6-
# Composes reusable templates from this folder:
7-
# template-run-tests.yml - pytest across Python version matrix
8-
# template-build-package.yml - sdist + wheel build + twine check
9-
# template-publish-package.yml - TwineAuthenticate + twine upload (parameterized)
10-
#
11-
# Trigger logic:
12-
# This pipeline is MANUALLY TRIGGERED ONLY.
13-
# Both packageVersion and publishTarget must be explicitly set at queue time.
14-
#
15-
# One-time ADO setup: see ADO-PUBLISH-SETUP.md
6+
# Delegates all stages to template-pipeline-stages.yml, which is shared with
7+
# the (future) PR gate and post-merge CI pipelines.
8+
# For one-time ADO setup, see ADO-PUBLISH-SETUP.md.
169

17-
# ── Pipeline parameters ────────────────────────────────────────────────────────
18-
# Both fields are shown as required inputs in the ADO "Run pipeline" UI.
19-
# Neither has a default — the Validate stage will fail if either is empty or
20-
# if packageVersion does not match msal/sku.py __version__.
2110
parameters:
2211
- name: packageVersion
2312
displayName: 'Package version to publish (must match msal/sku.py, e.g. 1.36.0 or 1.36.0rc1)'
@@ -27,155 +16,15 @@ parameters:
2716
displayName: 'Publish target'
2817
type: string
2918
values:
30-
- 'test.pypi.org (Preview / RC)' # publishes to test.pypi.org (staging / preview)
31-
- 'pypi.org (Production)' # publishes to PyPI (production)
19+
- 'test.pypi.org (Preview / RC)'
20+
- 'pypi.org (Production)'
3221

3322
trigger: none # manual runs only — no automatic branch or tag triggers
3423
pr: none
3524

36-
variables:
37-
pythonBuildVersion: '3.12' # single version used for build + publish jobs
38-
39-
# ══════════════════════════════════════════════════════════════════════════════
40-
# Stage 1 · Validate — verify packageVersion matches msal/sku.py before
41-
# anything else runs.
42-
# ══════════════════════════════════════════════════════════════════════════════
4325
stages:
44-
- stage: Validate
45-
displayName: 'Validate version'
46-
jobs:
47-
- job: ValidateVersion
48-
displayName: 'Check version matches source'
49-
pool:
50-
vmImage: ubuntu-latest
51-
steps:
52-
- task: UsePythonVersion@0
53-
inputs:
54-
versionSpec: '3.12'
55-
displayName: 'Set up Python'
56-
57-
- bash: |
58-
PARAM_VER="${{ parameters.packageVersion }}"
59-
SKU_VER=$(grep '__version__' msal/sku.py | sed 's/.*"\(.*\)".*/\1/')
60-
61-
if [ -z "$PARAM_VER" ]; then
62-
echo "##vso[task.logissue type=error]packageVersion is required. Enter the version to publish (must match msal/sku.py __version__)."
63-
exit 1
64-
elif [ "$PARAM_VER" != "$SKU_VER" ]; then
65-
echo "##vso[task.logissue type=error]Version mismatch: parameter '$PARAM_VER' != msal/sku.py '$SKU_VER'"
66-
echo "Update msal/sku.py __version__ to match the packageVersion parameter, or correct the parameter."
67-
exit 1
68-
else
69-
echo "Version validated: $PARAM_VER"
70-
fi
71-
displayName: 'Verify version parameter matches msal/sku.py'
72-
73-
# ══════════════════════════════════════════════════════════════════════════════
74-
# Stage 2 · CI — run the full test matrix
75-
# ══════════════════════════════════════════════════════════════════════════════
76-
- stage: CI
77-
displayName: 'Run tests'
78-
dependsOn: Validate
79-
condition: succeeded()
80-
jobs:
81-
- job: Test
82-
displayName: 'Run unit tests'
83-
pool:
84-
vmImage: ubuntu-latest
85-
strategy:
86-
matrix:
87-
Python39:
88-
python.version: '3.9'
89-
Python310:
90-
python.version: '3.10'
91-
Python311:
92-
python.version: '3.11'
93-
Python312:
94-
python.version: '3.12'
95-
Python313:
96-
python.version: '3.13'
97-
Python314:
98-
python.version: '3.14'
99-
steps:
100-
- template: template-run-tests.yml # python.version resolved from matrix
101-
102-
# ══════════════════════════════════════════════════════════════════════════════
103-
# Stage 3 · Build — compile sdist + wheel (single Python version)
104-
# ══════════════════════════════════════════════════════════════════════════════
105-
- stage: Build
106-
displayName: 'Build package'
107-
dependsOn: CI
108-
condition: succeeded()
109-
jobs:
110-
- job: BuildDist
111-
displayName: 'Build sdist + wheel (Python 3.12)'
112-
pool:
113-
vmImage: ubuntu-latest
114-
steps:
115-
- template: template-build-package.yml
116-
parameters:
117-
pythonVersion: '3.12' # must be a literal — template params resolve at compile time
118-
artifactName: python-dist
119-
120-
# ══════════════════════════════════════════════════════════════════════════════
121-
# Stage 4a · Publish to MSAL-Python (test.pypi.org)
122-
# Runs when: publishTarget == 'test.pypi.org (Preview / RC)'
123-
# ══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
124-
- stage: PublishMSALPython
125-
displayName: 'Publish to test.pypi.org (Preview)'
126-
dependsOn: Build
127-
condition: >
128-
and(
129-
succeeded(),
130-
eq('${{ parameters.publishTarget }}', 'test.pypi.org (Preview / RC)')
131-
)
132-
jobs:
133-
- deployment: DeployMSALPython
134-
displayName: 'Upload to test.pypi.org'
135-
pool:
136-
vmImage: ubuntu-latest
137-
# Optional: add approval checks in ADO → Pipelines → Environments → MSAL-Python
138-
environment: MSAL-Python
139-
strategy:
140-
runOnce:
141-
deploy:
142-
steps:
143-
- template: template-publish-package.yml
144-
parameters:
145-
serviceConnectionName: MSAL-Test-Python-Upload
146-
repositoryName: MSAL-Test-Python-Upload
147-
artifactName: python-dist
148-
pythonVersion: '3.12' # must be a literal — template params resolve at compile time
149-
skipExisting: true
150-
151-
# ══════════════════════════════════════════════════════════════════════════════
152-
# Stage 4b · Publish to PyPI
153-
# Runs when: publishTarget == 'pypi.org (Production)'
154-
# ══════════════════════════════════════════════════════════════════════════════
155-
- stage: PublishPyPI
156-
displayName: 'Publish to PyPI (Production)'
157-
dependsOn: Build
158-
condition: >
159-
and(
160-
succeeded(),
161-
eq('${{ parameters.publishTarget }}', 'pypi.org (Production)')
162-
)
163-
jobs:
164-
- deployment: DeployPyPI
165-
displayName: 'Upload to pypi.org'
166-
pool:
167-
vmImage: ubuntu-latest
168-
# IMPORTANT: configure a required manual approval on this environment in
169-
# ADO → Pipelines → Environments → MSAL-Python-Release → Approvals and checks.
170-
environment: MSAL-Python-Release
171-
strategy:
172-
runOnce:
173-
deploy:
174-
steps:
175-
- template: template-publish-package.yml
176-
parameters:
177-
serviceConnectionName: MSAL-Prod-Python-Upload
178-
repositoryName: MSAL-Prod-Python-Upload
179-
artifactName: python-dist
180-
pythonVersion: '3.12' # must be a literal — template params resolve at compile time
181-
skipExisting: false
26+
- template: template-pipeline-stages.yml
27+
parameters:
28+
packageVersion: ${{ parameters.packageVersion }}
29+
publishTarget: ${{ parameters.publishTarget }}
30+
runPublish: true

.Pipelines/template-build-package.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

.Pipelines/template-install-lab-cert.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)