@@ -37,6 +37,8 @@ resources:
3737extends :
3838 template : ${{ variables.templateFile }}
3939 parameters :
40+ release :
41+ category : NonAzure
4042 featureFlags :
4143 WindowsHostVersion :
4244 Disk : Large
@@ -89,6 +91,7 @@ extends:
8991 Write-Host ("sending " + $vstsCommandString)
9092 Write-Host "##$vstsCommandString"
9193 name: Package
94+ displayName: Set Package Version
9295 - task : AzureCLI@2
9396 displayName : Get Az Token
9497 inputs :
@@ -346,53 +349,198 @@ extends:
346349 displayName: 'Build $(buildName)'
347350 condition: succeeded()
348351
349- - stage : Release
352+ - stage : ReleasePreparation
350353 dependsOn : BuildAndSign
351- condition : ne(variables['Build.Reason'], 'Schedule')
352- variables :
353- PackageVersion : $[ dependencies.SetPackageVersion.outputs['Package.Version'] ]
354+ condition : and(succeeded(), ne(variables['Build.Reason'], 'Schedule'), eq(variables.officialBuild, true))
354355 jobs :
355- - job : Validation
356- displayName : Manual validation
356+ - job : ReleasePreparationJob
357+ displayName : Release Preparation job
358+ pool :
359+ type : windows
360+ variables :
361+ ob_outputDirectory : ' $(Build.ArtifactStagingDirectory)'
362+ steps :
363+ - download : current
364+ artifact : drop_BuildAndSign_BuildWin_x64
365+ patterns : ' *.zip'
366+
367+ - download : current
368+ artifact : drop_BuildAndSign_BuildWin_arm64
369+ patterns : ' *.zip'
370+
371+ - download : current
372+ artifact : drop_BuildAndSign_BuildLinuxArm64Musl
373+ patterns : ' *.tar.gz'
374+
375+ - download : current
376+ artifact : drop_BuildAndSign_BuildLinuxMusl
377+ patterns : ' *.tar.gz'
378+
379+ - download : current
380+ artifact : release # # this includes artifacts for macOS
381+ patterns : ' **/*.tar.gz'
382+
383+ - download : current
384+ artifact : drop_BuildAndSign_SignMsixBundle
385+ patterns : ' *.msixbundle'
386+
387+ - pwsh : |
388+ Get-ChildItem "$(Pipeline.Workspace)" -Recurse -Include '*.zip', '*.tar.gz', '*.msixbundle' | ForEach-Object {
389+ Write-Host "Found artifact: $($_.FullName)"
390+ }
391+ displayName: List downloaded artifacts
392+
393+ - pwsh : |
394+ $outputDir = "$(ob_outputDirectory)\releasePrep"
395+ if( -not (Test-Path -Path $outputDir)) {
396+ New-Item -ItemType Directory -Path $outputDir -Force -ErrorAction Ignore -Verbose
397+ }
398+
399+ Write-Verbose -Verbose "Starting to copy"
400+
401+ Get-ChildItem "$(Pipeline.Workspace)" -Recurse -Include '*.zip', '*.tar.gz', '*.msixbundle' | ForEach-Object {
402+ Copy-Item -Path $_.FullName -Destination $outputDir -Force -Verbose
403+ }
404+
405+ if (-not (Test-Path $(Build.SourcesDirectory)\CHANGELOG.md)) {
406+ throw "CHANGELOG.md file not found in source directory."
407+ }
408+
409+ Copy-Item -Path "$(Build.SourcesDirectory)\CHANGELOG.md" -Destination $outputDir -Force -Verbose
410+
411+ Write-Verbose -Verbose "Copy completed"
412+ displayName: Copy artifacts to release area
413+
414+ - stage : Validation
415+ dependsOn : ['ReleasePreparation']
416+ condition : and(succeeded(), ne(variables['Build.Reason'], 'Schedule'))
417+ jobs :
418+ - job : ValidationJob
419+ displayName : Validation job
357420 pool :
358421 type : agentless
359- timeoutInMinutes : 1440
360422 steps :
361423 - task : ManualValidation@0
362- displayName : Wait 24 hours for validation
424+ displayName : Wait for manual validation
363425 inputs :
364426 notifyUsers : $(Build.RequestedForEmail)
365- instructions : Please validate the release
427+ instructions : Please validate the build artifacts before proceeding to release.
366428 timeoutInMinutes : 1440
367- - job : GitHub
368- dependsOn : validation
369- displayName : Publish draft to GitHub
429+
430+ - stage : Release
431+ dependsOn : ['BuildAndSign', 'Validation', 'ReleasePreparation']
432+ condition : and(succeeded(), ne(variables['Build.Reason'], 'Schedule'), eq(variables.officialBuild, true))
433+ variables :
434+ - name : PackageVersion
435+ value : $[ stageDependencies.BuildAndSign.SetPackageVersion.outputs['Package.Version'] ]
436+ - name : ob_release_environment
437+ value : ${{ iif ( parameters.OfficialBuild, 'Production', 'Test' ) }}
438+ jobs :
439+ - job : ReleaseJob
440+ displayName : Release job
370441 pool :
371- type : windows
372- variables :
373- ob_outputDirectory : ' $(Build.ArtifactStagingDirectory) '
374- ob_sdl_sbom_enabled : false
375- ob_signing_setup_enabled : false
376- ob_sdl_codeql_compiled_enabled : false
377- drop : $(Pipeline.Workspace)/drop_build_main
442+ type : release
443+ os : windows
444+ templateContext :
445+ inputs :
446+ - input : pipelineArtifact
447+ artifactName : drop_ReleasePreparation_ReleasePreparationJob
448+
378449 steps :
379- - download : current
380- displayName : Download artifacts
381- patterns : |
382- '**/*.zip'
383- '**/*.tar.gz'
450+ - task : PowerShell@2
451+ displayName : Capture downloaded artifacts and Version for release
452+ inputs :
453+ targetType : ' inline'
454+ script : |
455+ Write-Verbose -Verbose "Release version: $(PackageVersion)"
456+
457+ $artifacts = Get-ChildItem "$(Pipeline.Workspace)" -Recurse -Include '*.zip', '*.tar.gz', '*.msixbundle', '*.MD'
458+
459+ $artifacts | ForEach-Object {
460+ Write-Verbose -Verbose "Found artifact: $($_.FullName)"
461+ }
462+
463+ $ChangeLogDirectory = New-Item -ItemType Directory -Path "$(Pipeline.Workspace)/ChangeLog" -Force -ErrorAction Ignore
464+ Write-Host "##vso[task.setvariable variable=ChangeLogDirectory]$ChangeLogDirectory"
465+ Copy-Item -Path "$(Pipeline.Workspace)/releasePrep/CHANGELOG.md" -Destination $ChangeLogDirectory -Force -Verbose
466+
467+ $GitHubReleaseDirectory = New-Item -ItemType Directory -Path "$(Pipeline.Workspace)/GitHubRelease" -Force -ErrorAction Ignore
468+ Write-Host "##vso[task.setvariable variable=GitHubReleaseDirectory]$GitHubReleaseDirectory"
469+ $artifacts | ForEach-Object {
470+ Copy-Item -Path $_.FullName -Destination $GitHubReleaseDirectory -Force -Verbose
471+ }
472+
473+ $windowsDirName = "Microsoft.DSC-Windows"
474+ $linuxDirName = "Microsoft.DSC-Linux"
475+
476+ $WindowsReleaseDirectory = New-Item -ItemType Directory -Path "$(Pipeline.Workspace)/$windowsDirName" -Force -ErrorAction Ignore
477+ Write-Host "##vso[task.setvariable variable=WindowsReleaseDirectory]$WindowsReleaseDirectory"
478+
479+ $artifacts | Where-Object { $_.Extension -eq '.zip' } | ForEach-Object {
480+ Copy-Item -Path $_.FullName -Destination $WindowsReleaseDirectory -Force -Verbose
481+ }
482+
483+ $LinuxReleaseDirectory = New-Item -ItemType Directory -Path "$(Pipeline.Workspace)/$linuxDirName" -Force -ErrorAction Ignore
484+ Write-Host "##vso[task.setvariable variable=LinuxReleaseDirectory]$LinuxReleaseDirectory"
485+
486+ $artifacts | Where-Object { $_.Extension -eq '.tar.gz' } | ForEach-Object {
487+ Copy-Item -Path $_.FullName -Destination $LinuxReleaseDirectory -Force -Verbose
488+ }
489+
490+ if (-not '$(PackageVersion)') {
491+ throw "PackageVersion variable is not set. Cannot proceed with release."
492+ }
493+
494+ $packageVersion = '$(PackageVersion)'
495+ if ($packageVersion -like '*-*') {
496+ Write-Verbose -Verbose "Pre-release version detected: $packageVersion"
497+ Write-Host "##vso[task.setvariable variable=IsPreRelease]true"
498+ }
499+ else {
500+ Write-Verbose -Verbose "Stable release version detected: $packageVersion"
501+ Write-Host "##vso[task.setvariable variable=IsPreRelease]false"
502+ }
503+
504+ $githubReleaseVersion = "v$packageVersion"
505+ Write-Verbose -Verbose "GitHub Release version: $githubReleaseVersion"
506+
507+ Write-Host "##vso[task.setvariable variable=GitHubReleaseVersion]$githubReleaseVersion"
508+
509+ - task : UniversalPackages@0
510+ displayName : Publish to Azure Artifacts Universal Packages
511+ inputs :
512+ command : publish
513+ publishDirectory : ' $(LinuxReleaseDirectory)'
514+ vstsFeedPublish : ' PowerShell-DSC-Feed'
515+ vstsFeedPackagePublish : ' microsoft.dsc-linux'
516+ versionOption : custom
517+ versionPublish : ' $(PackageVersion)'
518+
519+ - task : UniversalPackages@0
520+ displayName : Publish to Azure Artifacts Universal Packages
521+ inputs :
522+ command : publish
523+ publishDirectory : ' $(WindowsReleaseDirectory)'
524+ vstsFeedPublish : ' PowerShell-DSC-Feed'
525+ vstsFeedPackagePublish : ' microsoft.dsc-windows'
526+ versionOption : custom
527+ versionPublish : ' $(PackageVersion)'
528+
384529 - task : GitHubRelease@1
385530 displayName : Create GitHub release
386531 inputs :
387- gitHubConnection : GitHub
532+ gitHubConnection : github.com_SteveL-MSFT
388533 repositoryName : PowerShell/DSC
534+ target : main
389535 action : create
536+ title : $(GitHubReleaseVersion)
390537 assets : |
391- *.zip;
392- *.tar.gz;
538+ $(GitHubReleaseDirectory)\ *.zip
539+ $(GitHubReleaseDirectory)\ *.tar.gz
393540 addChangeLog : true
394541 changeLogType : commitBased
395- releaseNotesFilePath : CHANGELOG.md
396- tagSource : gitTag
397- tag : v$(version)
542+ releaseNotesFilePath : ' $(ChangeLogDirectory)\ CHANGELOG.md'
543+ tagSource : ' userSpecifiedTag '
544+ tag : ' $(GitHubReleaseVersion) '
398545 isDraft : true
546+ isPreRelease : ' $(IsPreRelease)'
0 commit comments