Skip to content

Commit ad5ba02

Browse files
committed
Allow of multiple channels
1 parent d816844 commit ad5ba02

File tree

1 file changed

+147
-56
lines changed

1 file changed

+147
-56
lines changed

.pipelines/templates/package-create-msix.yml

Lines changed: 147 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ jobs:
130130
$IsStable = '$(ChannelSelection.IsStable)' -eq 'true'
131131
$IsPreview = '$(ChannelSelection.IsPreview)' -eq 'true'
132132
133+
Write-Host "##vso[task.setvariable variable=IsLTS]$IsLTS"
134+
Write-Host "##vso[task.setvariable variable=IsStable]$IsStable"
135+
Write-Host "##vso[task.setvariable variable=IsPreview]$IsPreview"
136+
133137
Write-Verbose -Verbose "Channel Selection - LTS: $IsLTS, Stable: $IsStable, Preview: $IsPreview"
134138
135139
# Define app configurations for each channel
@@ -138,100 +142,187 @@ jobs:
138142
AppStoreName = 'PowerShell-LTS'
139143
ProductId = '$(productId-LTS)'
140144
ServiceEndpoint = "StoreAppPublish-Stable"
145+
PDPFolder = 'PDP-LTS'
146+
SBConfigFile = 'SBConfig-LTS.json'
141147
}
142148
'Stable' = @{
143149
AppStoreName = 'PowerShell'
144150
ProductId = '$(productId-Stable)'
145151
ServiceEndpoint = "StoreAppPublish-Stable"
152+
PDPFolder = 'PDP-Stable'
153+
SBConfigFile = 'SBConfig-Stable.json'
146154
}
147155
'Preview' = @{
148156
AppStoreName = 'PowerShell (Preview)'
149157
ProductId = '$(productId-Preview)'
150158
ServiceEndpoint = "StoreAppPublish-Preview"
159+
PDPFolder = 'PDP-Preview'
160+
SBConfigFile = 'SBConfig-Preview.json'
151161
}
152162
}
153163
154-
$currentChannel = if ($IsLTS) { 'LTS' }
155-
elseif ($IsStable) { 'Stable' }
156-
elseif ($IsPreview) { 'Preview' }
157-
else {
158-
Write-Error "No valid channel detected"
164+
# Determine active channels
165+
$activeChannels = @()
166+
if ($IsLTS) { $activeChannels += 'LTS' }
167+
if ($IsStable) { $activeChannels += 'Stable' }
168+
if ($IsPreview) { $activeChannels += 'Preview' }
169+
170+
if ($activeChannels.Count -eq 0) {
171+
Write-Error "No valid channel detected"
172+
exit 1
173+
}
174+
175+
Write-Verbose -Verbose "Active channels: $($activeChannels -join ', ')"
176+
177+
$basePDPPath = '$(System.DefaultWorkingDirectory)/PowerShell/.pipelines/store/PDP/PDP'
178+
$baseSBConfigPath = '$(System.DefaultWorkingDirectory)/PowerShell/.pipelines/store/SBConfig.json'
179+
$storeConfigDir = '$(System.DefaultWorkingDirectory)/PowerShell/.pipelines/store'
180+
181+
$channelMetadata = @()
182+
foreach ($channel in $activeChannels) {
183+
$config = $channelConfigs[$channel]
184+
Write-Verbose -Verbose "Processing channel: $channel"
185+
Write-Verbose -Verbose " App Store Name: $($config.AppStoreName)"
186+
Write-Verbose -Verbose " Product ID: $($config.ProductId)"
187+
188+
# Create channel-specific PDP folder
189+
$channelPDPPath = "$storeConfigDir/$($config.PDPFolder)"
190+
if (!(Test-Path $channelPDPPath)) {
191+
Write-Verbose -Verbose "Creating PDP folder: $channelPDPPath"
192+
New-Item -ItemType Directory -Path $channelPDPPath -Force | Out-Null
193+
194+
if (Test-Path $basePDPPath) {
195+
Copy-Item -Path "$basePDPPath\*" -Destination $channelPDPPath -Recurse -Force
196+
Write-Verbose -Verbose "Copied base PDP to: $channelPDPPath"
197+
}
198+
}
199+
200+
# Update channel-specific PDP.xml file
201+
$channelPDPFile = "$channelPDPPath/en-US/PDP.xml"
202+
if (Test-Path $channelPDPFile) {
203+
Write-Verbose -Verbose "Updating PDP file: $channelPDPFile"
204+
[xml]$pdpXml = Get-Content $channelPDPFile -Raw
205+
$appStoreNameElement = $pdpXml.SelectSingleNode("//AppStoreName[@_locID]")
206+
207+
if ($appStoreNameElement) {
208+
$appStoreNameElement.InnerText = $config.AppStoreName
209+
Write-Verbose -Verbose "Updated AppStoreName to: $($config.AppStoreName)"
210+
} else {
211+
Write-Warning "AppStoreName element not found in PDP file for $channel"
212+
}
213+
214+
$pdpXml.Save($channelPDPFile)
215+
Write-Verbose -Verbose "PDP file updated for $channel"
216+
if ($IsLTS) {
217+
Write-Host "##vso[task.setvariable variable=PDP-LTS]$channelPDPPath"
218+
} elseif ($IsStable) {
219+
Write-Host "##vso[task.setvariable variable=PDP-Stable]$channelPDPPath"
220+
} elseif ($IsPreview) {
221+
Write-Host "##vso[task.setvariable variable=PDP-Preview]$channelPDPPath"
222+
}
223+
} else {
224+
Write-Error "PDP file not found: $channelPDPFile"
159225
exit 1
160226
}
161-
162-
$config = $channelConfigs[$currentChannel]
163-
Write-Verbose -Verbose "Selected channel: $currentChannel"
164-
Write-Verbose -Verbose "App Store Name: $($config.AppStoreName)"
165-
Write-Verbose -Verbose "Product ID: $($config.ProductId)"
166-
167-
# Update PDP.xml file
168-
$pdpPath = '$(System.DefaultWorkingDirectory)/PowerShell/.pipelines/store/PDP/PDP/en-US/PDP.xml'
169-
if (Test-Path $pdpPath) {
170-
Write-Verbose -Verbose "Updating PDP file: $pdpPath"
171-
172-
[xml]$pdpXml = Get-Content $pdpPath -Raw
173-
174-
$appStoreNameElement = $pdpXml.SelectSingleNode("//AppStoreName[@_locID]")
175-
if ($appStoreNameElement) {
176-
$appStoreNameElement.InnerText = $config.AppStoreName
177-
Write-Verbose -Verbose "Updated AppStoreName to: $($config.AppStoreName)"
227+
228+
# Create channel-specific SBConfig.json file
229+
$channelSBConfigPath = "$storeConfigDir/$($config.SBConfigFile)"
230+
if (Test-Path $baseSBConfigPath) {
231+
Write-Verbose -Verbose "Creating SBConfig file: $channelSBConfigPath"
232+
233+
$sbConfigJson = Get-Content $baseSBConfigPath -Raw | ConvertFrom-Json
234+
$sbConfigJson.appSubmission.productId = $config.ProductId
235+
Write-Verbose -Verbose "Updated productId to: $($config.ProductId)"
236+
237+
$sbConfigJson | ConvertTo-Json -Depth 100 | Set-Content $channelSBConfigPath -Encoding UTF8
238+
Write-Verbose -Verbose "SBConfig file created for $channel"
239+
if ($IsLTS) {
240+
Write-Host "##vso[task.setvariable variable=SBConfigPath-LTS]$channelSBConfigPath"
241+
} elseif ($IsStable) {
242+
Write-Host "##vso[task.setvariable variable=SBConfigPath-Stable]$channelSBConfigPath"
243+
} elseif ($IsPreview) {
244+
Write-Host "##vso[task.setvariable variable=SBConfigPath-Preview]$channelSBConfigPath"
245+
}
178246
} else {
179-
Write-Warning "AppStoreName element not found in PDP file"
247+
Write-Error "Base SBConfig file not found: $baseSBConfigPath"
248+
exit 1
249+
}
250+
251+
if ($IsLTS) {
252+
Write-Host "##vso[task.setvariable variable=ServiceConnection-LTS]$config.ServiceEndpoint"
253+
} elseif ($IsStable) {
254+
Write-Host "##vso[task.setvariable variable=ServiceConnection-Stable]$config.ServiceEndpoint"
255+
} elseif ($IsPreview) {
256+
Write-Host "##vso[task.setvariable variable=ServiceConnection-Preview]$config.ServiceEndpoint"
180257
}
181-
182-
$pdpXml.Save($pdpPath)
183-
Write-Verbose -Verbose "PDP file updated successfully"
184-
} else {
185-
Write-Error "PDP file not found: $pdpPath"
186-
exit 1
187258
}
188-
189-
# Update SBConfig.json file
190-
$sbConfigPath = '$(System.DefaultWorkingDirectory)/PowerShell/.pipelines/store/SBConfig.json'
191-
if (Test-Path $sbConfigPath) {
192-
Write-Verbose -Verbose "Updating SBConfig file: $sbConfigPath"
193-
194-
$sbConfigJson = Get-Content $sbConfigPath -Raw | ConvertFrom-Json
195-
196-
$sbConfigJson.appSubmission.productId = $config.ProductId
197-
Write-Verbose -Verbose "Updated productId to: $($config.ProductId)"
198-
199-
$sbConfigJson | ConvertTo-Json -Depth 100 | Set-Content $sbConfigPath -Encoding UTF8
200-
Write-Verbose -Verbose "SBConfig file updated successfully"
201-
} else {
202-
Write-Error "SBConfig file not found: $sbConfigPath"
203-
exit 1
259+
260+
# Write channel metadata to artifact for cross-pipeline access
261+
$metadata = @{
262+
ActiveChannels = $activeChannels
204263
}
205-
206-
Write-Host "##vso[task.setvariable variable=ServiceConnection]$($config.ServiceEndpoint)"
207-
Write-Host "##vso[task.setvariable variable=SBConfigPath]$($config.SBConfigPath)"
264+
265+
# Set pipeline variables (using the first active channel for backward compatibility)
266+
$primaryChannel = $activeChannels[0]
267+
$primaryConfig = $channelConfigs[$primaryChannel]
268+
$primaryChannelMeta = $channelMetadata | Where-Object { $_.Channel -eq $primaryChannel }
269+
270+
Write-Host "##vso[task.setvariable variable=ServiceConnection]$($primaryConfig.ServiceEndpoint)"
271+
Write-Host "##vso[task.setvariable variable=SBConfigPath]$($primaryChannelMeta.SBConfigPath)"
272+
Write-Host "##vso[task.setvariable variable=ActiveChannels]$($activeChannels -join ',')"
273+
Write-Host "##vso[task.setvariable variable=PrimaryChannel]$primaryChannel"
274+
275+
Write-Verbose -Verbose "Pipeline variables set for primary channel: $primaryChannel"
208276
name: UpdateConfigs
209277
displayName: Update PDPs and SBConfig.json
210278

211279
- task: MS-RDX-MRO.windows-store-publish-dev.package-task.store-package@3
212280
displayName: 'Create StoreBroker Package'
281+
condition: $(IsLTS)
213282
inputs:
214-
serviceEndpoint: '$(ServiceConnection)'
215-
sbConfigPath: '$(SBConfigPath)'
283+
serviceEndpoint: '$(ServiceConnection-LTS)'
284+
sbConfigPath: '$(SBConfigPath-LTS)'
216285
sourceFolder: '$(BundleDir)'
217286
contents: '*.msixBundle'
218-
outSBName: 'PowerShellStorePackage'
219-
pdpPath: '$(System.DefaultWorkingDirectory)/PowerShell/.pipelines/store/PDP/PDP'
287+
outSBName: 'PowerShellStorePackage-LTS'
288+
pdpPath: '$(PDP-LTS)'
220289
pdpMediaPath: '$(System.DefaultWorkingDirectory)/PowerShell/.pipelines/store/PDP/PDP-Media'
221-
290+
291+
- task: MS-RDX-MRO.windows-store-publish-dev.package-task.store-package@3
292+
displayName: 'Create StoreBroker Package'
293+
condition: $(IsStable)
294+
inputs:
295+
serviceEndpoint: '$(ServiceConnection-Stable)'
296+
sbConfigPath: '$(SBConfigPath-Stable)'
297+
sourceFolder: '$(BundleDir)'
298+
contents: '*.msixBundle'
299+
outSBName: 'PowerShellStorePackage-Stable'
300+
pdpPath: '$(PDP-Stable)'
301+
pdpMediaPath: '$(System.DefaultWorkingDirectory)/PowerShell/.pipelines/store/PDP/PDP-Media'
302+
303+
- task: MS-RDX-MRO.windows-store-publish-dev.package-task.store-package@3
304+
displayName: 'Create StoreBroker Package'
305+
condition: $(IsPreview)
306+
inputs:
307+
serviceEndpoint: '$(ServiceConnection-Preview)'
308+
sbConfigPath: '$(SBConfigPath-Preview)'
309+
sourceFolder: '$(BundleDir)'
310+
contents: '*.msixBundle'
311+
outSBName: 'PowerShellStorePackage-Preview'
312+
pdpPath: '$(PDP-Preview)'
313+
pdpMediaPath: '$(System.DefaultWorkingDirectory)/PowerShell/.pipelines/store/PDP/PDP-Media'
314+
222315
- pwsh: |
223316
$submissionPackageDir = "$(System.DefaultWorkingDirectory)/SBOutDir"
224317
$jsonFile = "$submissionPackageDir/PowerShellStorePackage.json"
225318
$zipFile = "$submissionPackageDir/PowerShellStorePackage.zip"
226319
227320
if ((Test-Path $jsonFile) -and (Test-Path $zipFile)) {
228321
Write-Verbose -Verbose "Uploading StoreBroker Package files:"
229-
Write-Verbose -Verbose "JSON File: $jsonFile"
230-
Write-Verbose -Verbose "ZIP File: $zipFile"
322+
Get-ChildItem -Path $submissionPackageDir | Write-Verbose -Verbose
231323
232324
Copy-Item -Path $submissionPackageDir -Destination "$(ob_outputDirectory)" -Verbose -Recurse
233325
}
234-
235326
else {
236327
Write-Error "Required files not found in $submissionPackageDir"
237328
}

0 commit comments

Comments
 (0)