Official PowerShell Package pipeline (#21504)

This commit is contained in:
Aditya Patwardhan
2024-04-22 16:26:03 -07:00
committed by GitHub
parent fe38405b1d
commit b2574ce6f8
13 changed files with 1562 additions and 20 deletions
+46 -8
View File
@@ -61,6 +61,8 @@ function Start-PSPackage {
[ValidateScript({$Environment.IsMacOS})]
[string] $MacOSRuntime,
[string] $PackageBinPath,
[switch] $Private,
[Switch] $Force,
@@ -245,7 +247,14 @@ function Start-PSPackage {
$Version = (git --git-dir="$RepoRoot/.git" describe) -Replace '^v'
}
$Source = Split-Path -Path $Script:Options.Output -Parent
$Source = if ($PackageBinPath) {
$PackageBinPath
}
else {
Split-Path -Path $Script:Options.Output -Parent
}
Write-Verbose -Verbose "Source: $Source"
# Copy the ThirdPartyNotices.txt so it's part of the package
Copy-Item "$RepoRoot/ThirdPartyNotices.txt" -Destination $Source -Force
@@ -909,9 +918,9 @@ function Update-PSSignedBuildFolder
foreach ($signedFileObject in $signedFilesList) {
# completely skip replacing pwsh on non-windows systems (there is no .exe extension here)
# and it may not be signed correctly
# The Shim will not be signed in CI.
if ($signedFileObject.Name -eq "pwsh" -or ($signedFileObject.Name -eq "Microsoft.PowerShell.GlobalTool.Shim.exe" -and $env:BUILD_REASON -eq 'PullRequest')) {
Write-Verbose -Verbose "Skipping $signedFileObject"
continue
@@ -1090,7 +1099,7 @@ function New-UnixPackage {
switch ($Type) {
"deb" {
$packageVersion = Get-LinuxPackageSemanticVersion -Version $Version
if (!$Environment.IsUbuntu -and !$Environment.IsDebian) {
if (!$Environment.IsUbuntu -and !$Environment.IsDebian -and !$Environment.IsMariner) {
throw ($ErrorMessage -f "Ubuntu or Debian")
}
@@ -1689,7 +1698,7 @@ function New-AfterScripts
$packagingStrings.RedHatAfterInstallScript -f "$Link", $Destination | Out-File -FilePath $AfterInstallScript -Encoding ascii
$packagingStrings.RedHatAfterRemoveScript -f "$Link", $Destination | Out-File -FilePath $AfterRemoveScript -Encoding ascii
}
elseif ($Environment.IsDebianFamily -or $Environment.IsSUSEFamily) {
elseif ($Environment.IsDebianFamily -or $Environment.IsSUSEFamily -or $Distribution -in $script:DebianDistributions) {
$AfterInstallScript = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName()))
$AfterRemoveScript = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName()))
$packagingStrings.UbuntuAfterInstallScript -f "$Link", $Destination | Out-File -FilePath $AfterInstallScript -Encoding ascii
@@ -2301,7 +2310,6 @@ function New-ILNugetPackageSource
[Parameter(Mandatory = $true)]
[string] $RefAssemblyPath,
[Parameter(Mandatory = $true)]
[string] $CGManifestPath
)
@@ -2358,9 +2366,15 @@ function New-ILNugetPackageSource
CreateNugetPlatformFolder -FileName $FileName -Platform 'win' -PackageRuntimesFolder $packageRuntimesFolderPath -PlatformBinPath $WinFxdBinPath
Write-Verbose -Verbose "Done creating Windows runtime assemblies for $FileName"
if ($linuxExceptionList -notcontains $FileName )
{
CreateNugetPlatformFolder -FileName $FileName -Platform 'unix' -PackageRuntimesFolder $packageRuntimesFolderPath -PlatformBinPath $LinuxFxdBinPath
Write-Verbose -Verbose "Done creating Linux runtime assemblies for $FileName"
}
else {
Write-Verbose -Verbose "Skipping creating Linux runtime assemblies for $FileName"
}
if ($FileName -eq "Microsoft.PowerShell.SDK.dll")
@@ -2409,6 +2423,14 @@ function New-ILNugetPackageSource
Write-Log "Copied the built-in modules to contentFiles for the SDK package"
}
else {
Write-Verbose -Verbose "Skipping copying the built-in modules and reference assemblies for $FileName"
}
if (-not $PSBoundParameters.ContainsKey("CGManifestPath")) {
Write-Verbose -Verbose "CGManifestPath is not provided. Skipping CGManifest creation."
return
}
# Create a CGManifest file that lists all dependencies for this package, which is used when creating the SBOM.
if (! (Test-Path -Path $CGManifestPath)) {
@@ -4197,7 +4219,8 @@ function New-GlobalToolNupkgSource
[Parameter(Mandatory)] [string] $WindowsBinPath,
[Parameter(Mandatory)] [string] $WindowsDesktopBinPath,
[Parameter(Mandatory)] [string] $AlpineBinPath,
[Parameter(Mandatory)] [string] $PackageVersion
[Parameter(Mandatory)] [string] $PackageVersion,
[Parameter()] [switch] $SkipCGManifest
)
if ($PackageType -ne "Unified")
@@ -4361,12 +4384,21 @@ function New-GlobalToolNupkgSource
# Set VSTS environment variable for package NuSpec source path.
$pkgNuSpecSourcePathVar = "GlobalToolNuSpecSourcePath"
Write-Log "New-GlobalToolNupkgSource: Creating NuSpec source path VSTS variable: $pkgNuSpecSourcePathVar"
Write-Verbose -Verbose "sending: [task.setvariable variable=$pkgNuSpecSourcePathVar]$RootFolder"
Write-Host "##vso[task.setvariable variable=$pkgNuSpecSourcePathVar]$RootFolder"
$global:GlobalToolNuSpecSourcePath = $RootFolder
# Set VSTS environment variable for package Name.
$pkgNameVar = "GlobalToolPkgName"
Write-Log "New-GlobalToolNupkgSource: Creating current package name variable: $pkgNameVar"
Write-Verbose -Verbose "sending: vso[task.setvariable variable=$pkgNameVar]$PackageName"
Write-Host "##vso[task.setvariable variable=$pkgNameVar]$PackageName"
$global:GlobalToolPkgName = $PackageName
if ($SkipCGManifest.IsPresent) {
Write-Verbose -Verbose "New-GlobalToolNupkgSource: Skipping CGManifest creation."
return
}
# Set VSTS environment variable for CGManifest file path.
$globalToolCGManifestPFilePath = Join-Path -Path "$env:REPOROOT" -ChildPath "tools\cgmanifest.json"
@@ -4409,7 +4441,7 @@ function New-GlobalToolNupkgFromSource
[Parameter(Mandatory)] [string] $PackageNuSpecPath,
[Parameter(Mandatory)] [string] $PackageName,
[Parameter(Mandatory)] [string] $DestinationPath,
[Parameter(Mandatory)] [string] $CGManifestPath
[Parameter()] [string] $CGManifestPath
)
if (! (Test-Path -Path $PackageNuSpecPath))
@@ -4423,6 +4455,12 @@ function New-GlobalToolNupkgFromSource
Write-Log "New-GlobalToolNupkgFromSource: Removing GlobalTool NuSpec source directory: $PackageNuSpecPath"
Remove-Item -Path $PackageNuSpecPath -Recurse -Force -ErrorAction SilentlyContinue
if (-not ($PSBoundParameters.ContainsKey('CGManifestPath')))
{
Write-Verbose -Verbose "New-GlobalToolNupkgFromSource: CGManifest file path not provided."
return
}
Write-Log "New-GlobalToolNupkgFromSource: Removing GlobalTool CGManifest source directory: $CGManifestPath"
if (! (Test-Path -Path $CGManifestPath))
{
@@ -6,9 +6,9 @@ Import-Module "$PSScriptRoot\dockerInstall.psm1"
# which was large and unstable in docker
function Install-WixZip
{
param($zipPath)
param($zipPath, $arm64 = $false)
$targetRoot = "${env:ProgramFiles(x86)}\WiX Toolset xcopy"
$targetRoot = $arm64 ? "${env:ProgramFiles(x86)}\Arm Support WiX Toolset xcopy" : "${env:ProgramFiles(x86)}\WiX Toolset xcopy"
$binPath = Join-Path -Path $targetRoot -ChildPath 'bin'
Write-Verbose "Expanding $zipPath to $binPath ..." -Verbose
Expand-Archive -Path $zipPath -DestinationPath $binPath -Force