Skip to content

Commit 3662e2b

Browse files
authored
Merge pull request #1167 from adityapatwardhan/fixUniversalPackageRelease
Fix universal package release to use service connection and cli
2 parents 6458502 + db4c242 commit 3662e2b

File tree

1 file changed

+110
-37
lines changed

1 file changed

+110
-37
lines changed

.pipelines/DSC-Official.yml

Lines changed: 110 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -470,23 +470,6 @@ extends:
470470
Copy-Item -Path $_.FullName -Destination $GitHubReleaseDirectory -Force -Verbose
471471
}
472472
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-
490473
if (-not '$(PackageVersion)') {
491474
throw "PackageVersion variable is not set. Cannot proceed with release."
492475
}
@@ -506,26 +489,6 @@ extends:
506489
507490
Write-Host "##vso[task.setvariable variable=GitHubReleaseVersion]$githubReleaseVersion"
508491
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-
529492
- task: GitHubRelease@1
530493
displayName: Create GitHub release
531494
inputs:
@@ -544,3 +507,113 @@ extends:
544507
tag: '$(GitHubReleaseVersion)'
545508
isDraft: true
546509
isPreRelease: '$(IsPreRelease)'
510+
511+
- stage: ReleaseUniversalPackage
512+
dependsOn: ['Release']
513+
condition: and(succeeded(), ne(variables['Build.Reason'], 'Schedule'), eq(variables.officialBuild, true))
514+
variables:
515+
- name: PackageVersion
516+
value: $[ stageDependencies.BuildAndSign.SetPackageVersion.outputs['Package.Version'] ]
517+
jobs:
518+
- job: ReleaseUniversalPackageJob
519+
displayName: Release Universal Package job
520+
pool:
521+
type: windows
522+
variables:
523+
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
524+
steps:
525+
- download: current
526+
artifact: drop_ReleasePreparation_ReleasePreparationJob
527+
528+
- pwsh: |
529+
$releasePrepPath = "$(Pipeline.Workspace)/drop_ReleasePreparation_ReleasePreparationJob/releasePrep"
530+
if (-not (Test-Path -Path $releasePrepPath)) {
531+
throw "Release preparation path '$releasePrepPath' does not exist."
532+
}
533+
534+
$windowsFiles = Get-ChildItem -Path $releasePrepPath -Recurse -Include '*.zip'
535+
if ($windowsFiles.Count -eq 0) {
536+
throw "No Windows .zip files found in '$releasePrepPath'. Cannot proceed with Universal Package creation."
537+
}
538+
539+
$linuxFiles = Get-ChildItem -Path $releasePrepPath -Recurse -Include '*linux.tar.gz'
540+
if ($linuxFiles.Count -eq 0) {
541+
throw "No Linux .tar.gz files found in '$releasePrepPath'. Cannot proceed with Universal Package creation."
542+
}
543+
544+
$macosFiles = Get-ChildItem -Path $releasePrepPath -Recurse -Include '*darwin.tar.gz'
545+
if ($macosFiles.Count -eq 0) {
546+
throw "No macOS .tar.gz files found in '$releasePrepPath'. Cannot proceed with Universal Package creation."
547+
}
548+
549+
$windowsDirectory = New-Item -ItemType Directory -Path "$releasePrepPath/windows" -Force -ErrorAction Ignore
550+
Write-Host "##vso[task.setvariable variable=WindowsDirectory]$($windowsDirectory.FullName)"
551+
552+
$linuxDirectory = New-Item -ItemType Directory -Path "$releasePrepPath/linux" -Force -ErrorAction Ignore
553+
Write-Host "##vso[task.setvariable variable=LinuxDirectory]$linuxDirectory"
554+
555+
$macosDirectory = New-Item -ItemType Directory -Path "$releasePrepPath/macos" -Force -ErrorAction Ignore
556+
Write-Host "##vso[task.setvariable variable=MacOSDirectory]$macosDirectory"
557+
558+
$windowsFiles | ForEach-Object {
559+
Move-Item -Path $_.FullName -Destination $windowsDirectory.FullName -Force -Verbose
560+
}
561+
562+
$linuxFiles | ForEach-Object {
563+
Move-Item -Path $_.FullName -Destination $linuxDirectory.FullName -Force -Verbose
564+
}
565+
566+
$macosFiles | ForEach-Object {
567+
Move-Item -Path $_.FullName -Destination $macosDirectory.FullName -Force -Verbose
568+
}
569+
570+
displayName: Prepare files for Universal Package
571+
572+
- task: AzureCLI@2
573+
displayName: Publish Windows - Universal Package
574+
inputs:
575+
azureSubscription: PS-PS-DSC-UniversalFeed
576+
scriptType: pscore
577+
scriptLocation: inlineScript
578+
inlineScript: |
579+
$packageVersion = '$(PackageVersion)'
580+
581+
if (-not $packageVersion) {
582+
throw "PackageVersion variable is not set. Cannot proceed with publishing Universal Package."
583+
}
584+
Write-Verbose -Verbose "Universal Package version: $packageVersion"
585+
az artifacts universal publish --organization https://dev.azure.com/PowerShell --project PowerShell --feed PowerShell-Universal --name microsoft.dsc-windows --version $packageVersion --description "Microsoft Desired State Configuration (DSC) - Universal Package" --path "$(WindowsDirectory)" --scope project --verbose
586+
condition: succeeded()
587+
588+
- task: AzureCLI@2
589+
displayName: Publish Linux - Universal Package
590+
inputs:
591+
azureSubscription: PS-PS-DSC-UniversalFeed
592+
scriptType: pscore
593+
scriptLocation: inlineScript
594+
inlineScript: |
595+
$packageVersion = '$(PackageVersion)'
596+
597+
if (-not $packageVersion) {
598+
throw "PackageVersion variable is not set. Cannot proceed with publishing Universal Package."
599+
}
600+
Write-Verbose -Verbose "Universal Package version: $packageVersion"
601+
az artifacts universal publish --organization https://dev.azure.com//PowerShell --project PowerShell --feed PowerShell-Universal --name microsoft.dsc-linux --version $packageVersion --description "Microsoft Desired State Configuration (DSC) - Universal Package" --path "$(LinuxDirectory)" --scope project --verbose
602+
condition: succeeded()
603+
604+
- task: AzureCLI@2
605+
displayName: Publish macOS - Universal Package
606+
inputs:
607+
azureSubscription: PS-PS-DSC-UniversalFeed
608+
scriptType: pscore
609+
scriptLocation: inlineScript
610+
inlineScript: |
611+
$packageVersion = '$(PackageVersion)'
612+
613+
if (-not $packageVersion) {
614+
throw "PackageVersion variable is not set. Cannot proceed with publishing Universal Package."
615+
}
616+
Write-Verbose -Verbose "Universal Package version: $packageVersion"
617+
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
618+
condition: succeeded()
619+

0 commit comments

Comments
 (0)