@@ -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