Skip to content

Commit dc0c5da

Browse files
committed
Update azure-pipelines-publish-pypi.yml for Azure Pipelines
Correcting validation errors
1 parent 801f9a5 commit dc0c5da

File tree

1 file changed

+62
-38
lines changed

1 file changed

+62
-38
lines changed

.azurepipelines/azure-pipelines-publish-pypi.yml

Lines changed: 62 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,25 @@
44
name: 1ES-MSTICPy-Publish-$(date:yyyyMMdd)$(rev:.r)
55

66
parameters:
7-
Artifact: dist
8-
Feed: testpypi
7+
- name: Artifact
8+
type: string
9+
default: dist
10+
displayName: Directory to store the built artifacts
11+
- name: Feed
12+
type: string
13+
default: testpypi
14+
displayName: The feed to publish to
15+
values:
16+
- testpypi
17+
- pypi
918

1019
resources:
1120
repositories:
1221
- repository: msticpy
1322
name: microsoft/msticpy
14-
type: git
23+
type: github
1524
ref: main
25+
endpoint: Microsoft
1626
- repository: 1ESPipelineTemplates
1727
type: git
1828
name: 1ESPipelineTemplates/1ESPipelineTemplates
@@ -25,44 +35,58 @@ extends:
2535
name: MSSecurity-1ES-Build-Agents-Pool
2636
image: MSSecurity-1ES-Windows-2022
2737
os: windows
28-
variables:
29-
- name: DistDir
30-
value: $(Pipeline.Workspace)\${{ parameters.Artifact }}
31-
- name: TWINE_PASSWORD
32-
value: ${{ if eq(parameters.Feed, 'testpypi') }}${{ secrets.TEST_TWINE_PASSWORD }}${{ else }}${{ secrets.TWINE_PASSWORD }}
3338

34-
steps:
35-
- checkout: self
36-
37-
- task: UsePythonVersion@0
38-
inputs:
39-
versionSpec: '>=3.10'
40-
architecture: 'x64'
41-
displayName: 'Use latest Python'
39+
stages:
40+
- stage: publishTasks
41+
displayName: PublishTasks
42+
jobs:
43+
- job: publishJob
44+
displayName: PublishJob
45+
variables:
46+
- name: DistDir
47+
value: $(Pipeline.Workspace)\${{ parameters.Artifact }}
48+
steps:
49+
- checkout: self
50+
51+
- task: UsePythonVersion@0
52+
inputs:
53+
versionSpec: '>=3.10'
54+
architecture: 'x64'
55+
displayName: 'Use latest Python'
56+
57+
- powershell: python -m pip install --upgrade pip
58+
displayName: 'Upgrade pip'
59+
- powershell: python -m pip install --upgrade build twine
60+
displayName: 'Install build and twine'
61+
- powershell: python -m pip install --upgrade keyring artifacts-keyring
62+
displayName: 'Install keyring and artifacts-keyring'
4263

43-
- powershell: python -m pip install --upgrade pip
44-
displayName: 'Upgrade pip'
45-
- powershell: python -m pip install --upgrade build twine
46-
displayName: 'Install build and twine'
47-
- powershell: python -m pip install --upgrade keyring artifacts-keyring
48-
displayName: 'Install keyring and artifacts-keyring'
64+
- powershell: python -m build --sdist --wheel --outdir "$(DistDir)"
65+
displayName: 'Build package wheel and sdist'
4966

50-
- powershell: python -m build --sdist --wheel --outdir "$(DistDir)"
51-
displayName: 'Build package wheel and sdist'
67+
- task: PipAuthenticate@1
68+
inputs:
69+
artifactFeeds: 1ESToolsOrgFeed
70+
displayName: 'Authenticate pip for internal feed'
5271

53-
- task: PipAuthenticate@1
54-
inputs:
55-
artifactFeeds: 1ESToolsOrgFeed
56-
displayName: 'Authenticate pip for internal feed'
72+
- task: TwineAuthenticate@1
73+
inputs:
74+
artifactFeed: ${{ parameters.Feed }}
75+
displayName: 'Authenticate Twine for PyPI feed'
5776

58-
- task: TwineAuthenticate@1
59-
inputs:
60-
artifactFeed: ${{ parameters.Feed }}
61-
displayName: 'Authenticate Twine for PyPI feed'
77+
- powershell: python -m twine upload --skip-existing --verbose "$(DistDir)/*"
78+
condition: eq('${{ parameters.Feed }}', 'testpypi')
79+
displayName: 'Push to PyPI Test feed'
80+
env:
81+
TWINE_REPOSITORY: ${{ parameters.Feed }}
82+
TWINE_USERNAME: __token__
83+
TWINE_PASSWORD: $(TEST_TWINE_PASSWORD)
6284

63-
- powershell: python -m twine upload --skip-existing --verbose "$(DistDir)/*"
64-
displayName: 'Push to PyPI feed'
65-
env:
66-
TWINE_REPOSITORY: ${{ parameters.Feed }}
67-
TWINE_USERNAME: __token__
68-
TWINE_PASSWORD: $(TWINE_PASSWORD)
85+
- powershell: python -m twine upload --skip-existing --verbose "$(DistDir)/*"
86+
condition: eq('${{ parameters.Feed }}', 'pypi')
87+
displayName: 'Push to PyPI Test feed'
88+
env:
89+
TWINE_REPOSITORY: ${{ parameters.Feed }}
90+
TWINE_USERNAME: __token__
91+
TWINE_PASSWORD: $(TWINE_PASSWORD)
92+
- powershell: echo Unrecognized feed "$( parameters.Feed )"

0 commit comments

Comments
 (0)