@@ -19,6 +19,10 @@ parameters:
1919 displayName : ' Publish proxy module to PowerShell gallery'
2020 type : boolean
2121 default : false
22+ - name : ReleaseEnvironment
23+ displayName : ' Release environment'
24+ type : string
25+ default : ' Production'
2226
2327variables :
2428 BuildConfiguration : Release
@@ -36,10 +40,6 @@ resources:
3640 name : OneBranch.Pipelines/GovernedTemplates
3741 ref : refs/heads/main
3842
39- pipelines :
40- - pipeline : PSPackagesOfficial
41- source : ' PowerShell-Packages-Official'
42-
4343extends :
4444 # https://aka.ms/obpipelines/templates
4545 template : v2/OneBranch.Official.CrossPlat.yml@templates
@@ -62,6 +62,10 @@ extends:
6262 - stage : build
6363 jobs :
6464 - job : main
65+ templateContext :
66+ sdl :
67+ codeSignValidation :
68+ targetPathExclusionPattern : \"^(?!.*\\.nupkg$).*\"
6569 displayName : Build package
6670 pool :
6771 type : windows
@@ -100,6 +104,18 @@ extends:
100104 Install-Module -Repository CFS -Name Microsoft.PowerShell.PSResourceGet -MinimumVersion 1.0.5
101105 .\build.ps1 -clean -Build -BuildConfiguration Release -BuildFramework netstandard2.0
102106 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;
103119 - pwsh : |
104120 Get-ChildItem | Write-Verbose -Verbose
105121 Write-Verbose -Verbose -Message "Install Microsoft.PowerShell.ThreadJob module"
@@ -126,38 +142,20 @@ extends:
126142 }
127143 Get-ChildItem -Path $(ob_outputDirectory) -Recurse -File -Name | Write-Verbose -Verbose
128144 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
144145 - stage : release_official_MicrosoftPowerShellThreadJob_module
145146 displayName : release official
146147 variables :
147- ob_release_environment : Production
148+ ob_release_environment : ${{ parameters.ReleaseEnvironment }}
148149 drop : $(Pipeline.Workspace)/drop_build_main
149150 version : $[ stageDependencies.build.main.outputs['package.version'] ]
150- dependsOn : [build, manual ]
151+ dependsOn : [build]
151152 condition : ${{ parameters.publishOfficialToPowerShellGallery }}
152153 jobs :
153154 - job : publish
154155 templateContext :
155156 inputs :
156157 - input : pipelineArtifact
157158 artifactName : drop_build_main
158- - input : pipelineArtifact
159- pipeline : PSPackagesOfficial
160- artifactName : drop_upload_upload_packages
161159 displayName : Publish to PowerShell Gallery
162160 pool :
163161 type : release
@@ -167,61 +165,31 @@ extends:
167165 steps :
168166 - task : PowerShell@2
169167 inputs :
170- targetType : inline
168+ targetType : ' inline'
171169 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
201174 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'
208179 - stage : release_proxy_ThreadJob_module
209180 displayName : release proxy
210181 variables :
211- ob_release_environment : Production
182+ ob_release_environment : ${{ parameters.ReleaseEnvironment }}
212183 drop : $(Pipeline.Workspace)/drop_build_main
213184 version : $[ stageDependencies.build.main.outputs['package.proxyVersion'] ]
214- dependsOn : [build, manual ]
185+ dependsOn : [build]
215186 condition : ${{ parameters.publishProxyToPowerShellGallery }}
216187 jobs :
217188 - job : publish
218189 templateContext :
219190 inputs :
220191 - input : pipelineArtifact
221192 artifactName : drop_build_main
222- - input : pipelineArtifact
223- pipeline : PSPackagesOfficial
224- artifactName : drop_upload_upload_packages
225193 displayName : Publish to PowerShell Gallery
226194 pool :
227195 type : release
@@ -231,46 +199,15 @@ extends:
231199 steps :
232200 - task : PowerShell@2
233201 inputs :
234- targetType : inline
202+ targetType : ' inline'
235203 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
254208 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'
276213
0 commit comments