Adds bundled plugin trust and cross-platform native deployment

- embeds the append-only historical and deny trust lists in the API and marks matching bundled plugins as Official without blocking loading
- builds and records the current plugin manifest only for official release builds
- deploys the PDF native libraries for the supported Linux, macOS and Windows runtimes from the plugin dependency manifest
- records release hashes by appending only missing entries to master's manifest and rejects any diff that removes a line
- documents the release flow, the supported runtimes and the plugin installer limits
This commit is contained in:
BinaryAlley committed 2026-11-28 18:00:00 +02:00
1 parent 3fb8912c7f
commit b30cbd6b9e
114 files changed
+2708 -243

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
# Bundled plugin revocation list.
# Each line revokes one plugin binary: <assembly file name>|<SHA-256>.
# The reader removes these hashes from the historical and current trust lists, so a revoked binary is no longer marked Official.
# Remove an entry to restore trust in that hash. The historical trust list remains append-only.
+4
View File
@@ -0,0 +1,4 @@
# Bundled plugin trust list.
# Each line identifies one shipped plugin binary: <assembly file name>|<SHA-256>.
# The release workflow appends a line for every released plugin binary. Never remove an existing line, so older bundled versions remain Official.
# Use BundledPlugins.deny.manifest to revoke a hash without removing its trust-list entry.
+19
View File
@@ -0,0 +1,19 @@
<Project>
<!-- The append-only list of bundled plugin binaries that are trusted as Official. -->
<PropertyGroup>
<BundledPluginsManifest>$(MSBuildThisFileDirectory)BundledPlugins.manifest</BundledPluginsManifest>
<BundledPluginsDenyManifest>$(MSBuildThisFileDirectory)BundledPlugins.deny.manifest</BundledPluginsDenyManifest>
</PropertyGroup>
<!-- The plugin projects that ship with the application. -->
<ItemGroup>
<BundledPluginProject Include="$(MSBuildThisFileDirectory)../plugins/Nemera.Plugins.Calibre/Nemera.Plugins.Calibre.csproj" />
<BundledPluginProject Include="$(MSBuildThisFileDirectory)../plugins/Nemera.Plugins.CoverArtArchive/Nemera.Plugins.CoverArtArchive.csproj" />
<BundledPluginProject Include="$(MSBuildThisFileDirectory)../plugins/Nemera.Plugins.Epub/Nemera.Plugins.Epub.csproj" />
<BundledPluginProject Include="$(MSBuildThisFileDirectory)../plugins/Nemera.Plugins.ID3/Nemera.Plugins.ID3.csproj" />
<BundledPluginProject Include="$(MSBuildThisFileDirectory)../plugins/Nemera.Plugins.LocalMusicArtwork/Nemera.Plugins.LocalMusicArtwork.csproj" />
<BundledPluginProject Include="$(MSBuildThisFileDirectory)../plugins/Nemera.Plugins.MusicBrainz/Nemera.Plugins.MusicBrainz.csproj" />
<BundledPluginProject Include="$(MSBuildThisFileDirectory)../plugins/Nemera.Plugins.OpenLibrary/Nemera.Plugins.OpenLibrary.csproj" />
<BundledPluginProject Include="$(MSBuildThisFileDirectory)../plugins/Nemera.Plugins.Pdf/Nemera.Plugins.Pdf.csproj" />
</ItemGroup>
</Project>
+204
View File
@@ -0,0 +1,204 @@
<Project DefaultTargets="CI">
<Import Project="$(MSBuildThisFileDirectory)BundledPlugins.props" />
<PropertyGroup>
<RepoRoot>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..'))</RepoRoot>
<Solution>$(RepoRoot)/src/Nemera.slnx</Solution>
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
<ApiPublishDirectory>$(RepoRoot)/bin/api/publish</ApiPublishDirectory>
<WebPublishDirectory>$(RepoRoot)/bin/web/publish</WebPublishDirectory>
<BundledPluginsCurrentManifest Condition="'$(BundledPluginsCurrentManifest)' == ''">$(RepoRoot)/bin/api/BundledPlugins.current.manifest</BundledPluginsCurrentManifest>
<BundledPluginsSolution Condition="'$(BundledPluginsSolution)' == ''">$(MSBuildThisFileDirectory)obj/BundledPlugins.slnx</BundledPluginsSolution>
<_OfficialReleaseBuild Condition="'$(OfficialReleaseBuild)' == ''">false</_OfficialReleaseBuild>
<_OfficialReleaseBuild Condition="'$(OfficialReleaseBuild)' != ''">$(OfficialReleaseBuild)</_OfficialReleaseBuild>
<_DockerDependsOn>Build</_DockerDependsOn>
<_DockerDependsOn Condition="'$(_OfficialReleaseBuild)' == 'true'">ValidateDockerRelease;VerifyPublishedBundledPlugins</_DockerDependsOn>
</PropertyGroup>
<Target Name="Restore">
<Exec Command="dotnet restore &quot;$(Solution)&quot;" />
<PropertyGroup>
<BundledPluginsAlreadyRestored>true</BundledPluginsAlreadyRestored>
</PropertyGroup>
</Target>
<Target Name="Build" DependsOnTargets="Restore;CompileSolution;FinalizeOfficialBundledPluginManifest" />
<Target Name="CompileSolution" DependsOnTargets="PrepareOfficialBundledPluginManifest">
<Exec Condition="'$(_OfficialReleaseBuild)' == 'true'" Command="dotnet build &quot;$(Solution)&quot; -c $(Configuration) --no-restore -p:OfficialReleaseBuild=$(_OfficialReleaseBuild) -p:BundledPluginsCurrentManifest=&quot;$(BundledPluginsCurrentManifest)&quot;" />
<Exec Condition="'$(_OfficialReleaseBuild)' != 'true'" Command="dotnet build &quot;$(Solution)&quot; -c $(Configuration) --no-restore -p:OfficialReleaseBuild=$(_OfficialReleaseBuild)" />
</Target>
<Target Name="Test" DependsOnTargets="Build">
<Exec Command="dotnet test &quot;$(Solution)&quot; -c $(Configuration) --no-build --blame-hang --blame-hang-timeout 10m" />
</Target>
<!-- The generated solution lets dotnet restore and dotnet build handle the plugin projects as separate supported invocations. -->
<Target Name="PrepareBundledPluginsSolution">
<ItemGroup>
<_BundledPluginSolutionLine Include="&lt;Solution&gt;" />
<_BundledPluginSolutionLine Include="@(BundledPluginProject->' &lt;Project Path=&quot;%(FullPath)&quot; /&gt;')" />
<_BundledPluginSolutionLine Include="&lt;/Solution&gt;" />
</ItemGroup>
<Error Condition="'@(BundledPluginProject)' == ''" Text="The bundled plugin catalog is empty." />
<MakeDir Directories="$([System.IO.Path]::GetDirectoryName('$(BundledPluginsSolution)'))" />
<WriteLinesToFile File="$(BundledPluginsSolution)" Lines="@(_BundledPluginSolutionLine)" Overwrite="true" WriteOnlyWhenDifferent="true" />
</Target>
<Target Name="RestoreBundledPlugins" Condition="'$(BundledPluginsAlreadyRestored)' != 'true'" DependsOnTargets="PrepareBundledPluginsSolution">
<Exec Command="dotnet restore &quot;$(BundledPluginsSolution)&quot;" WorkingDirectory="$(RepoRoot)" />
</Target>
<Target Name="BuildBundledPlugins" DependsOnTargets="PrepareBundledPluginsSolution;RestoreBundledPlugins">
<Exec Command="dotnet build &quot;$(BundledPluginsSolution)&quot; -c $(Configuration) --no-restore -p:NemeraPluginsOutputDirectory=&quot;$(NemeraPluginsOutputDirectory)&quot;" WorkingDirectory="$(RepoRoot)" />
</Target>
<!-- The first official build needs a current manifest file to embed. The real manifest is generated from the deployed plugins after the solution build. -->
<Target Name="PrepareOfficialBundledPluginManifest" Condition="'$(_OfficialReleaseBuild)' == 'true'">
<MakeDir Directories="$([System.IO.Path]::GetDirectoryName('$(BundledPluginsCurrentManifest)'))" />
<WriteLinesToFile File="$(BundledPluginsCurrentManifest)" Lines="# The current manifest is generated after the solution build." Overwrite="true" WriteOnlyWhenDifferent="true" />
</Target>
<!-- The official manifest is generated from the plugins that the solution build actually deployed, so the embedded hashes and the deployed binaries cannot diverge. -->
<Target Name="FinalizeOfficialBundledPluginManifest" Condition="'$(_OfficialReleaseBuild)' == 'true'" DependsOnTargets="CompileSolution">
<MSBuild Projects="$(RepoRoot)/src/Nemera.Presentation.Api/Nemera.Presentation.Api.csproj" Targets="GetTargetPath" Properties="Configuration=$(Configuration)">
<Output TaskParameter="TargetOutputs" ItemName="_BundledPluginApiTargetPath" />
</MSBuild>
<Error Condition="'@(_BundledPluginApiTargetPath)' == ''" Text="The API target path could not be determined." />
<ItemGroup>
<_BundledPluginApiTargetDirectory Include="@(_BundledPluginApiTargetPath->'%(RootDir)%(Directory)')" />
</ItemGroup>
<PropertyGroup>
<_DeployedBundledPluginsDirectory>@(_BundledPluginApiTargetDirectory)plugins</_DeployedBundledPluginsDirectory>
</PropertyGroup>
<ItemGroup>
<_DeployedBundledPluginAssembly Include="$(_DeployedBundledPluginsDirectory)/Nemera.Plugins.*.dll" />
</ItemGroup>
<Error Condition="'@(_DeployedBundledPluginAssembly)' == ''" Text="No bundled plugin binaries were deployed to '$(_DeployedBundledPluginsDirectory)'." />
<GetFileHash Files="@(_DeployedBundledPluginAssembly)" Algorithm="SHA256">
<Output TaskParameter="Items" ItemName="_FinalizedBundledPluginHash" />
</GetFileHash>
<WriteLinesToFile File="$(BundledPluginsCurrentManifest)" Lines="@(_FinalizedBundledPluginHash->'%(Filename)%(Extension)|%(FileHash)')" Overwrite="true" WriteOnlyWhenDifferent="true" />
<Exec Command="dotnet build &quot;$(RepoRoot)/src/Nemera.Presentation.Api/Nemera.Presentation.Api.csproj&quot; -c $(Configuration) --no-restore -p:OfficialReleaseBuild=true -p:BundledPluginsCurrentManifest=&quot;$(BundledPluginsCurrentManifest)&quot;" />
<Exec Command="dotnet build &quot;$(RepoRoot)/tests/UnitTests/Nemera.Presentation.Api.UnitTests/Nemera.Presentation.Api.UnitTests.csproj&quot; -c $(Configuration) --no-restore -p:OfficialReleaseBuild=true -p:BundledPluginsCurrentManifest=&quot;$(BundledPluginsCurrentManifest)&quot;" />
<Exec Command="dotnet build &quot;$(RepoRoot)/tests/IntegrationTests/Nemera.Presentation.Api.IntegrationTests/Nemera.Presentation.Api.IntegrationTests.csproj&quot; -c $(Configuration) --no-restore -p:OfficialReleaseBuild=true -p:BundledPluginsCurrentManifest=&quot;$(BundledPluginsCurrentManifest)&quot;" />
</Target>
<Target Name="VerifyBundledPlugins" DependsOnTargets="Build">
<Exec Command="dotnet test &quot;$(Solution)&quot; -c $(Configuration) --no-build --filter &quot;FullyQualifiedName~BundledPluginManifest&quot;" />
</Target>
<!-- Ensures a fresh publish output exists unless the caller explicitly reuses the output of the preceding publish step. -->
<Target Name="EnsurePublishedBundledPlugins">
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="Publish" Condition="'$(ReusePublishedBundledPlugins)' != 'true' And '$(_PublishedBundledPlugins)' != 'true'" />
</Target>
<!-- Verifies the manifest embedded in the published API assembly against the plugin binaries that were actually published. -->
<Target Name="VerifyPublishedBundledPlugins" DependsOnTargets="EnsurePublishedBundledPlugins">
<Error Condition="!Exists('$(ApiPublishDirectory)/Nemera.Presentation.Api.dll')" Text="The published API assembly is missing from '$(ApiPublishDirectory)'." />
<Error Condition="!Exists('$(ApiPublishDirectory)/plugins')" Text="The published bundled plugins are missing from '$(ApiPublishDirectory)/plugins'." />
<Exec Command="dotnet test &quot;$(Solution)&quot; -c $(Configuration) --no-build --filter &quot;FullyQualifiedName~PublishedBundledPluginManifest&quot;" EnvironmentVariables="NEMERA_API_PUBLISH_DIRECTORY=$(ApiPublishDirectory)" />
</Target>
<!-- Official release configuration must be validated before any build or test work starts. -->
<Target Name="ValidateOfficialRelease">
<Error Condition="'$(OfficialReleaseBuild)' != 'true'" Text="The Publish target is reserved for official release builds. Pass -p:OfficialReleaseBuild=true." />
<Error Condition="'$(Configuration)' != 'Release'" Text="Official releases must be published in the Release configuration." />
</Target>
<Target Name="Publish" DependsOnTargets="ValidateOfficialRelease;VerifyBundledPlugins">
<RemoveDir Directories="$(ApiPublishDirectory)" Condition="Exists('$(ApiPublishDirectory)')" />
<RemoveDir Directories="$(WebPublishDirectory)" Condition="Exists('$(WebPublishDirectory)')" />
<Error Condition="!Exists('$(BundledPluginsCurrentManifest)')" Text="The current bundled plugin manifest '$(BundledPluginsCurrentManifest)' is missing. Build the official plugins before publishing." />
<MakeDir Directories="$(ApiPublishDirectory)/plugins" />
<MSBuild Projects="@(BundledPluginProject)" Targets="Build" Properties="Configuration=$(Configuration);NemeraPluginsOutputDirectory=$(ApiPublishDirectory)/plugins/" />
<ItemGroup>
<_PublishedBundledPluginAssembly Include="$(ApiPublishDirectory)/plugins/Nemera.Plugins.*.dll" />
</ItemGroup>
<Error Condition="'@(_PublishedBundledPluginAssembly)' == ''" Text="No bundled plugin binaries were deployed to '$(ApiPublishDirectory)/plugins'." />
<GetFileHash Files="@(_PublishedBundledPluginAssembly)" Algorithm="SHA256">
<Output TaskParameter="Items" ItemName="_PublishedBundledPluginHash" />
</GetFileHash>
<WriteLinesToFile File="$(BundledPluginsCurrentManifest)" Lines="@(_PublishedBundledPluginHash->'%(Filename)%(Extension)|%(FileHash)')" Overwrite="true" WriteOnlyWhenDifferent="true" />
<Exec Command="dotnet publish &quot;$(RepoRoot)/src/Nemera.Presentation.Api/Nemera.Presentation.Api.csproj&quot; -c $(Configuration) -o &quot;$(ApiPublishDirectory)&quot; -p:OfficialReleaseBuild=true -p:BundledPluginsCurrentManifest=&quot;$(BundledPluginsCurrentManifest)&quot; -p:BundledPluginsPredeployed=true" />
<Exec Command="dotnet publish &quot;$(RepoRoot)/src/Nemera.Presentation.Web/Nemera.Presentation.Web.csproj&quot; -c $(Configuration) -o &quot;$(WebPublishDirectory)&quot;" />
<PropertyGroup>
<_PublishedBundledPlugins>true</_PublishedBundledPlugins>
</PropertyGroup>
</Target>
<!-- Official images must be Release builds, so they cannot bypass the release configuration or the manifest checks. -->
<Target Name="ValidateDockerRelease" Condition="'$(_OfficialReleaseBuild)' == 'true'">
<Error Condition="'$(Configuration)' != 'Release'" Text="Official Docker images must be built in the Release configuration." />
</Target>
<!-- Official images ship the verified publish output. Local images build from source so docker compose keeps working without a prior publish. -->
<Target Name="Docker" DependsOnTargets="$(_DockerDependsOn)">
<PropertyGroup>
<_ImageVersion Condition="'$(Version)' != ''">$(Version)</_ImageVersion>
<_ImageVersion Condition="'$(Version)' == ''">latest</_ImageVersion>
<_DockerApiDockerfile Condition="'$(_OfficialReleaseBuild)' == 'true'">$(RepoRoot)/src/Nemera.Presentation.Api/Dockerfile.release</_DockerApiDockerfile>
<_DockerApiDockerfile Condition="'$(_OfficialReleaseBuild)' != 'true'">$(RepoRoot)/src/Nemera.Presentation.Api/Dockerfile</_DockerApiDockerfile>
<_DockerApiContext Condition="'$(_OfficialReleaseBuild)' == 'true'">$(ApiPublishDirectory)</_DockerApiContext>
<_DockerApiContext Condition="'$(_OfficialReleaseBuild)' != 'true'">$(RepoRoot)</_DockerApiContext>
<_DockerWebDockerfile Condition="'$(_OfficialReleaseBuild)' == 'true'">$(RepoRoot)/src/Nemera.Presentation.Web/Dockerfile.release</_DockerWebDockerfile>
<_DockerWebDockerfile Condition="'$(_OfficialReleaseBuild)' != 'true'">$(RepoRoot)/src/Nemera.Presentation.Web/Dockerfile</_DockerWebDockerfile>
<_DockerWebContext Condition="'$(_OfficialReleaseBuild)' == 'true'">$(WebPublishDirectory)</_DockerWebContext>
<_DockerWebContext Condition="'$(_OfficialReleaseBuild)' != 'true'">$(RepoRoot)</_DockerWebContext>
</PropertyGroup>
<Exec Command="docker build -t nemera-api:$(_ImageVersion) -f &quot;$(_DockerApiDockerfile)&quot; &quot;$(_DockerApiContext)&quot;" />
<Exec Command="docker build -t nemera-web:$(_ImageVersion) -f &quot;$(_DockerWebDockerfile)&quot; &quot;$(_DockerWebContext)&quot;" />
</Target>
<!-- Recording is only allowed from a clean GitHub Actions checkout whose commit is the current origin/master. -->
<Target Name="ValidateBundledPluginsRecording">
<Error Condition="'$(AllowBundledPluginsRecording)' != 'true'" Text="Recording bundled plugin hashes is reserved for the release workflow. Pass -p:AllowBundledPluginsRecording=true only from CI." />
<Error Condition="'$(GITHUB_ACTIONS)' != 'true'" Text="Recording bundled plugin hashes is only allowed in GitHub Actions." />
<PropertyGroup>
<_ReleaseBranchIsValid>false</_ReleaseBranchIsValid>
<_ReleaseBranchIsValid Condition="'$(ReleaseBranch)' != '' And $(ReleaseBranch.StartsWith('release/'))">true</_ReleaseBranchIsValid>
</PropertyGroup>
<Error Condition="'$(_ReleaseBranchIsValid)' != 'true'" Text="Recording bundled plugin hashes requires a release/x.y.z branch." />
<Exec Command="git status --porcelain" WorkingDirectory="$(RepoRoot)" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" ItemName="_BundledPluginsGitStatus" />
</Exec>
<Error Condition="'@(_BundledPluginsGitStatus)' != ''" Text="Recording bundled plugin hashes requires a clean worktree. Commit or stash the changes first." />
<Exec Command="git rev-parse HEAD" WorkingDirectory="$(RepoRoot)" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" ItemName="_BundledPluginsHead" />
</Exec>
<Exec Command="git rev-parse origin/master" WorkingDirectory="$(RepoRoot)" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" ItemName="_BundledPluginsMasterHead" />
</Exec>
<Error Condition="'@(_BundledPluginsHead)' != '@(_BundledPluginsMasterHead)'" Text="Recording bundled plugin hashes requires the release branch to point at origin/master. Merge the previous trust-list pull request and recreate the release branch from master." />
</Target>
<Target Name="RecordBundledPlugins" DependsOnTargets="ValidateBundledPluginsRecording;Publish;VerifyPublishedBundledPlugins;RecordBundledPluginsFromPublish" />
<!-- VerifyPublishedBundledPlugins has already proved that the published plugin set exactly matches the embedded current manifest. -->
<Target Name="RecordBundledPluginsFromPublish" DependsOnTargets="ValidateOfficialRelease;ValidateBundledPluginsRecording;VerifyPublishedBundledPlugins">
<ItemGroup>
<_BundledPluginPublishedAssembly Include="$(ApiPublishDirectory)/plugins/Nemera.Plugins.*.dll" />
</ItemGroup>
<GetFileHash Files="@(_BundledPluginPublishedAssembly)" Algorithm="SHA256">
<Output TaskParameter="Items" ItemName="_RecordedBundledPluginHash" />
</GetFileHash>
<Error Condition="'@(_RecordedBundledPluginHash)' == ''" Text="No bundled plugin binaries were found in '$(ApiPublishDirectory)/plugins'." />
<Error Condition="!Exists('$(BundledPluginsManifest)')" Text="The bundled plugin trust manifest '$(BundledPluginsManifest)' is missing." />
<ReadLinesFromFile File="$(BundledPluginsManifest)">
<Output TaskParameter="Lines" ItemName="_ExistingBundledPluginManifestLine" />
</ReadLinesFromFile>
<ItemGroup>
<_NewBundledPluginManifestLine Include="@(_RecordedBundledPluginHash->'%(Filename)%(Extension)|%(FileHash)')" />
<_CombinedBundledPluginManifestLine Include="@(_ExistingBundledPluginManifestLine);@(_NewBundledPluginManifestLine)" />
</ItemGroup>
<!-- Rewrite the manifest as a deduplicated merge so a repeated run cannot append the same hash twice. -->
<RemoveDuplicates Inputs="@(_CombinedBundledPluginManifestLine)">
<Output TaskParameter="Filtered" ItemName="_DeduplicatedBundledPluginManifestLine" />
</RemoveDuplicates>
<WriteLinesToFile File="$(BundledPluginsManifest)" Lines="@(_DeduplicatedBundledPluginManifestLine)" Overwrite="true" />
</Target>
<Target Name="CI" DependsOnTargets="Test">
<Message Text="CI build complete." Importance="high" />
</Target>
</Project>