Skip to content

Commit 368d8d3

Browse files
Add an interactive publish step for the release pipeline (#317)
We'll now be able to upload to PyPI directly from the pipeline, instead of having to download the wheels locally and running twine. This will be much less error prone.
1 parent 008d4ce commit 368d8d3

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

pipelines/pipeline.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ parameters:
2525
displayName: Release Build
2626
type: boolean
2727
default: false
28+
- name: pypiTestUpload
29+
type: boolean
30+
default: false
2831

2932
# Uploads artifacts to blob storage to be ushered to network share. Generally this should only be enabled for main
3033
# and release branches.
@@ -155,3 +158,43 @@ stages:
155158
parameters:
156159
emailTo: ${{parameters.emailTo}}
157160
enableTests: ${{parameters.enableTests}}
161+
162+
- stage: publishStage
163+
displayName: Publish
164+
pool: DirectML_TF2_Windows_Pool
165+
jobs:
166+
- job: waitForValidation
167+
pool: server
168+
displayName: Wait for external validation
169+
timeoutInMinutes: 1440 # job times out in 1 day
170+
steps:
171+
- task: ManualValidation@0
172+
inputs:
173+
notifyUsers: |
174+
$(emailTo)
175+
instructions: 'If the test results look good, resume the pipeline to publish to PyPI'
176+
onTimeout: 'resume'
177+
- job: publish
178+
displayName: Publish
179+
dependsOn: waitForValidation
180+
steps:
181+
- ${{each artifact in parameters.buildArtifacts}}:
182+
- download: 'current'
183+
artifact: ${{artifact}}
184+
displayName: Download ${{artifact}}
185+
- powershell: |
186+
New-Item $(Build.ArtifactStagingDirectory)/pypi -ItemType Directory
187+
Copy-Item $(Pipeline.Workspace)/x64-linux-release-cp*/*.whl $(Build.ArtifactStagingDirectory)/pypi -Force
188+
Copy-Item $(Pipeline.Workspace)/x64-win-release-cp*/*.whl $(Build.ArtifactStagingDirectory)/pypi -Force
189+
190+
pip install twine
191+
if ("${{parameters.pypiTestUpload}}" -eq "True")
192+
{
193+
twine upload --repository-url https://test.pypi.org/legacy/ --username="__token__" --password="$(pypiTestToken)" $(Build.ArtifactStagingDirectory)/pypi/*.whl
194+
}
195+
else
196+
{
197+
twine upload --username="__token__" --password="$(pypiToken)" $(Build.ArtifactStagingDirectory)/pypi/*.whl
198+
}
199+
displayName: Upload wheels to PyPI
200+
condition: and(succeeded(), startsWith(variables['build.sourceBranch'], 'refs/heads/release/'))

0 commit comments

Comments
 (0)