Skip to content

Commit 56b4430

Browse files
committed
ci: add github cli attestation verification
1 parent 389db81 commit 56b4430

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

build/sign.ps1

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,13 @@ function Test-RequiredAssets {
7777
if (-not $found) {
7878
throw "Required build asset not found: $($required.Key)`nThis file should contain $($required.Value)"
7979
}
80+
8081
Write-Host " ✅ Found $($required.Value) in: $($found.Name)" -ForegroundColor Green
82+
83+
# Verify GitHub attestation
84+
if (-not (Test-GithubAttestation -FilePath $found.FullName -RepoName "Yubico/Yubico.NET.SDK")) {
85+
throw "Attestation verification failed for: $($found.Name)"
86+
}
8187
}
8288
}
8389

@@ -109,6 +115,39 @@ function Initialize-DirectoryStructure {
109115
return $directories
110116
}
111117

118+
function Test-GithubAttestation {
119+
[CmdletBinding()]
120+
param(
121+
[Parameter(Mandatory = $true)]
122+
[string]$FilePath,
123+
124+
[Parameter(Mandatory = $true)]
125+
[string]$RepoName
126+
)
127+
128+
Write-Host " 🔐 Verifying attestation for: $FilePath" -ForegroundColor Gray
129+
130+
try {
131+
# Check if gh CLI is available
132+
if (-not (Get-Command gh -ErrorAction SilentlyContinue)) {
133+
throw "GitHub CLI (gh) is not installed or not in PATH"
134+
}
135+
136+
$output = gh attestation verify $FilePath --repo $RepoName 2>&1
137+
if ($LASTEXITCODE -ne 0) {
138+
Write-Host $output -ForegroundColor Red
139+
throw $output # This will trigger the catch block
140+
}
141+
142+
Write-Host " ✅ Attestation verified" -ForegroundColor Green
143+
return $true
144+
}
145+
catch {
146+
Write-Host " ❌ Attestation verification failed: $_" -ForegroundColor Red
147+
return $false
148+
}
149+
}
150+
112151
<#
113152
.SYNOPSIS
114153
Signs NuGet and Symbol packages using a smart card certificate.
@@ -196,7 +235,7 @@ function Invoke-NuGetPackageSigning {
196235

197236
# Validate tools existence
198237
Write-Host "`nVerifying required tools..."
199-
if (-not (Test-Path $SignToolPath)) {
238+
if (-not (Get-Command $SignToolPath -ErrorAction SilentlyContinue)) {
200239
throw "SignTool not found at path: $SignToolPath"
201240
}
202241
Write-Host "✓ SignTool found at: $SignToolPath"
@@ -254,7 +293,7 @@ function Invoke-NuGetPackageSigning {
254293
}
255294

256295
# First process nupkg files to sign their contents
257-
Write-Host "`nProcessing NuGet packages..."
296+
Write-Host "`n📦 Processing NuGet packages..." -ForegroundColor Yellow
258297
$nugetPackages = Get-ChildItem -Path $directories.Unsigned -Filter "*.nupkg"
259298
foreach ($package in $nugetPackages) {
260299
Write-Host "`nSigning contents of: $($package.Name)"

0 commit comments

Comments
 (0)