Skip to content

Commit

Permalink
Fix all the issues with the packaging pipeline (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
daxian-dbw committed Sep 18, 2024
1 parent d35028f commit ed7df6e
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .pipelines/Build-Official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ variables:
- name: BUILDSECMON_OPT_IN
value: true
- name: LinuxContainerImage
value: onebranch.azurecr.io/linux/ubuntu-2004:latest
value: mcr.microsoft.com/onebranch/cbl-mariner/build:2.0
- name: WindowsContainerImage
value: onebranch.azurecr.io/windows/ltsc2019/vse2022:latest
- name: CDP_DEFINITION_BUILD_COUNT
Expand Down
2 changes: 1 addition & 1 deletion .pipelines/Package-Official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,6 @@ extends:
- template: /.pipelines/templates/nupkg-package.yml@self

- stage: upload
dependsOn: [mac_package, windows_package, linux_package, module, nupkg]
dependsOn: [mac, windows, linux, module, nupkg]
jobs:
- template: /.pipelines/templates/upload-to-Azure.yml@self
7 changes: 5 additions & 2 deletions .pipelines/templates/check-Azure-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ jobs:
scriptType: inlineScript
azurePowerShellVersion: latestVersion
inline: |
$context = New-AzStorageContext -StorageAccountName '$(PSInfraStorageAccount)'
Write-Verbose -Verbose 'Create storage context for $(PSInfraStorageAccount)'
$context = New-AzStorageContext -StorageAccountName '$(PSInfraStorageAccount)' -UseConnectedAccount
$containersToDelete = @{
'$web' = 'aish/$(PackageVersion)'
'aish' = '$(PackageVersion)'
Expand All @@ -83,10 +84,12 @@ jobs:
} else {
throw "Azure blob container '$virtualContainer' already exists. To overwrite, use the 'ForceAzureBlobDelete' parameter"
}
} else {
Write-Verbose -Verbose "No blob found under '$virtualContainer'"
}
}
catch {
if ($_.FullyQualifiedErrorId -eq 'ResourceNotFoundException,Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.GetAzureStorageContainerCommand') {
if ($_.FullyQualifiedErrorId -eq 'RequestFailedException,Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.GetAzureStorageBlobCommand') {
Write-Verbose -Verbose "Container '$virtualContainer' does not exist."
} else {
throw $_
Expand Down
14 changes: 4 additions & 10 deletions .pipelines/templates/linux-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- pwsh: |
$signedFilesPath = "$(Pipeline.Workspace)/AIShellBuildPipeline/drop_linux_sign_$(Architecture)"
Write-Verbose -Verbose "Downloaded artifacts: "
Get-ChildItem $signedFilesPath -Recurse
Get-ChildItem $signedFilesPath -Recurse | Out-String -Width 500 -Stream
Write-Verbose -Message "Checking 'aish' exists in '$signedFilesPath'" -Verbose
if (-not (Test-Path $signedFilesPath/aish)) {
Expand All @@ -73,14 +73,8 @@ jobs:
- pwsh: |
Import-Module $(repoRoot)/tools/packaging -Force
$signedFilesPath = "$(Pipeline.Workspace)/AIShellBuildPipeline/drop_macos_sign_$(Architecture)"
Write-Verbose -Message "Checking 'aish' exists in '$signedFilesPath'" -Verbose
if (-not (Test-Path $signedFilesPath/aish)) {
throw "aish not found in $signedFilesPath"
}
$signedFilesPath = "$(Pipeline.Workspace)/AIShellBuildPipeline/drop_linux_sign_$(Architecture)"
$macosRuntime = "osx-$(Architecture)"
$outDir = "$(Pipeline.Workspace)/AIShellBuildPipeline/pkgs"
$null = New-Item -ItemType Directory $outDir
Expand All @@ -95,7 +89,7 @@ jobs:
- pwsh: |
if (-not (Test-Path $(ob_outputDirectory))) {
New-Item -ItemType Directory -Path $(ob_outputDirectory) -Force
$null = New-Item -ItemType Directory -Path $(ob_outputDirectory) -Force
}
$pkgFilter = "AIShell-*.tar.gz"
Expand All @@ -107,5 +101,5 @@ jobs:
displayName: 'Copy artifacts to output directory'
- pwsh: |
Get-ChildItem -Path $(ob_outputDirectory) -Recurse
Get-ChildItem -Path $(ob_outputDirectory) -Recurse | Out-String -Width 500 -Stream
displayName: 'List uploaded artifacts'
2 changes: 1 addition & 1 deletion .pipelines/templates/mac-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- pwsh: |
$signedFilesPath = "$(Pipeline.Workspace)/AIShellBuildPipeline/drop_macos_sign_$(Architecture)"
Write-Verbose -Verbose "Downloaded artifacts:"
Get-ChildItem $signedFilesPath -Recurse
Get-ChildItem $signedFilesPath -Recurse | Out-String -Width 500 -Stream
$version = (Get-Item "$signedFilesPath/AIShell.Abstraction.dll").VersionInfo.ProductVersion
$vstsCommandString = "vso[task.setvariable variable=PackageVersion]$version"
Expand Down
28 changes: 18 additions & 10 deletions .pipelines/templates/module-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jobs:
displayName: Package AIShell module
condition: succeeded()
pool:
type: windows
type: linux

variables:
- name: runCodesignValidationInjection
Expand All @@ -19,13 +19,13 @@ jobs:
- name: ob_sdl_sbom_enabled
value: false
- name: ob_outputDirectory
value: '$(Build.ArtifactStagingDirectory)\ONEBRANCH_ARTIFACT'
value: '$(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT'
- name: repoRoot
value: $(Build.SourcesDirectory)\ProjectMercury
value: $(Build.SourcesDirectory)/ProjectMercury
- name: ob_sdl_binskim_enabled
value: true
- name: ob_sdl_tsa_configFile
value: $(repoRoot)\.config\tsaoptions.json
value: $(repoRoot)/.config/tsaoptions.json
- name: ob_signing_setup_enabled
value: true
- name: ob_sdl_codeql_compiled_enabled
Expand All @@ -50,17 +50,25 @@ jobs:
ob_restore_phase: true

- pwsh: |
$signedFilePath = "$(Pipeline.Workspace)/AIShellBuildPipeline/drop_module_sign"
Write-Verbose -Verbose "Downloaded artifacts: "
Get-ChildItem "$(Pipeline.Workspace)\AIShellBuildPipeline\drop_module_sign" -Recurse
Get-ChildItem $signedFilePath -Recurse | Out-String -Width 500 -Stream
$moduleFolder = "$(Pipeline.Workspace)/AIShellBuildPipeline/AIShell"
$null = New-Item -ItemType Directory -Path $moduleFolder -Force
Write-Verbose -Verbose "Move module files to the 'AIShell' module folder: "
Copy-Item -Path "$signedFilePath/*" -Destination $moduleFolder -Recurse -Force -Verbose
Get-ChildItem $moduleFolder -Recurse | Out-String -Width 500 -Stream
displayName: 'List downloaded files'
# Diagnostics is not critical it passes every time it runs
continueOnError: true
env:
ob_restore_phase: true
- pwsh: |
$signedFilePath = "$(Pipeline.Workspace)\AIShellBuildPipeline\drop_module_sign"
$nugetPath = "$(Pipeline.Workspace)\AIShellBuildPipeline\NuGetPackage"
$moduleFolder = "$(Pipeline.Workspace)/AIShellBuildPipeline/AIShell"
$nugetPath = "$(Pipeline.Workspace)/AIShellBuildPipeline/NuGetPackage"
New-Item -Path $nugetPath -ItemType Directory > $null
$vstsCommandString = "vso[task.setvariable variable=NugetPath]$nugetPath"
Expand All @@ -70,11 +78,11 @@ jobs:
try {
$RepoName = "PSRLLocal"
Register-PSRepository -Name $RepoName -SourceLocation $nugetPath -PublishLocation $nugetPath -InstallationPolicy Trusted
Publish-Module -Repository $RepoName -Path $signedFilePath
Publish-Module -Repository $RepoName -Path $moduleFolder
} finally {
Unregister-PSRepository -Name $RepoName -ErrorAction SilentlyContinue
}
Get-ChildItem -Path $nugetPath
Get-ChildItem -Path $nugetPath | Out-String -Width 500 -Stream
displayName: 'Create the NuGet package'
env:
ob_restore_phase: true
Expand All @@ -91,5 +99,5 @@ jobs:
displayName: Upload module nupkg
inputs:
SourceFolder: $(NugetPath)
Contents: '**\*'
Contents: '**/*'
TargetFolder: $(ob_outputDirectory)
4 changes: 4 additions & 0 deletions .pipelines/templates/nupkg-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ jobs:
- group: mscodehub-feed-read-general
- group: mscodehub-feed-read-akv
- group: DotNetPrivateBuildAccess
- name: ob_sdl_sbom_enabled
value: false
- name: ob_sdl_codeql_compiled_enabled
value: false

steps:
- checkout: self
Expand Down
25 changes: 16 additions & 9 deletions .pipelines/templates/upload-to-Azure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,10 @@ jobs:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifact: drop_mac_package_x64
artifact: macos-pkgs
targetPath: '$(Build.ArtifactStagingDirectory)/downloads'
displayName: Download macOS x64 packages

- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifact: drop_mac_package_arm64
targetPath: '$(Build.ArtifactStagingDirectory)/downloads'
displayName: Download macOS arm64 packages

- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
Expand Down Expand Up @@ -86,6 +79,20 @@ jobs:
targetPath: '$(Build.ArtifactStagingDirectory)/downloads'
displayName: Download Windows arm64 packages

- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifact: drop_module_package
targetPath: '$(Build.ArtifactStagingDirectory)/downloads'
displayName: Download module package

- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifact: drop_nupkg_package
targetPath: '$(Build.ArtifactStagingDirectory)/downloads'
displayName: Download SDK NuGet package

- pwsh: |
Get-ChildItem '$(Build.ArtifactStagingDirectory)/downloads' | ForEach-Object FullName
displayName: 'Capture downloads'
Expand Down Expand Up @@ -121,7 +128,7 @@ jobs:
$nupkgName = [System.IO.Path]::GetFileNameWithoutExtension($nupkgFile.Name)
$version = $nupkgName.Replace('AIShell.Abstraction.', '')
$storageAccountName = $(PSInfraStorageAccount)
$storageAccountName = '$(PSInfraStorageAccount)'
$context = New-AzStorageContext -StorageAccountName $storageAccountName -UseConnectedAccount
# Create the public blob container if it doesn't exist
Expand Down
10 changes: 5 additions & 5 deletions .pipelines/templates/windows-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- pwsh: |
$signedFilesPath = "$(Pipeline.Workspace)\AIShellBuildPipeline\drop_windows_build_$(Architecture)"
Write-Verbose -Verbose "Downloaded artifacts: "
Get-ChildItem $signedFilesPath -Recurse
Get-ChildItem $signedFilesPath -Recurse | Out-String -Width 500 -Stream
Write-Verbose -Message "Checking 'aish.exe' exists in '$signedFilesPath'" -Verbose
if (-not (Test-Path $signedFilesPath\aish.exe)) {
Expand Down Expand Up @@ -99,20 +99,20 @@ jobs:
- pwsh: |
if (-not (Test-Path $(ob_outputDirectory))) {
New-Item -ItemType Directory -Path $(ob_outputDirectory) -Force
$null = New-Item -ItemType Directory -Path $(ob_outputDirectory) -Force
}
$zipPkgNameFilter = "powershell-*.zip"
$zipPkgNameFilter = "AIShell-*.zip"
$zipPkgPath = Get-ChildItem -Path $(PackagePath) -Filter $zipPkgNameFilter -File | ForEach-Object FullName
Write-Verbose -Verbose "zipPkgPath: $zipPkgPath"
Copy-Item -Path $zipPkgPath -Destination '$(ob_outputDirectory)' -Force -Verbose
$msixPkgNameFilter = "powershell-*.msix"
$msixPkgNameFilter = "AIShell-*.msix"
$msixPkgPath = Get-ChildItem -Path $(PackagePath) -Filter $msixPkgNameFilter -File | ForEach-Object FullName
Write-Verbose -Verbose "msixPkgPath: $msixPkgPath"
Copy-Item -Path $msixPkgPath -Destination '$(ob_outputDirectory)' -Force -Verbose
displayName: Copy to output directory
- pwsh: |
Get-ChildItem -Path $(ob_outputDirectory) -Recurse
Get-ChildItem -Path $(ob_outputDirectory) -Recurse | Out-String -Width 500 -Stream
displayName: 'List uploaded artifacts'
2 changes: 1 addition & 1 deletion shell/AIShell.Integration/AIShell.Integration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Management.Automation" Version="7.4.0">
<PackageReference Include="System.Management.Automation" Version="7.4.5">
<ExcludeAssets>contentFiles</ExcludeAssets>
<PrivateAssets>All</PrivateAssets>
</PackageReference>
Expand Down

0 comments on commit ed7df6e

Please sign in to comment.