Skip to content

Modernize GitHub workflows and finish NuGet trusted publishing - #7

Merged
ardalis merged 3 commits into
xunit-v3-mainfrom
workflows-trusted-publishing
Nov 25, 2026
Merged

ardalis merged 3 commits into
xunit-v3-mainfrom
workflows-trusted-publishing

Conversation

@ardalis

@ardalis ardalis commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Closes #6. Stacked on #9 (xunit v3). The base is xunit-v3-main; retarget to main once #9 merges.

Summary

Trusted publishing (publish.yml)

  • Calls ci.yml as a reusable workflow, then pushes the exact .nupkg that CI built and tested. Build, test and pack steps are no longer duplicated.
  • NuGet/login (OIDC → short-lived API key) and dotnet nuget push are in a separate publish job that runs only for tag refs. A manual workflow_dispatch on a branch now only builds and tests.
  • id-token: write is granted only to the publish job; the workflow default is contents: read.
  • NuGet/login is pinned to v1.2.0 (by SHA). Push uses --skip-duplicate.

CI (ci.yml)

  • Also runs on changes to tests/**, Directory.*.props, *.slnx, nuget.config and .github/workflows/** (before, only src/** triggered it).
  • permissions: contents: read, plus concurrency so a new push cancels older PR runs.
  • NuGet lock files are on (RestorePackagesWithLockFile). CI restores with --locked-mode and caches packages through setup-dotnet.
  • Uploads TRX test results (--report-xunit-trx) and Cobertura coverage (--coverlet, Microsoft.Testing.Platform flags) as the test-results artifact, and the package (nuget-package artifact).
  • Can be called from other workflows (workflow_call).

Other

  • All actions are pinned to commit SHAs with version comments.
  • New .github/dependabot.yml gives weekly, grouped updates for github-actions and nuget.

Manual steps (need a maintainer)

  • nuget.org → Trusted Publishing: add a policy for NimblePros.SharedKernel with owner NimblePros, repository SharedKernelSample, workflow file publish.yml, and no environment.
  • Confirm the NUGET_USER secret is the nuget.org username (profile name) of the policy owner.
  • After the first successful trusted publish, delete the NUGET_API_KEY repo secret and revoke that key on nuget.org. Nothing references it any more.
  • Optional: add a protected nuget environment with required reviewers. Then add environment: nuget to the publish job and set the same environment on the policy.

Test plan

  • actionlint passes on all workflows
  • Ran the CI steps locally on top of the xunit v3 changes: locked-mode restore, build, test (TRX and Cobertura produced), pack. 10/10 tests pass and NimblePros.SharedKernel.4.0.0.nupkg is produced.
  • CI green on this PR
  • First release after the policy is set up publishes through OIDC

🤖 Generated with Claude Code

ardalis and others added 2 commits November 25, 2026 08:38
- Target net11.0
- Ardalis.GuardClauses 6.0.0, Ardalis.Specification 10.0.0, Mediator 3.0.2
- Test packages: Microsoft.NET.Test.Sdk 18.12.0, coverlet.collector 10.1.1,
  AwesomeAssertions 9.6.0, Moq 4.21.0, xunit 2.9.3, xunit.runner.visualstudio 4.0.1
- Remove Microsoft.Extensions.Logging.Abstractions reference (NU1510: provided by net11.0)
- CI/publish workflows: .NET 11 SDK, actions/checkout v7, actions/setup-dotnet v6
- Bump package version to 4.0.0

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- ci.yml: broaden path filters, least-privilege permissions, concurrency,
  locked-mode restore with NuGet caching, TRX + coverage artifacts,
  pack and upload the nupkg, callable via workflow_call
- publish.yml: reuse ci.yml, push the CI-built package; OIDC login and push
  only run for tag refs, with id-token: write scoped to that job
- Pin all actions to commit SHAs (NuGet/login v1.2.0)
- Add Dependabot for github-actions and nuget
- Enable NuGet lock files

Refs #6

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ardalis ardalis mentioned this pull request Nov 25, 2026
3 of 4 tasks
- ci.yml: --report-xunit-trx and --coverlet replace VSTest --logger/--collect
- Watch global.json in CI path filters
- Dependabot test group: Microsoft.Testing.* instead of Microsoft.NET.Test.Sdk

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ardalis
ardalis changed the base branch from net11-upgrade to xunit-v3-main November 25, 2026 13:58
@ardalis
ardalis merged commit ba612e1 into xunit-v3-main Nov 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant