Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,28 @@ jobs:
echo "defined=false" >> "$GITHUB_OUTPUT"
fi

reproducible:
name: Reproducible packages and symbols
runs-on: ubuntu-latest
timeout-minutes: 20

steps:
- name: Check out
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7

- name: Install the .NET SDKs
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6
with:
dotnet-version: |
11.0.x
10.0.x

# Two packs of the same commit, compared entry by entry. The script also asserts that every
# package has a symbol package beside it, which is the other half of G4.
- name: Pack twice and compare every entry
shell: pwsh
run: ./docs/tools/verify-reproducible.ps1

build-test-sonar:
name: Build, test and analyse
runs-on: ubuntu-latest
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ jobs:
$packages = @(Get-ChildItem ./artifacts/*.nupkg)
if ($packages.Count -eq 0) { throw 'nothing was packed' }

# G4: every package ships a symbol package beside it. The count is the cheap check; the symbol
# push below sends them to nuget.org's symbol server, where a debugger finds them by the PDB.
$symbols = @(Get-ChildItem ./artifacts/*.snupkg)
if ($symbols.Count -ne $packages.Count) {
$failures += "$($packages.Count) package(s) but $($symbols.Count) symbol package(s)"
}

$version = (Select-String -Path ./src/Directory.Build.props -Pattern '<Version>(.*?)</Version>').Matches[0].Groups[1].Value

$entryPoint = 'SharpCorePDF'
Expand Down Expand Up @@ -269,3 +276,13 @@ jobs:
--source https://api.nuget.org/v3/index.json \
--api-key "${{ steps.login.outputs.NUGET_API_KEY }}" \
--skip-duplicate

# The symbol packages go to nuget.org's symbol server, not the package endpoint: a `.snupkg` is
# served from /api/v2/symbolpackage, and that is what a debugger asks for when it has the PDB.
- name: Push symbols to nuget.org
if: ${{ github.event_name == 'push' || inputs.publish }}
run: |
dotnet nuget push ./artifacts/*.snupkg \
--source https://www.nuget.org/api/v2/symbolpackage \
--api-key "${{ steps.login.outputs.NUGET_API_KEY }}" \
--skip-duplicate
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ against an empty feed.
with `IsReadable`/`RequiresPassword` instead of throwing. `tools/SharpCorePDF.Diagnostics` prints it as
text or JSON, with `--profile` for the archival pre-flight and `--json` for the whole report.

### Changed

- **The packages ship symbols, and the build is proven reproducible.** Every `dotnet pack` writes a
`.snupkg` beside the `.nupkg`, `publish.yml` pushes both, and a `reproducible` CI job packs the same
commit twice and compares every entry of every package. The assembly and file versions follow
`<Version>` again (the 1.7.0 bump had left them at 1.6.0.0).

## [1.7.0] - 2026-11-14

### Added
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ page, running footer and bookmarks stay in step.
| --- | --- |
| [`tools/validate-pdf.py`](tools/validate-pdf.py) | Runs `qpdf --check`, decodes every stream, and prints the geometry, rotation and annotations of every page; `--password` does the same for an encrypted document. |
| [`tools/make-fixtures.py`](tools/make-fixtures.py) | Regenerates the PDF fixtures the test suite uses; `--parity` regenerates the checked-in parity corpus through [`tools/make_parity_fixtures.py`](tools/make_parity_fixtures.py). |
| [`tools/verify-reproducible.ps1`](tools/verify-reproducible.ps1) | Packs the solution twice with the CI build property and fails when any entry of any package differs, and checks that every package has a symbol package beside it; the `reproducible` CI job runs it and the release checklist's G4 cites it. |

Both tools run through `uv`, as shown in the repository README:

Expand Down
4 changes: 2 additions & 2 deletions docs/release-checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ is the first time the entry-point id is claimed, and G0 is what decided it. It w
| G1 | The public surface has stopped moving | a preview is a promise a consumer builds against | **No** — 1 of 12 surface stories is in review; 1.0.0 was cut over it, see the sequence below | the remaining surface stories |
| G2 | One shipped leg, `net11.0` | 1.0 must not withdraw a target framework it once advertised | **No** — packages carry `lib/net10.0` and `lib/net11.0`, and `publish.yml` asserts both | the story that narrows the shipped leg |
| G3 | `CHANGELOG.md` exists and describes the version being published | a version with no notes is a version nobody can evaluate | **Yes, 2026-10-17** — the file holds a `[1.0.0]` entry, written in the same commit as the bump | keep the entry current in the commit that bumps `<Version>` |
| G4 | Symbols reach a debugger, and the build is proven reproducible | a stack trace from a consumer is useless without source mapping | **Partly** — `<Deterministic>true</Deterministic>` is set and Source Link rides on `RepositoryUrl`, but no symbol package is packed and no two builds are compared | the changelog and symbols story |
| G4 | Symbols reach a debugger, and the build is proven reproducible | a stack trace from a consumer is useless without source mapping | **Yes, 2026-11-14** — every `dotnet pack` writes a `.snupkg` beside the `.nupkg` (`IncludeSymbols` and `SymbolPackageFormat` in `src/Directory.Build.props`), `publish.yml` pushes both, and `docs/tools/verify-reproducible.ps1` packs the same commit twice and compares every entry of every package; the `reproducible` CI job runs it on every push | `docs/tools/verify-reproducible.ps1`, `.github/workflows/ci.yml`, `.github/workflows/publish.yml` |
| G5 | Trusted publishing policy and `NUGET_USERNAME` exist | without them the workflow can publish nothing | **Yes, 2026-10-17** — the OIDC exchange minted a key that pushed all five (run `39025525848`); the first attempt was refused `403` on the bare id until its subject line was added to the policy | nuget.org → Trusted Publishing; repository secrets |
| G6 | A dry run is green on the commit that will be tagged | the local-feed handshake is the only rehearsal available | **Yes, 2026-10-17** — dispatch `39023732538` with `publish: false` pushed all five `1.0.0` packages into the runner's local feed on `a1d8f6a` | Actions → publish → `publish: false` |
| G7 | The tag equals `<Version>` | a tag must name the version, prerelease suffix included | **Yes** — `v1.0.0` names `<Version>` `1.0.0`, and `publish.yml` refuses a mismatch | `v` + the exact `<Version>` |
Expand Down Expand Up @@ -576,7 +576,7 @@ assignment covers, recorded as the underlay form XObject the editor already writ
| G2 — the shipped leg | **Unchanged: both legs ship** | `dotnet pack` produced five `1.7.0` packages; `SharpCorePDF.Domain`, `.Application` and `.Infrastructure` carry `lib/net10.0` and `lib/net11.0` |
| G3 — notes | **Written** | `CHANGELOG.md` holds `## [1.7.0] - 2026-11-14`, and `[Unreleased]` is empty again |
| G9 — quality gate on the tree | **Green on `5ddd935`, the tagged commit** | `ci.yml` run `43597713484`: token check, build/test/analyse, **Tests on arm64** and **Native AOT smoke** all `success`; locally `dotnet test` **1185 passed, 0 failed** on each leg |
| G4 — symbols and reproducible binaries | **Still partly** | tracked as #12: no `.snupkg` and no two-build comparison |
| G4 — symbols and reproducible binaries | **Yes, 2026-11-14** | `.snupkg` is packed for all five packages and pushed to nuget.org's symbol server; `docs/tools/verify-reproducible.ps1` (the `reproducible` CI job) packs the same commit twice and compares every entry. Code signing is still not done, which the gate treats as "as appropriate" |
| G5 — trusted publishing | **Unchanged, outside the tree** | the `1.6.0` policy needed no new subject |
| G6 — a dry run on the commit to be tagged | **Not run separately** | the tag push was the publish run; `publish.yml` gates it on the SonarCloud verdict for the commit, which was green |
| G7 — the tag equals `<Version>` | **Yes — `v1.7.0` on `5ddd935`, `<Version>` 1.7.0** | the tag names the commit whose analysis was the newest on `main` |
Expand Down
109 changes: 109 additions & 0 deletions docs/tools/verify-reproducible.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#requires -Version 7
<#
Proves the packages are reproducible: packs the solution twice with the CI build property and compares
every entry of every package, then checks that each package has a symbol package beside it.

The comparison is entry-by-entry rather than a hash of the .nupkg file: the container records the time
each entry was added, so two packs with identical contents can still differ as files. What a consumer
installs is the entries, and those are what this compares.

Run it from anywhere; it finds the repository root from its own path.
#>
param(
[string] $Root = (Resolve-Path (Join-Path $PSScriptRoot '../..')).Path
)

$ErrorActionPreference = 'Stop'
Add-Type -AssemblyName System.IO.Compression.FileSystem

function Get-EntryHashes {
param([string] $Path)

$zip = [System.IO.Compression.ZipFile]::OpenRead($Path)

try {
$hashes = @{}

foreach ($entry in $zip.Entries) {
$stream = $entry.Open()

try {
$buffer = New-Object System.IO.MemoryStream
$stream.CopyTo($buffer)
$hashes[$entry.FullName] = [System.Convert]::ToHexString(
[System.Security.Cryptography.SHA256]::HashData($buffer.ToArray()))
$buffer.Dispose()
}
finally {
$stream.Dispose()
}
}

return $hashes
}
finally {
$zip.Dispose()
}
}

Push-Location $Root

try {
$first = Join-Path $Root 'artifacts/repro1'
$second = Join-Path $Root 'artifacts/repro2'

Remove-Item -LiteralPath $first, $second -Recurse -Force -ErrorAction SilentlyContinue

dotnet pack ./SharpCorePDF.slnx -c Release -o $first -p:ContinuousIntegrationBuild=true --nologo -v q
if ($LASTEXITCODE -ne 0) { throw 'the first pack failed' }

dotnet pack ./SharpCorePDF.slnx -c Release -o $second -p:ContinuousIntegrationBuild=true --nologo -v q
if ($LASTEXITCODE -ne 0) { throw 'the second pack failed' }

$packages = @(Get-ChildItem $first -Filter *.nupkg)
if ($packages.Count -eq 0) { throw 'the first pack produced no package' }

$symbols = @(Get-ChildItem $first -Filter *.snupkg)
if ($symbols.Count -ne $packages.Count) {
throw "$($packages.Count) package(s) but $($symbols.Count) symbol package(s)"
}

$problems = [System.Collections.Generic.List[string]]::new()

foreach ($package in $packages) {
$other = Join-Path $second $package.Name

if (-not (Test-Path -LiteralPath $other)) {
$problems.Add("$($package.Name) is missing from the second pack")
continue
}

$a = Get-EntryHashes $package.FullName
$b = Get-EntryHashes $other

foreach ($entry in $a.Keys) {
if (-not $b.ContainsKey($entry)) {
$problems.Add("$($package.Name): $entry is only in the first pack")
}
elseif ($b[$entry] -ne $a[$entry]) {
$problems.Add("$($package.Name): $entry differs")
}
}

foreach ($entry in $b.Keys) {
if (-not $a.ContainsKey($entry)) {
$problems.Add("$($package.Name): $entry is only in the second pack")
}
}
}

if ($problems.Count -gt 0) {
$problems | ForEach-Object { Write-Host "::error::$_" }
throw "$($problems.Count) difference(s) between two packs"
}

Write-Output "reproducible: $($packages.Count) package(s), $($symbols.Count) symbol package(s), every entry identical"
}
finally {
Pop-Location
}
7 changes: 5 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<Deterministic>true</Deterministic>
<ContinuousIntegrationBuild Condition="'$(CI)' == 'true'">true</ContinuousIntegrationBuild>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<EnforceCodeStyleInBuild>false</EnforceCodeStyleInBuild>

<!--
Expand All @@ -47,8 +50,8 @@
<IsAotCompatible>true</IsAotCompatible>

<Version>1.7.0</Version>
<AssemblyVersion>1.6.0.0</AssemblyVersion>
<FileVersion>1.6.0.0</FileVersion>
<AssemblyVersion>1.7.0.0</AssemblyVersion>
<FileVersion>1.7.0.0</FileVersion>
<Authors>MPCoreDeveloper</Authors>
<Company>SharpCorePDF</Company>
<Product>SharpCorePDF</Product>
Expand Down
Loading