Repository navigation
Add a release workflow using nuget.org trusted publishing - #4123
Merged
Merged
Conversation
Nerdbank.GitVersioning 3.x (adopted in e1d8e52) stopped putting the git height in the fourth component when version.json already uses {height} in the prerelease tag. Since then every build has had AssemblyVersion 1.2.0.0, and because StyleCop.Analyzers.CodeFixes.csproj derives the StyleCop.Analyzers.Unstable package version from AssemblyVersion, every build produced StyleCop.Analyzers.Unstable 1.2.0 (instead of 1.2.0.N) and a StyleCop.Analyzers 1.2.0-beta.N metadata package depending on it. Set AssemblyVersion and AssemblyFileVersion back to major.minor.patch.height, matching the 1.2.0-beta.556 release (1.2.0.556).
Releases have always been tagged with the bare version (1.2.0-beta.556), and
the nuspec release notes link to releases/<version>. nbgv tag defaults to
v{version}.
AArnott
marked this pull request as ready for review
October 7, 2026 21:39
This was referenced Oct 8, 2026
Closed
There was a problem hiding this comment.
🟡 Changes recommended
The CI trigger no longer builds master, blocking releases, and the package version contradicts the stated release scope.
2 open findings
What changed in this PR
Adds trusted NuGet publishing via GitHub OIDC and restores unique unstable package versions.
Changes:
- Adds package collection, validation, publishing, and release attachment.
- Restores Git height in assembly versions.
- Updates versioning and CI branch configuration.
| File | Description |
|---|---|
.github/workflows/release.yml |
Adds the trusted publishing workflow. |
.github/workflows/build.yml |
Changes CI branch triggers. |
StyleCop.Analyzers/Directory.Build.targets |
Restores Git height in assembly versions. |
StyleCop.Analyzers/version.json |
Changes version and release-tag configuration. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
AArnott
force-pushed
the
release-workflow
branch
from
October 11, 2026 19:16
ccd088b to
0a50a21
Compare
AArnott
commented
Oct 11, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4123 +/- ##
=======================================
Coverage 97.62% 97.62%
=======================================
Files 1283 1283
Lines 136089 136089
Branches 4369 4369
=======================================
Hits 132857 132857
Misses 2086 2086
Partials 1146 1146 🚀 New features to boost your workflow:
|
This was referenced Nov 11, 2026
This was referenced Nov 24, 2026
Open
Open
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Adds a release workflow that publishes the single
StyleCop.Analyzerspackage to nuget.org using nuget.org Trusted Publishing. GitHub OIDC is exchanged for a short-lived API key byNuGet/login; no API key secret is stored.Release flow
nbgv tag origin/mastercreates the release tag, then the tag is pushed.masteror the applicablevX.Yservicing branch, the release is published.release.ymlruns:actions: read,contents: read): resolves the tag to a commit, derives the matchingvX.Yservicing branch from the tag, finds the successful Build run for that commit onmasteror that servicing branch, downloads itsnuget-packagesartifact, and validates that it contains exactly one publicStyleCop.Analyzerspackage whose version matches the tag.release,id-token: writeonly): waits for approval, obtains a short-lived NuGet API key withNuGet/login, and pushes the package with--skip-duplicate.contents: write): uploads the package to the GitHub release when one exists.The workflow can also be started with
workflow_dispatchand ataginput to retry a release. Reusing the successful CI artifact ensures that the package being published is exactly the package that was tested. A release-tag build is not used because Nerdbank.GitVersioning produces private build metadata outside the configured public release refs.CI trigger changes
The Build workflow intentionally runs on pushes to
master,vX.Yservicing branches, andvalidate/*branches, and runs for pull requests regardless of their base branch. This ensures that release, servicing, and validation-branch changes are built and tested by the same workflow.Package and version changes
StyleCop.Analyzers;StyleCop.Analyzers.Unstableand the separate metadata package are no longer created.1.3-betais included.masterandvX.Yservicing branches; the version policy explicitly matches the repository'svX.Yservicing-branch convention.Validation and maintenance
release.ymluses PowerShell (pwsh)..g<sha>package versions.dotnet buildof the release package succeeds with zero warnings and zero errors.One-time setup
Maintainers must configure:
DotNetAnalyzers/StyleCopAnalyzers, workflowrelease.yml, and environmentrelease.releaseenvironment with required reviewers.NUGET_USERrepository variable containing the nuget.org account that owns the policy.