Skip to content

Commit 2b6a8c7

Browse files
Add SBOM to nuget package (#80)
1 parent 72bf366 commit 2b6a8c7

File tree

2 files changed

+35
-18
lines changed

2 files changed

+35
-18
lines changed

build.psm1

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -533,12 +533,7 @@ function Start-BuildPowerShellNativePackage
533533

534534
[Parameter(Mandatory = $true)]
535535
[ValidateScript({Test-Path $_ -PathType Leaf})]
536-
[string] $psrpZipPath,
537-
538-
[Parameter(Mandatory = $true)]
539-
[string] $NuGetOutputPath,
540-
541-
[switch] $SkipCleanup = $false
536+
[string] $psrpZipPath
542537
)
543538

544539
if(-not (Test-Path $PackageRoot))
@@ -605,24 +600,32 @@ function Start-BuildPowerShellNativePackage
605600
Copy-Item $iconPath (Join-Path $PackageRoot -ChildPath $iconFileName) -Verbose
606601

607602
$Nuspec -f $Version, $iconFileName | Out-File -FilePath (Join-Path $PackageRoot -ChildPath 'Microsoft.PowerShell.Native.nuspec') -Force
603+
}
608604

609-
if(-not (Test-Path $NuGetOutputPath))
610-
{
611-
$null = New-Item $NuGetOutputPath -Force -Verbose -ItemType Directory
612-
}
605+
<#
606+
.SYNOPSIS
607+
Pack the new nuget package from af folder.
608+
#>
609+
function New-NugetPackage {
610+
param (
611+
[Parameter(Mandatory)]
612+
[string] $PackageRoot,
613+
614+
[Parameter(Mandatory)]
615+
[string] $NuGetOutputPath
616+
)
613617

614618
try {
619+
if (-not (Test-Path $NuGetOutputPath)) {
620+
$null = New-Item $NuGetOutputPath -Force -Verbose -ItemType Directory
621+
}
622+
615623
Push-Location $PackageRoot
616624
nuget.exe pack . -OutputDirectory $NuGetOutputPath
617625
}
618626
finally {
619627
Pop-Location
620628
}
621-
622-
if(-not $SkipCleanup -and (Test-Path $tempExtractionPath))
623-
{
624-
Remove-Item $tempExtractionPath -Recurse -Force -ErrorAction SilentlyContinue
625-
}
626629
}
627630

628631
<#

tools/releaseBuild/yaml/nuget.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,23 @@ steps:
8282
$macOSZipPath = Join-Path "$(System.ArtifactsDirectory)/release" 'osx-symbols.zip'
8383
$psrpZipPath = Join-Path "$(System.ArtifactsDirectory)/release" 'psrp.zip'
8484
85-
Start-BuildPowerShellNativePackage -PackageRoot $PackageRoot -Version $(PackageVersion) -WindowsX64ZipPath $WindowsX64ZipPath -WindowsX86ZipPath $WindowsX86ZipPath -WindowsARMZipPath $WindowsARMZipPath -WindowsARM64ZipPath $WindowsARM64ZipPath -LinuxZipPath $LinuxZipPath -LinuxARMZipPath $LinuxARMZipPath -LinuxARM64ZipPath $LinuxARM64ZipPath -LinuxAlpineZipPath $LinuxAlpineZipPath -macOSZipPath $macOSZipPath -psrpZipPath $psrpZipPath -NuGetOutputPath $(NuGetPackagePath)
86-
87-
displayName: 'Build NuGet package'
85+
Start-BuildPowerShellNativePackage -PackageRoot $PackageRoot -Version $(PackageVersion) -WindowsX64ZipPath $WindowsX64ZipPath -WindowsX86ZipPath $WindowsX86ZipPath -WindowsARMZipPath $WindowsARMZipPath -WindowsARM64ZipPath $WindowsARM64ZipPath -LinuxZipPath $LinuxZipPath -LinuxARMZipPath $LinuxARMZipPath -LinuxARM64ZipPath $LinuxARM64ZipPath -LinuxAlpineZipPath $LinuxAlpineZipPath -macOSZipPath $macOSZipPath -psrpZipPath $psrpZipPath
86+
87+
displayName: 'Collate NuGet package structure'
88+
89+
- ${{ if ne(variables['SkipSigning'], 'True') }}:
90+
- template: Sbom.yml@ComplianceRepo
91+
parameters:
92+
BuildDropPath: '$(System.ArtifactsDirectory)\NugetPackage'
93+
Build_Repository_Uri: https://github.com/PowerShell/PowerShell-Native
94+
PackageName: Microsoft.PowerShell.Native
95+
PackageVersion: $(PackageVersion)
96+
97+
- pwsh: |
98+
Import-Module $(Build.SourcesDirectory)\build.psm1
99+
$PackageRoot = "$(System.ArtifactsDirectory)\NugetPackage"
100+
New-NugetPackage -PackageRoot $PackageRoot -NuGetOutputPath $(NuGetPackagePath)
101+
displayName: Build NuGet package
88102

89103
- powershell: 'Get-Childitem $(NuGetPackagePath)'
90104
displayName: 'Capture nuget package'

0 commit comments

Comments
 (0)