Skip to content

Commit 4886bd0

Browse files
authored
Merge pull request #1299 from SteveL-MSFT/pipeline-fix
Pipeline fix
2 parents 5e7b4a2 + ad0e860 commit 4886bd0

File tree

1 file changed

+123
-59
lines changed

1 file changed

+123
-59
lines changed

.pipelines/DSC-Official.yml

Lines changed: 123 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ parameters:
1111
- name: OfficialBuild
1212
type: boolean
1313
default: false
14+
- name: PublishToStore
15+
type: boolean
16+
default: false
1417

1518
variables:
1619
- name: BuildConfiguration
@@ -60,11 +63,12 @@ extends:
6063
forStages: [Build]
6164
credscan:
6265
enabled: true
63-
scanFolder: $(Build.SourcesDirectory)\DSC
66+
scanFolder: $(System.DefaultWorkingDirectory)
6467
binskim:
6568
enabled: true
6669
apiscan:
6770
enabled: false
71+
tsaOptionsFile: .config\tsaoptions.json
6872

6973
stages:
7074
- stage: BuildAndSign
@@ -77,15 +81,16 @@ extends:
7781
type: windows
7882
vmImage: windows-latest
7983
variables:
80-
repoRoot: $(Build.SourcesDirectory)\DSC
81-
ob_sdl_tsa_configFile: $(Build.SourcesDirectory)\DSC\.config\tsaoptions.json
84+
repoRoot: '$(System.DefaultWorkingDirectory)\DSC'
85+
ob_sdl_tsa_configFile: '$(System.DefaultWorkingDirectory)\.config\tsaoptions.json'
8286
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
8387
ob_sdl_sbom_enabled: false
8488
ob_signing_setup_enabled: false
8589
ob_sdl_codeql_compiled_enabled: false
8690
steps:
8791
- checkout: self
8892
- pwsh: |
93+
Write-Verbose -Verbose (Get-ChildItem '$(repoRoot)' | Out-String)
8994
$packageVersion = $(repoRoot)/build.ps1 -GetPackageVersion
9095
$vstsCommandString = "vso[task.setvariable variable=Version;isoutput=true]$packageVersion"
9196
Write-Host ("sending " + $vstsCommandString)
@@ -107,9 +112,9 @@ extends:
107112
- job: BuildWin_x64
108113
dependsOn: SetPackageVersion
109114
variables:
110-
ob_sdl_tsa_configFile: '$(Build.SourcesDirectory)\DSC\.config\tsaoptions.json'
115+
ob_sdl_tsa_configFile: '$(System.DefaultWorkingDirectory)\.config\tsaoptions.json'
111116
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
112-
signSrcPath: '$(Build.SourcesDirectory)\out'
117+
signSrcPath: '$(System.DefaultWorkingDirectory)\out'
113118
AzToken: $[ dependencies.SetPackageVersion.outputs['AzToken'] ]
114119
ob_sdl_sbom_enabled: true
115120
ob_signing_setup_enabled: true
@@ -128,9 +133,9 @@ extends:
128133
- job: BuildWin_arm64
129134
dependsOn: SetPackageVersion
130135
variables:
131-
ob_sdl_tsa_configFile: '$(Build.SourcesDirectory)\DSC\.config\tsaoptions.json'
136+
ob_sdl_tsa_configFile: '$(System.DefaultWorkingDirectory)\.config\tsaoptions.json'
132137
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
133-
signSrcPath: '$(Build.SourcesDirectory)\out'
138+
signSrcPath: '$(System.DefaultWorkingDirectory)\out'
134139
AzToken: $[ dependencies.SetPackageVersion.outputs['AzToken'] ]
135140
ob_sdl_sbom_enabled: true
136141
ob_signing_setup_enabled: true
@@ -152,9 +157,9 @@ extends:
152157
- BuildWin_arm64
153158
variables:
154159
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
155-
ob_sdl_tsa_configFile: '$(Build.SourcesDirectory)\DSC\.config\tsaoptions.json'
160+
ob_sdl_tsa_configFile: '$(System.DefaultWorkingDirectory)\.config\tsaoptions.json'
156161
ob_symbolsPublishing_enabled: true
157-
ob_symbolsPublishing_symbolsFolder: '$(Build.SourcesDirectory)\DSC\bin'
162+
ob_symbolsPublishing_symbolsFolder: '$(System.DefaultWorkingDirectory)\DSC\bin'
158163
ob_symbolsPublishing_searchPattern: '**/*.pdb'
159164
ob_symbolsPublishing_indexSources: true
160165
ob_sdl_sbom_enabled: false
@@ -172,12 +177,12 @@ extends:
172177
artifact: drop_BuildAndSign_BuildWin_arm64
173178
patterns: '*.msix'
174179
- pwsh: |
175-
Set-Location "$(Build.SourcesDirectory)/DSC"
180+
Set-Location "$(System.DefaultWorkingDirectory)\DSC"
176181
$null = New-Item -ItemType Directory -Path "./bin/msix" -Force -ErrorAction Ignore
177182
Copy-Item "$(Pipeline.Workspace)/drop_BuildAndSign_BuildWin_x64/*.msix" ./bin/msix -Verbose
178183
Copy-Item "$(Pipeline.Workspace)/drop_BuildAndSign_BuildWin_arm64/*.msix" ./bin/msix -Verbose
179184
./build.ps1 -PackageType msixbundle
180-
Copy-Item "$(Build.SourcesDirectory)/DSC/bin/*.msixbundle" "$(ob_outputDirectory)"
185+
Copy-Item "$(System.DefaultWorkingDirectory)/DSC/bin/*.msixbundle" "$(ob_outputDirectory)"
181186
displayName: 'Create msixbundle'
182187
condition: succeeded()
183188
@@ -212,6 +217,84 @@ extends:
212217
Copy-Item "$(Build.ArtifactStagingDirectory)/downloads/*.msixbundle" "$(ob_outputDirectory)"
213218
displayName: 'Copy MsixBundle to output directory'
214219
220+
- job: PrepareStorePublish
221+
dependsOn: ['SetPackageVersion', 'SignMsixBundle']
222+
condition: and(succeeded(), eq(variables.officialBuild, true), eq( variables.PublishToStore, true ))
223+
displayName: Prepare Microsoft Store Publish to output directory
224+
pool:
225+
type: windows
226+
variables:
227+
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
228+
ob_sdl_sbom_enabled: false
229+
ob_signing_setup_enabled: false
230+
ob_sdl_codeql_compiled_enabled: false
231+
PackageVersion: $[ dependencies.SetPackageVersion.outputs['Package.Version'] ]
232+
steps:
233+
- pwsh: |
234+
Write-Verbose -Verbose (Get-ChildItem '$(System.DefaultWorkingDirectory)' | Out-String)
235+
$pdpPath = '$(System.DefaultWorkingDirectory)\.pipelines\store\PDP\en-US\PDP.xml'
236+
if (-not (Test-Path -Path $pdpPath)) {
237+
throw "PDP path '$pdpPath' does not exist. Cannot update PDP.xml."
238+
}
239+
240+
$sbConfigPath = '$(System.DefaultWorkingDirectory)\.pipelines\store\SBConfig.json'
241+
if (-not (Test-Path -Path $sbConfigPath)) {
242+
throw "SBConfig path '$sbConfigPath' does not exist. Cannot update SBConfig.json."
243+
}
244+
245+
$isPreRelease = '$(PackageVersion)' -like '*-*'
246+
$pdpContent = Get-Content -Path $pdpPath -Raw
247+
$appName = if ($isPreRelease) {
248+
'DesiredStateConfiguration-Preview'
249+
} else {
250+
'DesiredStateConfiguration'
251+
}
252+
$pdpContent = $pdpContent.Replace('$AppName$', $appName)
253+
Set-Content -Path $pdpPath -Value $pdpContent
254+
Write-Host "PDP.xml updated successfully with AppName: $appName"
255+
256+
$sbConfigContent = Get-Content -Path $sbConfigPath -Raw
257+
$productId = "Microsoft.$appName"
258+
$sbConfigContent = $sbConfigContent.Replace('$ProductID$', $productId)
259+
Set-Content -Path $sbConfigPath -Value $sbConfigContent
260+
Write-Host "SBConfig.json updated successfully with ProductID: $productId"
261+
displayName: 'Prepare Store Publish Files'
262+
- download: current
263+
artifact: drop_BuildAndSign_SignMsixBundle
264+
patterns: '*.msixbundle'
265+
- task: MS-RDX-MRO.windows-store-publish.package-task.store-package@3
266+
displayName: Package for Store Submission
267+
inputs:
268+
serviceEndpoint: dsc-store
269+
sbConfigPath: '$(System.DefaultWorkingDirectory)\.pipelines\Store\SBConfig.json'
270+
sourceFolder: '$(Pipeline.Workspace)\drop_BuildAndSign_SignMsixBundle'
271+
contents: '*.msixbundle'
272+
outSBName: 'DesiredStateConfigurationStorePackage'
273+
pdpPath: '$(System.DefaultWorkingDirectory)\.pipelines\Store\PDP'
274+
pdpMediaPath: '$(System.DefaultWorkingDirectory)\.pipelines\Store\PDP-Media'
275+
- pwsh: |
276+
Get-Item -Path "$(System.DefaultWorkingDirectory)/SBLog.txt" -ErrorAction SilentlyContinue |
277+
Copy-Item -Destination "$(ob_outputDirectory)" -Verbose
278+
displayName: Upload Store Failure Log
279+
condition: failed()
280+
- pwsh: |
281+
$submissionPackageDir = "$(System.DefaultWorkingDirectory)/SBOutDir"
282+
$jsonFile = "$submissionPackageDir/DesiredStateConfigurationStorePackage.json"
283+
$zipFile = "$submissionPackageDir/DesiredStateConfigurationStorePackage.zip"
284+
285+
if ((Test-Path $jsonFile) -and (Test-Path $zipFile)) {
286+
Write-Verbose -Verbose "Uploading StoreBroker Package files:"
287+
Write-Verbose -Verbose "JSON File: $jsonFile"
288+
Write-Verbose -Verbose "ZIP File: $zipFile"
289+
290+
Copy-Item -Path $submissionPackageDir -Destination "$(ob_outputDirectory)" -Verbose -Recurse
291+
}
292+
293+
else {
294+
Write-Error "Required files not found in $submissionPackageDir"
295+
}
296+
displayName: 'Upload StoreBroker Package'
297+
215298
- job: BuildLinuxMusl
216299
dependsOn: SetPackageVersion
217300
variables:
@@ -220,7 +303,7 @@ extends:
220303
AzToken: $[ dependencies.SetPackageVersion.outputs['AzToken'] ]
221304
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
222305
ob_linuxSymbolsPublishing_enabled: true
223-
ob_linuxSymbolsPublishing_symbolsFolder: '$(Build.SourcesDirectory)/DSC/bin'
306+
ob_linuxSymbolsPublishing_symbolsFolder: '$(System.DefaultWorkingDirectory)/DSC/bin'
224307
ob_linuxSymbolsPublishing_searchPattern: '**/*.dbg'
225308
displayName: Linux-x64-musl
226309
pool:
@@ -258,7 +341,7 @@ extends:
258341
AzToken: $[ dependencies.SetPackageVersion.outputs['AzToken'] ]
259342
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
260343
ob_linuxSymbolsPublishing_enabled: true
261-
ob_linuxSymbolsPublishing_symbolsFolder: '$(Build.SourcesDirectory)/DSC/bin'
344+
ob_linuxSymbolsPublishing_symbolsFolder: '$(System.DefaultWorkingDirectory)/DSC/bin'
262345
ob_linuxSymbolsPublishing_searchPattern: '**/*.dbg'
263346
displayName: Linux-ARM64-musl
264347
pool:
@@ -401,8 +484,15 @@ extends:
401484
artifact: drop_BuildAndSign_SignMsixBundle
402485
patterns: '*.msixbundle'
403486

487+
- download: current
488+
artifact: drop_BuildAndSign_PrepareStorePublish
489+
condition: and(succeeded(), eq( variables.PublishToStore, true ))
490+
patterns: |
491+
*.zip
492+
*.json
493+
404494
- pwsh: |
405-
Get-ChildItem "$(Pipeline.Workspace)" -Recurse -Include '*.zip', '*.tar.gz', '*.msixbundle', '*.rpm', '*.deb' | ForEach-Object {
495+
Get-ChildItem "$(Pipeline.Workspace)" -Recurse -Include '*.zip', '*.tar.gz', '*.msixbundle', '*.rpm', '*.deb', '*.json' | ForEach-Object {
406496
Write-Host "Found artifact: $($_.FullName)"
407497
}
408498
displayName: List downloaded artifacts
@@ -415,7 +505,7 @@ extends:
415505
416506
Write-Verbose -Verbose "Starting to copy"
417507
418-
Get-ChildItem "$(Pipeline.Workspace)" -Recurse -Include '*.zip', '*.tar.gz', '*.msixbundle', '*.rpm', '*.deb' | ForEach-Object {
508+
Get-ChildItem "$(Pipeline.Workspace)" -Recurse -Include '*.zip', '*.tar.gz', '*.msixbundle', '*.rpm', '*.deb', '*.json' | ForEach-Object {
419509
Copy-Item -Path $_.FullName -Destination $outputDir -Force -Verbose
420510
}
421511
@@ -495,6 +585,14 @@ extends:
495585
Write-Verbose -Verbose "GitHub Release version: $githubReleaseVersion"
496586
Write-Host "##vso[task.setvariable variable=GitHubReleaseVersion]$githubReleaseVersion"
497587
588+
$appId = if ('$(PackageVersion)' -like '*-*') {
589+
'9PCX3HX4HZ0Z'
590+
} else {
591+
'9NVTPZWRC6KQ'
592+
}
593+
Write-Verbose -Verbose "App ID for Store submission: $appId"
594+
Write-Host "##vso[task.setvariable variable=AppID]$appId"
595+
498596
- task: GitHubRelease@1
499597
displayName: Create GitHub release
500598
inputs:
@@ -514,51 +612,18 @@ extends:
514612
isDraft: true
515613
isPreRelease: '$(IsPreRelease)'
516614

517-
- task: PowerShell@2
518-
displayName: Update PDP.xml for Store release
519-
inputs:
520-
targetType: 'inline'
521-
script: |
522-
$pdpPath = '$(System.DefaultWorkingDirectory)/DSC/.pipelines/store/PDP/en-US/PDP.xml'
523-
if (-not (Test-Path -Path $pdpPath)) {
524-
throw "PDP path '$pdpPath' does not exist. Cannot update PDP.xml."
525-
}
526-
527-
$sbConfigPath = '$(System.DefaultWorkingDirectory)/DSC/.pipelines/store/SBConfig.json'
528-
if (-not (Test-Path -Path $sbConfigPath)) {
529-
throw "SBConfig path '$sbConfigPath' does not exist. Cannot update SBConfig.json."
530-
}
531-
532-
$pdpContent = Get-Content -Path $pdpPath -Raw
533-
$appName = if ($(isPreRelease) -eq 'true') {
534-
'DesiredStateConfiguration-Preview'
535-
} else {
536-
'DesiredStateConfiguration'
537-
}
538-
$pdpContent = $pdpContent.Replace('$AppName$', $appName)
539-
Set-Content -Path $pdpPath -Value $pdpContent
540-
Write-Host "PDP.xml updated successfully with AppName: $appName"
541-
542-
$sbConfigContent = Get-Content -Path $sbConfigPath -Raw
543-
$productId = if ($(isPreRelease) -eq 'true') {
544-
'Microsoft.DesiredStateConfiguration-Preview'
545-
} else {
546-
'Microsoft.DesiredStateConfiguration'
547-
}
548-
$sbConfigContent = $sbConfigContent.Replace('$ProductID$', $productId)
549-
Set-Content -Path $sbConfigPath -Value $sbConfigContent
550-
Write-Host "SBConfig.json updated successfully with ProductID: $productId"
551-
552-
- task: MS-RDX-MRO.windows-store-publish.package-task.store-package@3
553-
displayName: Publish to Microsoft Store
615+
- task: MS-RDX-MRO.windows-store-publish.publish-task.store-publish@3
616+
displayName: 'Publish StoreBroker Package (Stable/LTS)'
617+
condition: and(succeeded(), eq( variables.PublishToStore, true ), eq( variables.officialBuild, true ))
554618
inputs:
555619
serviceEndpoint: dsc-store
556-
sbConfigPath: '$(System.DefaultWorkingDirectory)/DSC/.pipelines/store/SBConfig.json'
557-
sourceFolder: '$(GitHubReleaseDirectory)'
558-
contents: '*.msixbundle'
559-
outSBName: 'DesiredStateConfigurationStorePackage'
560-
pdpPath: '$(System.DefaultWorkingDirectory)/DSC/.pipelines/store/PDP/en-US/PDP.xml'
561-
pdpMediaPath: '$(System.DefaultWorkingDirectory)/DSC/.pipelines/store/PDP/PDP-Media/en-US'
620+
appId: '$(AppID)'
621+
inputMethod: JsonAndZip
622+
jsonPath: '$(Pipeline.Workspace)\DesiredStateConfigurationStorePackage.json'
623+
zipPath: '$(Pipeline.Workspace)\DesiredStateConfigurationStorePackage.zip'
624+
numberOfPackagesToKeep: 2
625+
jsonZipUpdateMetadata: true
626+
targetPublishMode: 'Manual'
562627

563628
- stage: ReleaseUniversalPackage
564629
dependsOn: ['BuildAndSign','Release']
@@ -668,4 +733,3 @@ extends:
668733
Write-Verbose -Verbose "Universal Package version: $packageVersion"
669734
az artifacts universal publish --organization https://dev.azure.com/PowerShell/ --project PowerShell --feed PowerShell-Universal --name microsoft.dsc-macos --version $packageVersion --description "Microsoft Desired State Configuration (DSC) - Universal Package" --path "$(MacOSDirectory)" --scope project --verbose
670735
condition: succeeded()
671-

0 commit comments

Comments
 (0)