@@ -97,14 +97,27 @@ stages:
97
97
**\*.psm1
98
98
useMinimatch : true
99
99
100
- # finally publish the parts of the build which will be used in the next stages
101
- # if it's not published, the subsequent stages will not be able to access it.
102
- - publish : " $(Build.SourcesDirectory)/OSS_Microsoft_CompatPowerShellGet"
103
- artifact : build
104
- displayName : publish build directory
100
+ # Register local folder as PSRepository
101
+ # Then publish-module to that folder
102
+ - pwsh : |
103
+ $localRepo = "$(Build.SourcesDirectory)/local"
104
+ New-Item -Path $localRepo -ItemType Directory -Force
105
+ $vstsCommandString = "vso[task.setvariable variable=localRepo]${localRepo}"
106
+ Write-Host "local repo is: " + $vstsCommandString
107
+ Write-Host "##$vstsCommandString"
108
+
109
+ Register-PSRepository -Name local -SourceLocation $(localRepo)
110
+ Publish-Module -Path $(signOutPath) -Repository local
111
+ displayName: Publish module to local repository
112
+
113
+ - pwsh : |
114
+ $nupkgPath = "$(localRepo)"
115
+ $artifactName = "CompatPowerShellGet"
116
+ Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$nupkgPath"
117
+ displayName: Upload module artifact
105
118
106
119
# Now on to the compliance stage
107
- - stage : compliance
120
+ - stage : Compliance
108
121
displayName : Compliance
109
122
dependsOn : Build
110
123
jobs :
@@ -133,3 +146,39 @@ stages:
133
146
codeBaseName : ' CompatPowerShellGet_20200201'
134
147
# selections
135
148
APIScan : false # set to false when not using Windows APIs.
149
+
150
+ stages :
151
+ - stage : Publish
152
+ displayName : Publish
153
+ dependsOn : Compliance
154
+ pool :
155
+ name : 1ES
156
+ demands :
157
+ - ImageOverride -equals PSMMS2019-Secure
158
+ jobs :
159
+ - job : Publish_Job
160
+ displayName : Build Microsoft.PowerShell.CompatPowerShellGet
161
+ steps :
162
+ - checkout : self
163
+
164
+ - task : DownloadPipelineArtifact@2
165
+ displayName : ' Download PowerShellGet module artifacts'
166
+ inputs :
167
+ artifact : CompatPowerShellGet
168
+ patterns : ' **/*.nupkg'
169
+ downloadPath : ' $(Pipeline.Workspace)/nuget'
170
+
171
+ - pwsh : |
172
+ $package = (Get-ChildItem '$(Pipeline.Workspace)/nuget/CompatPowerShellGet.*.nupkg').FullName
173
+ $vstsCommandString = "vso[task.setvariable variable=NugetPkgPath]${package}"
174
+ Write-Host "sending " + $vstsCommandString
175
+ Write-Host "##$vstsCommandString"
176
+ displayName: 'Capture PowerShellGet module NuGet package path and set environment variable'
177
+
178
+ - task : NuGetCommand@2
179
+ displayName : ' Push CompatPowerShellGet module artifacts to PSGallery feed'
180
+ inputs :
181
+ command : push
182
+ packagesToPush : ' $(NugetPkgPath)'
183
+ nuGetFeedType : external
184
+ publishFeedCredentials : PSGalleryPush
0 commit comments