Skip to content

Commit 4a1f144

Browse files
committed
Make release packaging reproducible
1 parent b56d914 commit 4a1f144

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

scripts/build-release.ps1

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ $artifacts = Join-Path $root 'artifacts'
1212
$portable = Join-Path $artifacts 'portable'
1313
$payload = Join-Path $root 'src\DarksFIDO2.Setup\Payload'
1414
$out = Join-Path $artifacts 'release'
15+
$providerProject = Join-Path $root 'src\DarksFIDO2.Provider\DarksFIDO2.Provider.csproj'
16+
[xml]$providerProjectXml = Get-Content -LiteralPath $providerProject -Raw
17+
$version = @($providerProjectXml.Project.PropertyGroup.Version | Where-Object { $_ })[0]
18+
if (!$version) { throw 'The provider project version is missing.' }
1519

1620
Remove-Item $artifacts -Recurse -Force -ErrorAction SilentlyContinue
1721
New-Item $portable, $payload, $out -ItemType Directory -Force | Out-Null
1822

19-
& $dotnet restore (Join-Path $root 'DarksFIDO2.slnx') --locked-mode
23+
& $dotnet restore (Join-Path $root 'DarksFIDO2.slnx') --locked-mode -r $Runtime -p:PublishReadyToRun=true
2024
if ($LASTEXITCODE -ne 0) { throw 'Locked dependency restore failed.' }
2125

2226
# Keep the GUI self-contained but multi-file. A single-file WPF bundle extracts a full
@@ -42,6 +46,7 @@ foreach ($name in 'DarksFIDO2.exe','darksfido-cli.exe','DarksFIDO2.Provider.exe'
4246
& (Join-Path $PSScriptRoot 'build-provider-package.ps1') -ProviderExecutable (Join-Path $portable 'DarksFIDO2.Provider.exe') -OutputPath $providerPackage -CertificateThumbprint $CertificateThumbprint -MakeAppx $makeAppx -SignTool $signTool -TimestampServer $TimestampServer
4347
Copy-Item $providerPackage (Join-Path $portable 'DarksFIDO2.Provider.msix') -Force
4448
Copy-Item $providerPackage (Join-Path $payload 'DarksFIDO2.Provider.msix') -Force
49+
Copy-Item $providerPackage (Join-Path $out 'DarksFIDO2.Provider.msix') -Force
4550
$certificatePath = Join-Path $out 'DarksFIDO2-Signing-Public.cer'
4651
Export-Certificate -Cert ("Cert:\CurrentUser\My\" + $CertificateThumbprint) -FilePath $certificatePath -Force | Out-Null
4752

@@ -69,4 +74,17 @@ $setup = Join-Path $artifacts 'setup\DarksFIDO2-Setup.exe'
6974
& $signTool sign /sha1 $CertificateThumbprint /fd SHA256 /tr $TimestampServer /td SHA256 $setup | Out-Null
7075
if ($LASTEXITCODE -ne 0) { throw 'Setup signing failed.' }
7176
Copy-Item $setup (Join-Path $out 'DarksFIDO2-Setup.exe') -Force
77+
$releaseNotes = Join-Path $root "RELEASE-NOTES-$version.md"
78+
$securityAudit = Join-Path $root "SECURITY-AUDIT-$version.md"
79+
if (!(Test-Path -LiteralPath $releaseNotes) -or !(Test-Path -LiteralPath $securityAudit)) {
80+
throw "Release notes and security audit are required for version $version."
81+
}
82+
Copy-Item $releaseNotes, $securityAudit -Destination $out -Force
83+
$checksumLines = Get-ChildItem -LiteralPath $out -File |
84+
Sort-Object Name |
85+
ForEach-Object { "$(Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256 | Select-Object -ExpandProperty Hash) *$($_.Name)" }
86+
[IO.File]::WriteAllLines(
87+
(Join-Path $out 'SHA256SUMS.txt'),
88+
[string[]]$checksumLines,
89+
[Text.UTF8Encoding]::new($false))
7290
Get-ChildItem $out | Select-Object Name, Length, LastWriteTime

0 commit comments

Comments
 (0)