fix(release): validate packaged NuGet README#197
Conversation
Use NuGet-compatible Markdown for the package README and verify every package carries the validated source file before upload or publication.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 035ce9133a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Detect unsupported HTML elements anywhere outside Markdown code spans and fenced code blocks so NuGet README validation cannot be bypassed by inline content.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b991c434b7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ) | ||
|
|
||
| $inCodeFence = $false | ||
| $unsupportedHtmlPattern = '</?(?:address|article|aside|blockquote|caption|center|col|colgroup|details|dialog|dir|div|dl|dt|dd|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|img|input|legend|li|link|main|menu|nav|ol|p|pre|script|section|style|summary|table|tbody|td|tfoot|th|thead|title|tr|ul)\b[^>]*>' |
There was a problem hiding this comment.
Reject unsupported HTML tags outside the hard-coded list
The validator only recognizes the enumerated element names, so raw HTML such as <span>text</span>, <a href="...">, <br>, or <svg> passes validation even though NuGet's Markdown renderer does not support raw HTML. In that scenario the release workflow still uploads a README containing literal markup; match arbitrary HTML element names outside code spans/fences rather than maintaining an incomplete block-tag allowlist.
Useful? React with 👍 / 👎.
| if ($line -match '^\s*(```|~~~)') { | ||
| $inCodeFence = -not $inCodeFence |
There was a problem hiding this comment.
Track the opening Markdown fence marker
This toggles state for every line beginning with either three backticks or three tildes, regardless of the opener's marker, length, or valid indentation. For example, ~~~ inside a backtick-fenced example incorrectly ends validation's fence, and the real closing backticks then put it back inside one, allowing raw HTML later in the README to escape validation; similarly, four-space-indented backticks are not a CommonMark fence but disable checks here. Track the actual opening marker and minimum length, and only accept a corresponding valid closing fence.
Useful? React with 👍 / 👎.
What does this PR do?
.nupkgcontains the sourceREADME.mdand rejects unsupported raw HTML before artifact upload or NuGet publication.[Unreleased].Why is this change needed?
NuGet.org displays the existing
<h1>and<img>tags as literal text, leaving the package page malformed.Fixes #196
How was this tested?
Passed:
dotnet pack HelmSharp.sln --configuration Release --no-build --no-restore --output C:\tmp\helmsharp-readme-validation-20260717Passed:
./scripts/VerifyPackageReadme.ps1 -PackageDirectory C:\tmp\helmsharp-readme-validation-20260717(9 packages)Attempted:
dotnet test HelmSharp.sln --configuration Release --no-build --no-restore; four existing network-dependent golden tests failed on HTTP 502 across net8.0, net9.0, and net10.0.dotnet build HelmSharp.sln --configuration Releasedotnet test HelmSharp.sln --configuration ReleaseChecklist