1- pool :
2- vmImage : ' windows-latest'
31
42parameters :
3+ - name : PublishPackage
4+ displayName : ' Confirm Publish Package to nuget'
5+ type : boolean
6+ default : false
57- name : pushEnvironment
6- displayName : ' Push to which environment? '
8+ displayName : ' Nuget Environment '
79 type : string
810 values :
9- - Test
10- - Production
11- default : Test
11+ - dev
12+ - prod
13+ default : dev
1214
13- # The build configuration is defined, in this case we are building Release packages
14- # Based on 'pushEnvironment' parameter, we set other variables and variable groups to use test vs prod settings
15- variables :
16- - name : buildConfiguration
17- value : ' Release'
18- - name : apiKey
19- ${{ if eq(parameters.pushEnvironment, 'Production') }} :
20- value : $(nuget-mock-solution-test-automation-api-key)
21- ${{ if ne(parameters.pushEnvironment, 'Production') }} :
22- value : $(int-nugettest-mock-solution-test-automation-api-key)
23- - name : nugetOrgSource
24- ${{ if eq(parameters.pushEnvironment, 'Production') }} :
25- value : ' https://api.nuget.org/v3/index.json'
26- ${{ if ne(parameters.pushEnvironment, 'Production') }} :
27- value : ' https://apiint.nugettest.org/v3/index.json'
28- - ${{ if eq(parameters.pushEnvironment, 'Production') }} :
29- - group : nuget_package_deployment
30- - ${{ if ne(parameters.pushEnvironment, 'Production') }} :
31- - group : int_nugettest_package_deployment
3215
3316# The github-ref-prefix should be either 'tags/' (for a tagged release) or 'heads/' (for a branch). Release number is either the tag name or branch name
3417# The standard release process would use a tagged release where the tag name is the version number (e.g 1.0.0) so prefix is default 'tags/' and release-number would be '1.0.0'
@@ -40,72 +23,100 @@ resources:
4023 endpoint : github.com_CDR-CI
4124 ref : refs/$(github-ref-prefix)$(release-number)
4225
43- # The build has 3 seperate tasks run under 1 step
44- steps :
45- - checkout : GitHubRepo
46- fetchDepth : 0
4726
48- # Build the project by running the dotnet command build, pointing to our csproj file
49- - task : DotNetCoreCLI@2
50- displayName : ' dotnet build'
51- inputs :
52- command : ' build'
53- versioningScheme : byBuildNumber
54- arguments : ' --configuration $(buildConfiguration) /p:UsingGitHubSource=true'
55- projects : ' $(System.DefaultWorkingDirectory)\Source\**\*.csproj'
27+ stages :
28+ - stage : ${{parameters.pushEnvironment}}
29+ variables :
30+ - group : nuget_package_deployment_${{parameters.pushEnvironment}}
31+ - group : nuget_package_deployment_certificate
32+ - name : buildConfiguration
33+ value : ' Release'
34+ - name : nuget-server-url
35+ ${{ if eq(parameters.pushEnvironment, 'prod') }} :
36+ value : ' https://api.nuget.org/v3/index.json'
37+ ${{ else }} :
38+ value : ' https://apiint.nugettest.org/v3/index.json'
39+
5640
57- # Create the package by running the dotnet pack command again pointing to the csproj file
58- # The nobuild means the project will not be compiled before running pack, because its already built in above step
59- - task : DotNetCoreCLI@2
60- displayName : " dotnet pack"
61- inputs :
62- command : ' pack'
63- configuration : $(BuildConfiguration)
64- packagesToPack : ' $(System.DefaultWorkingDirectory)\Source\**\*.csproj'
65- nobuild : true
66- versioningScheme : ' off'
67-
68- - task : PublishSymbols@2
69- displayName : Publish symbols path
70- continueOnError : True
71- inputs :
72- SearchPattern : ' **\bin\**\*.pdb'
73- PublishSymbols : false
74- SymbolServerType : TeamServices
41+ pool :
42+ vmImage : ' windows-latest'
43+ jobs :
44+ - job : deploy_${{parameters.pushEnvironment}}
45+
46+ # The build has 3 seperate tasks run under 1 step
47+ steps :
48+ - checkout : GitHubRepo
49+ fetchDepth : 0
7550
76- - task : DotNetCoreCLI@2
77- displayName : Install NuGetKeyVaultSignTool
78- inputs :
79- command : ' custom'
80- custom : ' tool'
81- arguments : ' install --tool-path . NuGetKeyVaultSignTool'
51+ # Build the project by running the dotnet command build, pointing to our csproj file
52+ - task : DotNetCoreCLI@2
53+ displayName : ' dotnet build'
54+ inputs :
55+ command : ' build'
56+ versioningScheme : byBuildNumber
57+ arguments : ' --configuration $(buildConfiguration) /p:UsingGitHubSource=true'
58+ projects : ' $(System.DefaultWorkingDirectory)\Source\**\*.csproj'
59+
60+ # Create the package by running the dotnet pack command again pointing to the csproj file
61+ # The nobuild means the project will not be compiled before running pack, because its already built in above step
62+ - task : DotNetCoreCLI@2
63+ displayName : " dotnet pack"
64+ inputs :
65+ command : ' pack'
66+ configuration : $(BuildConfiguration)
67+ packagesToPack : ' $(System.DefaultWorkingDirectory)\Source\**\*.csproj'
68+ nobuild : true
69+ versioningScheme : ' off'
70+
71+ - task : PublishSymbols@2
72+ displayName : Publish symbols path
73+ continueOnError : True
74+ inputs :
75+ SearchPattern : ' **\bin\**\*.pdb'
76+ PublishSymbols : false
77+ SymbolServerType : TeamServices
78+
79+ - task : DotNetCoreCLI@2
80+ displayName : Install NuGetKeyVaultSignTool
81+ inputs :
82+ command : ' custom'
83+ custom : ' tool'
84+ arguments : ' install --tool-path . NuGetKeyVaultSignTool'
8285
83- # WARNING: This will not throw an error if it can't find the file and will close silently (false positive)
84- - task : PowerShell@2
85- displayName : Signing with NuGetKeyVaultSignTool
86- inputs :
87- targetType : ' inline'
88- script : |
89- .\NuGetKeyVaultSignTool sign $(Build.ArtifactStagingDirectory)\*.nupkg `
90- --file-digest "sha256" `
91- --timestamp-rfc3161 "http://timestamp.digicert.com" `
92- --timestamp-digest "sha256" `
93- --azure-key-vault-url $(code-signing-kv-url) `
94- --azure-key-vault-tenant-id $(code-signing-kv-tenant-id) `
95- --azure-key-vault-client-id $(sp-code-signing-prod-client-id) `
96- --azure-key-vault-client-secret $(sp-code-signing-prod-client-secret) `
97- --azure-key-vault-certificate $(code-signing-cert-name)
86+ # WARNING: This will not throw an error if it can't find the file and will close silently (false positive)
87+ - task : PowerShell@2
88+ displayName : Signing with NuGetKeyVaultSignTool
89+ inputs :
90+ targetType : ' inline'
91+ script : |
92+ .\NuGetKeyVaultSignTool sign $(Build.ArtifactStagingDirectory)\*.nupkg `
93+ --file-digest "sha256" `
94+ --timestamp-rfc3161 "http://timestamp.digicert.com" `
95+ --timestamp-digest "sha256" `
96+ --azure-key-vault-url $(code-signing-kv-url) `
97+ --azure-key-vault-tenant-id $(code-signing-kv-tenant-id) `
98+ --azure-key-vault-client-id $(sp-code-signing-prod-client-id) `
99+ --azure-key-vault-client-secret $(sp-code-signing-prod-client-secret) `
100+ --azure-key-vault-certificate $(code-signing-cert-name)
101+
102+ # NOTE: Avoiding verifying with NuGetKeyVaultSignTool as it is rather faulty. Will give false positive for a file that doesn't exist.
103+ # Use dotnet nuget verify instead
104+ - task : PowerShell@2
105+ displayName : Verifying NuGetKeyVaultSign
106+ inputs :
107+ targetType : ' inline'
108+ script : ' dotnet nuget verify $(Build.ArtifactStagingDirectory)\*.nupkg'
98109
99- # NOTE: Avoiding verifying with NuGetKeyVaultSignTool as it is rather faulty. Will give false positive for a file that doesn't exist.
100- # Use dotnet nuget verify instead
101- - task : PowerShell@2
102- displayName : Verifying NuGetKeyVaultSign
103- inputs :
104- targetType : ' inline'
105- script : ' dotnet nuget verify $(Build.ArtifactStagingDirectory)\*.nupkg'
110+ - task : PowerShell@2
111+ displayName : ' Publishing to $(nuget-server-url)'
112+ condition : and(succeeded(), eq(${{parameters.PublishPackage}} , true))
113+ inputs :
114+ targetType : ' inline'
115+ script : ' dotnet nuget push $(Build.ArtifactStagingDirectory)\*.nupkg --api-key $(nuget-server-api-key) -n --source $(nuget-server-url)'
106116
107- - task : PowerShell@2
108- displayName : Publishing signed package
109- inputs :
110- targetType : ' inline'
111- script : ' dotnet nuget push $(Build.ArtifactStagingDirectory)\*.nupkg --api-key $(apiKey) -n --source $(nugetOrgSource)'
117+ - task : PublishPipelineArtifact@1
118+ displayName : Publish Signed Package
119+ condition : succeeded()
120+ inputs :
121+ path : $(Build.ArtifactStagingDirectory)
122+ artifact : mock-test-automation-solution
0 commit comments