@@ -19,6 +19,10 @@ parameters:
19
19
displayName : ' Publish proxy module to PowerShell gallery'
20
20
type : boolean
21
21
default : false
22
+ - name : ReleaseEnvironment
23
+ displayName : ' Release environment'
24
+ type : string
25
+ default : ' Production'
22
26
23
27
variables :
24
28
BuildConfiguration : Release
@@ -36,10 +40,6 @@ resources:
36
40
name : OneBranch.Pipelines/GovernedTemplates
37
41
ref : refs/heads/main
38
42
39
- pipelines :
40
- - pipeline : PSPackagesOfficial
41
- source : ' PowerShell-Packages-Official'
42
-
43
43
extends :
44
44
# https://aka.ms/obpipelines/templates
45
45
template : v2/OneBranch.Official.CrossPlat.yml@templates
@@ -62,6 +62,10 @@ extends:
62
62
- stage : build
63
63
jobs :
64
64
- job : main
65
+ templateContext :
66
+ sdl :
67
+ codeSignValidation :
68
+ targetPathExclusionPattern : \"^(?!.*\\.nupkg$).*\"
65
69
displayName : Build package
66
70
pool :
67
71
type : windows
@@ -100,6 +104,18 @@ extends:
100
104
Install-Module -Repository CFS -Name Microsoft.PowerShell.PSResourceGet -MinimumVersion 1.0.5
101
105
.\build.ps1 -clean -Build -BuildConfiguration Release -BuildFramework netstandard2.0
102
106
displayName: Build
107
+ # Add signing for all files for now.
108
+ - task : onebranch.pipeline.signing@1
109
+ displayName : Sign 1st-party files
110
+ inputs :
111
+ command : sign
112
+ signing_profile : external_distribution
113
+ search_root : $(Build.SourcesDirectory)/out
114
+ files_to_sign : |
115
+ **/*.psd1;
116
+ **/*.ps1xml;
117
+ **/*.psm1;
118
+ **/Microsoft.PowerShell.*.dll;
103
119
- pwsh : |
104
120
Get-ChildItem | Write-Verbose -Verbose
105
121
Write-Verbose -Verbose -Message "Install Microsoft.PowerShell.ThreadJob module"
@@ -126,38 +142,20 @@ extends:
126
142
}
127
143
Get-ChildItem -Path $(ob_outputDirectory) -Recurse -File -Name | Write-Verbose -Verbose
128
144
displayName: Upload Signed Nupkgs
129
- - stage : manual
130
- dependsOn : build
131
- jobs :
132
- - job : validation
133
- displayName : Manual validation
134
- pool :
135
- type : agentless
136
- timeoutInMinutes : 1440
137
- steps :
138
- - task : ManualValidation@0
139
- displayName : Wait 24 hours for validation
140
- inputs :
141
- notifyUsers : $(Build.RequestedForEmail)
142
- instructions : Please validate the release and then publish it!
143
- timeoutInMinutes : 1440
144
145
- stage : release_official_MicrosoftPowerShellThreadJob_module
145
146
displayName : release official
146
147
variables :
147
- ob_release_environment : Production
148
+ ob_release_environment : ${{ parameters.ReleaseEnvironment }}
148
149
drop : $(Pipeline.Workspace)/drop_build_main
149
150
version : $[ stageDependencies.build.main.outputs['package.version'] ]
150
- dependsOn : [build, manual ]
151
+ dependsOn : [build]
151
152
condition : ${{ parameters.publishOfficialToPowerShellGallery }}
152
153
jobs :
153
154
- job : publish
154
155
templateContext :
155
156
inputs :
156
157
- input : pipelineArtifact
157
158
artifactName : drop_build_main
158
- - input : pipelineArtifact
159
- pipeline : PSPackagesOfficial
160
- artifactName : drop_upload_upload_packages
161
159
displayName : Publish to PowerShell Gallery
162
160
pool :
163
161
type : release
@@ -167,61 +165,31 @@ extends:
167
165
steps :
168
166
- task : PowerShell@2
169
167
inputs :
170
- targetType : inline
168
+ targetType : ' inline'
171
169
script : |
172
- $localInstallerPath = Get-ChildItem -Path "$(Pipeline.Workspace)/GitHubPackages" -Filter '*win-x64.msi' | Select-Object -First 1 -ExpandProperty FullName
173
- if (Test-Path -Path $localInstallerPath) {
174
- Write-Verbose -Verbose "Installer found at $localInstallerPath"
175
- } else {
176
- throw "Installer not found"
177
- }
178
- Write-Verbose -Verbose "Installing PowerShell via msiexec"
179
- Start-Process -FilePath msiexec -ArgumentList "/package $localInstallerPath /quiet REGISTER_MANIFEST=1" -Wait -NoNewWindow
180
- $pwshPath = Get-ChildItem -Directory -Path 'C:\Program Files\PowerShell\7*' | Select-Object -First 1 -ExpandProperty FullName
181
- if (Test-Path -Path $pwshPath) {
182
- Write-Verbose -Verbose "PowerShell installed at $pwshPath"
183
- Write-Verbose -Verbose "Adding pwsh to env:PATH"
184
- Write-Host "##vso[task.prependpath]$pwshPath"
185
- } else {
186
- throw "PowerShell not installed"
187
- }
188
- displayName : Install pwsh 7
189
- - task : PowerShell@2
190
- inputs :
191
- targetType : inline
192
- pwsh : true
193
- script : |
194
- Write-Verbose -Verbose "Pwsh 7 Installed"
195
- Write-Verbose -Verbose "env:Path: "
196
- $env:PATH -split ';' | ForEach-Object {
197
- Write-Verbose -Verbose $_
198
- }
199
- displayName : Check pwsh 7 installation
200
- - task : Powershell@2
170
+ Get-ChildItem "$(Pipeline.Workspace)/" -Recurse | Write-Verbose -Verbose
171
+ displayName : Find Nupkg
172
+ - task : NuGetCommand@2
173
+ displayName : Push Official ThreadJob module to PSGallery
201
174
inputs :
202
- pwsh : true
203
- targetType : inline
204
- script : |
205
- Write-Verbose -Verbose -Message "Publish module to PSGallery"
206
- Publish-PSResource -ApiKey $(GalleryKey) -Repository PSGallery -Path $(Pipeline.Workspace)/Microsoft.PowerShell.ThreadJob.($version).nupkg
207
- displayName : Publish to PowerShell Gallery
175
+ command : push
176
+ packagesToPush : ' $(Pipeline.Workspace)/Microsoft.PowerShell.ThreadJob.$(version).nupkg'
177
+ nuGetFeedType : external
178
+ publishFeedCredentials : ' PSThreadJob-PSGalleryPush'
208
179
- stage : release_proxy_ThreadJob_module
209
180
displayName : release proxy
210
181
variables :
211
- ob_release_environment : Production
182
+ ob_release_environment : ${{ parameters.ReleaseEnvironment }}
212
183
drop : $(Pipeline.Workspace)/drop_build_main
213
184
version : $[ stageDependencies.build.main.outputs['package.proxyVersion'] ]
214
- dependsOn : [build, manual ]
185
+ dependsOn : [build]
215
186
condition : ${{ parameters.publishProxyToPowerShellGallery }}
216
187
jobs :
217
188
- job : publish
218
189
templateContext :
219
190
inputs :
220
191
- input : pipelineArtifact
221
192
artifactName : drop_build_main
222
- - input : pipelineArtifact
223
- pipeline : PSPackagesOfficial
224
- artifactName : drop_upload_upload_packages
225
193
displayName : Publish to PowerShell Gallery
226
194
pool :
227
195
type : release
@@ -231,46 +199,15 @@ extends:
231
199
steps :
232
200
- task : PowerShell@2
233
201
inputs :
234
- targetType : inline
202
+ targetType : ' inline'
235
203
script : |
236
- $localInstallerPath = Get-ChildItem -Path "$(Pipeline.Workspace)/GitHubPackages" -Filter '*win-x64.msi' | Select-Object -First 1 -ExpandProperty FullName
237
- if (Test-Path -Path $localInstallerPath) {
238
- Write-Verbose -Verbose "Installer found at $localInstallerPath"
239
- } else {
240
- throw "Installer not found"
241
- }
242
- Write-Verbose -Verbose "Installing PowerShell via msiexec"
243
- Start-Process -FilePath msiexec -ArgumentList "/package $localInstallerPath /quiet REGISTER_MANIFEST=1" -Wait -NoNewWindow
244
- $pwshPath = Get-ChildItem -Directory -Path 'C:\Program Files\PowerShell\7*' | Select-Object -First 1 -ExpandProperty FullName
245
- if (Test-Path -Path $pwshPath) {
246
- Write-Verbose -Verbose "PowerShell installed at $pwshPath"
247
- Write-Verbose -Verbose "Adding pwsh to env:PATH"
248
- Write-Host "##vso[task.prependpath]$pwshPath"
249
- } else {
250
- throw "PowerShell not installed"
251
- }
252
- displayName : Install pwsh 7
253
- - task : PowerShell@2
204
+ Get-ChildItem "$(Pipeline.Workspace)/" -Recurse | Write-Verbose -Verbose
205
+ displayName : Find Nupkg
206
+ - task : NuGetCommand@2
207
+ displayName : Push Proxy ThreadJob module to PSGallery
254
208
inputs :
255
- targetType : inline
256
- pwsh : true
257
- script : |
258
- Write-Verbose -Verbose "Pwsh 7 Installed"
259
- Write-Verbose -Verbose "env:Path: "
260
- $env:PATH -split ';' | ForEach-Object {
261
- Write-Verbose -Verbose $_
262
- }
263
- displayName : Check pwsh 7 installation
264
- - task : Powershell@2
265
- inputs :
266
- pwsh : true
267
- targetType : inline
268
- script : |
269
- Write-Verbose -Verbose -Message "Install Microsoft.PowerShell.ThreadJob module"
270
- Copy-Item -Path $(Pipeline.Workspace)/Microsoft.PowerShell.ThreadJob -Destination ($env:PSModulePath -split ';')[0] -Recurse -Force -Verbose
271
- Write-Verbose -Verbose -Message "Test ThreadJob module manifest"
272
- Test-ModuleManifest -Path $(Pipeline.Workspace)/ThreadJob/ThreadJob.psd1
273
- Write-Verbose -Verbose -Message "Publish module to PSGallery"
274
- Publish-PSResource -ApiKey $(GalleryKey) -Repository PSGallery -Path $(Pipeline.Workspace)/ThreadJob
275
- displayName : Publish to PowerShell Gallery
209
+ command : push
210
+ packagesToPush : ' $(Pipeline.Workspace)/ThreadJob.$(version).nupkg'
211
+ nuGetFeedType : external
212
+ publishFeedCredentials : ' PSThreadJob-PSGalleryPush'
276
213
0 commit comments