Skip to content

Commit 32fbd5d

Browse files
committed
ci: 🔧Replace nuget publish condition with environment 'Publish'
This is safer, since no PR can modify the condition. Instead the approvals whether to publish or not is controlled by envirnoment, configured in Azure DevOps.
1 parent 41b90d3 commit 32fbd5d

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed

azure-pipelines.yml

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -99,32 +99,35 @@ stages:
9999

100100
- stage: Publish
101101
dependsOn: Build
102-
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
103102
jobs:
104-
- job: Publish
103+
- deployment: Publish
105104
displayName: Publish nugets
106-
steps:
107-
- task: DownloadPipelineArtifact@2
108-
displayName: Download nugets from pipeline
109-
inputs:
110-
buildType: 'current'
111-
artifactName: 'nugets'
112-
targetPath: '$(Build.ArtifactStagingDirectory)'
113-
114-
- task: Bash@3
115-
displayName: 'Push to nuget.org'
116-
env:
117-
NUGET_ORG_APIKEY: '$(NUGET_ORG_APIKEY)'
118-
inputs:
119-
targetType: 'inline'
120-
script: 'dotnet nuget push "*.nupkg" --skip-duplicate --api-key $NUGET_ORG_APIKEY --source https://api.nuget.org/v3/index.json'
121-
workingDirectory: '$(Build.ArtifactStagingDirectory)'
122-
123-
- task: NuGetCommand@2
124-
displayName: Push to internal NuGet feed
125-
inputs:
126-
command: 'push'
127-
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg'
128-
nuGetFeedType: 'internal'
129-
publishVstsFeed: 'fee4c64f-3e49-4618-9ea4-5a3167257c37/989275f4-a952-4abd-ae82-2e7a0cb97b9b'
130-
allowPackageConflicts: true
105+
environment: 'Publish'
106+
strategy:
107+
runOnce:
108+
deploy:
109+
steps:
110+
- task: DownloadPipelineArtifact@2
111+
displayName: Download nugets from pipeline
112+
inputs:
113+
buildType: 'current'
114+
artifactName: 'nugets'
115+
targetPath: '$(Build.ArtifactStagingDirectory)'
116+
117+
- task: Bash@3
118+
displayName: 'Push to nuget.org'
119+
env:
120+
NUGET_ORG_APIKEY: '$(NUGET_ORG_APIKEY)'
121+
inputs:
122+
targetType: 'inline'
123+
script: 'dotnet nuget push "*.nupkg" --skip-duplicate --api-key $NUGET_ORG_APIKEY --source https://api.nuget.org/v3/index.json'
124+
workingDirectory: '$(Build.ArtifactStagingDirectory)'
125+
126+
- task: NuGetCommand@2
127+
displayName: Push to internal NuGet feed
128+
inputs:
129+
command: 'push'
130+
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg'
131+
nuGetFeedType: 'internal'
132+
publishVstsFeed: 'fee4c64f-3e49-4618-9ea4-5a3167257c37/989275f4-a952-4abd-ae82-2e7a0cb97b9b'
133+
allowPackageConflicts: true

0 commit comments

Comments
 (0)