diff --git a/.pipelines/PowerShell-Packages-Official.yml b/.pipelines/PowerShell-Packages-Official.yml index 30b9e415215..487e8cb9c6a 100644 --- a/.pipelines/PowerShell-Packages-Official.yml +++ b/.pipelines/PowerShell-Packages-Official.yml @@ -60,6 +60,7 @@ variables: value: $[format('{0:yyyyMMdd}-{1}', pipeline.startTime,variables['Build.SourceBranch'])] - name: branchCounter value: $[counter(variables['branchCounterKey'], 1)] + - group: MSIXSigningProfile resources: pipelines: @@ -246,7 +247,13 @@ extends: jobs: - template: /.pipelines/templates/nupkg.yml@self + - stage: msixbundle + displayName: 'Create MSIX Bundle' + dependsOn: [windows_package] + jobs: + - template: /.pipelines/templates/package-create-msix.yml@self + - stage: upload - dependsOn: [mac_package, windows_package, linux_package, nupkg] + dependsOn: [mac_package, windows_package, linux_package, nupkg, msixbundle] jobs: - template: /.pipelines/templates/uploadToAzure.yml@self diff --git a/.pipelines/PowerShell-Release-Official.yml b/.pipelines/PowerShell-Release-Official.yml index f7a69e4407a..816f4f55d90 100644 --- a/.pipelines/PowerShell-Release-Official.yml +++ b/.pipelines/PowerShell-Release-Official.yml @@ -58,7 +58,6 @@ variables: - name: ReleaseTagVar value: ${{ parameters.ReleaseTagVar }} - group: PoolNames - - group: MSIXSigningProfile resources: repositories: @@ -122,12 +121,6 @@ extends: jobs: - template: /.pipelines/templates/release-SetTagAndChangelog.yml@self - - stage: msixbundle - displayName: 'Create MSIX Bundle' - dependsOn: [] - jobs: - - template: /.pipelines/templates/release-create-msix.yml@self - - stage: validateSdk displayName: 'Validate SDK' dependsOn: [] @@ -270,7 +263,6 @@ extends: - fxdpackages - gbltool - validateSdk - - msixbundle jobs: - template: /.pipelines/templates/approvalJob.yml@self diff --git a/.pipelines/templates/release-create-msix.yml b/.pipelines/templates/package-create-msix.yml similarity index 58% rename from .pipelines/templates/release-create-msix.yml rename to .pipelines/templates/package-create-msix.yml index ac82fc05def..0ab2408e6a7 100644 --- a/.pipelines/templates/release-create-msix.yml +++ b/.pipelines/templates/package-create-msix.yml @@ -13,20 +13,32 @@ jobs: steps: - template: release-SetReleaseTagandContainerName.yml@self - - download: PSPackagesOfficial - artifact: drop_windows_package_package_win_arm64 - displayName: Download arm64 msix - patterns: '**/*.msix' - - - download: PSPackagesOfficial - artifact: drop_windows_package_package_win_x64 - displayName: Download x64 msix - patterns: '**/*.msix' - - - download: PSPackagesOfficial - artifact: drop_windows_package_package_win_x86 - displayName: Download x86 msix - patterns: '**/*.msix' + - task: DownloadPipelineArtifact@2 + inputs: + buildType: 'current' + artifact: drop_windows_package_package_win_arm64 + itemPattern: | + **/*.msix + targetPath: '$(Build.ArtifactStagingDirectory)/downloads' + displayName: Download windows arm64 packages + + - task: DownloadPipelineArtifact@2 + inputs: + buildType: 'current' + artifact: drop_windows_package_package_win_x64 + itemPattern: | + **/*.msix + targetPath: '$(Build.ArtifactStagingDirectory)/downloads' + displayName: Download windows x64 packages + + - task: DownloadPipelineArtifact@2 + inputs: + buildType: 'current' + artifact: drop_windows_package_package_win_x86 + itemPattern: | + **/*.msix + targetPath: '$(Build.ArtifactStagingDirectory)/downloads' + displayName: Download windows x86 packages # Finds the makeappx tool on the machine with image: 'onebranch.azurecr.io/windows/ltsc2022/vse2022:latest' - pwsh: | @@ -53,7 +65,7 @@ jobs: $sourceDir = '$(Pipeline.Workspace)\releasePipeline\msix' $null = New-Item -Path $sourceDir -ItemType Directory -Force - $msixFiles = Get-ChildItem -Path "$(Pipeline.Workspace)/PSPackagesOfficial/*.msix" -Recurse + $msixFiles = Get-ChildItem -Path "$(Build.ArtifactStagingDirectory)/downloads/*.msix" -Recurse foreach ($msixFile in $msixFiles) { $null = Copy-Item -Path $msixFile.FullName -Destination $sourceDir -Force -Verbose } @@ -87,43 +99,12 @@ jobs: $signedBundle = Get-ChildItem -Path $(BundleDir) -Filter "*.msixbundle" -File Write-Verbose -Verbose "Signed bundle: $signedBundle" - # Ensure the destination directory exists - if (-not (Test-Path -Path "$(ob_outputDirectory)")) { - Write-Verbose -Verbose "Creating destination directory: $(ob_outputDirectory)" - New-Item -Path "$(ob_outputDirectory)" -ItemType Directory -Force | Out-Null + if (-not (Test-Path $(ob_outputDirectory))) { + New-Item -ItemType Directory -Path $(ob_outputDirectory) -Force } - Copy-Item -Path $signedBundle.FullName -Destination "$(ob_outputDirectory)\$($signedBundle.Name)" -Verbose + Copy-Item -Path $signedBundle.FullName -Destination "$(ob_outputDirectory)" -Verbose Write-Verbose -Verbose "Uploaded Bundle:" Get-ChildItem -Path $(ob_outputDirectory) | Write-Verbose -Verbose displayName: Upload msixbundle to Artifacts - - - task: AzurePowerShell@5 - displayName: Upload msix to blob - inputs: - azureSubscription: az-blob-cicd-infra - scriptType: inlineScript - azurePowerShellVersion: LatestVersion - pwsh: true - inline: | - $containerName = '$(OutputVersion.AzureVersion)-private' - $storageAccount = '$(StorageAccount)' - - $storageContext = New-AzStorageContext -StorageAccountName $storageAccount -UseConnectedAccount - - if ($env:BundleDir) { - $bundleFile = Get-Item "$env:BundleDir\*.msixbundle" - $blobName = $bundleFile | Split-Path -Leaf - $existing = Get-AzStorageBlob -Container $containerName -Blob $blobName -Context $storageContext -ErrorAction Ignore - if ($existing) { - Write-Verbose -Verbose "MSIX bundle already exists at '$storageAccount/$containerName/$blobName', removing first." - $existingBlob | Remove-AzStorageBlob -ErrorAction Stop -Verbose - } - - Write-Verbose -Verbose "Uploading $bundleFile to $containerName/$blobName" - Set-AzStorageBlobContent -File $bundleFile -Container $containerName -Blob $blobName -Context $storageContext -Force - } - else{ - throw "BundleDir not found" - } diff --git a/.pipelines/templates/uploadToAzure.yml b/.pipelines/templates/uploadToAzure.yml index e35201cf1c7..e7960a19839 100644 --- a/.pipelines/templates/uploadToAzure.yml +++ b/.pipelines/templates/uploadToAzure.yml @@ -25,6 +25,7 @@ jobs: value: $(Build.SourcesDirectory)\PowerShell\.config\suppress.json - name: ob_sdl_codeql_compiled_enabled value: false + - group: 'Azure Blob variable group' steps: - checkout: self @@ -38,6 +39,8 @@ jobs: CreateJson: yes UseJson: no + - template: /.pipelines/templates/release-SetReleaseTagandContainerName.yml@self + - template: /.pipelines/templates/cloneToOfficialPath.yml@self - pwsh: | @@ -231,6 +234,15 @@ jobs: targetPath: '$(Build.ArtifactStagingDirectory)/downloads' displayName: Download macos x64 packages + - task: DownloadPipelineArtifact@2 + inputs: + buildType: 'current' + artifact: drop_msixbundle_CreateMSIXBundle + itemPattern: | + **/*.msixbundle + targetPath: '$(Build.ArtifactStagingDirectory)/downloads' + displayName: Download MSIXBundle + - pwsh: | Get-ChildItem '$(Build.ArtifactStagingDirectory)/downloads' | Select-Object -ExpandProperty FullName displayName: 'Capture downloads' @@ -397,3 +409,26 @@ jobs: Write-Host "File $blobName uploaded to $containerName container." Move-Item -Path $_.FullName -Destination $uploadedDirectory -Force -Verbose } + + $msixbundleFiles = Get-ChildItem -Path $downloadsDirectory -Filter "*.msixbundle" + + $containerName = '$(OutputVersion.AzureVersion)-private' + $storageAccount = '$(StorageAccount)' + + $storageContext = New-AzStorageContext -StorageAccountName $storageAccount -UseConnectedAccount + + if ($msixbundleFiles) { + $bundleFile = $msixbundleFiles[0].FullName + $blobName = $msixbundleFiles[0].Name + + $existing = Get-AzStorageBlob -Container $containerName -Blob $blobName -Context $storageContext -ErrorAction Ignore + if ($existing) { + Write-Verbose -Verbose "MSIX bundle already exists at '$storageAccount/$containerName/$blobName', removing first." + $existing | Remove-AzStorageBlob -ErrorAction Stop -Verbose + } + + Write-Verbose -Verbose "Uploading $bundleFile to $containerName/$blobName" + Set-AzStorageBlobContent -File $bundleFile -Container $containerName -Blob $blobName -Context $storageContext -Force + } else { + throw "MSIXBundle not found in $downloadsDirectory" + }