Skip to content

Add trusted nuget publish - #987

Merged
dtchepak merged 2 commits into
nsubstitute:mainfrom
zvirja:add-trusted-nuget-publish
Aug 9, 2026
Merged

Add trusted nuget publish#987
dtchepak merged 2 commits into
nsubstitute:mainfrom
zvirja:add-trusted-nuget-publish

Conversation

@zvirja

@zvirja zvirja commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Closes #958

Introduce trusted NuGet publish and push to NuGet when we run release_packages.yml pipeline. I configured the NuGet part and also added new environment in our configuration (is needed to make sure that API key could be only retrieved for this specific pipeline). I use this approach in other places so it shall all work fine without us updating anything going forward.

Packages will appear pushed under my name (not visible outside, but will appear e.g. in emails). If you have objections, you could re-configure the environment and put your own user name (you'll have to make sure to add proper record under the "Trusted Publishing" section on NuGet):

image

I also removed Version from csproj and instead calculate it based on the current tag value. Therefore release_packages.yml shall be run on tag only. This way it's a bit easier to maintain the product.

I kept triggering the pipeline manually. That's the part we could discuss. My suggestion is to add tags trigger - so if you push a tag, it's run automatically. But I leave this decision up to you @dtchepak.

@zvirja
zvirja requested a review from dtchepak August 8, 2026 20:59

@dtchepak dtchepak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @zvirja !

@dtchepak
dtchepak merged commit 8d3fcd7 into nsubstitute:main Aug 9, 2026
4 checks passed
@zvirja
zvirja deleted the add-trusted-nuget-publish branch August 9, 2026 06:59
@zvirja

zvirja commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@dtchepak What's your opinion on auto-trigger? Shall I do that as well? Or do you prefer keeping it manual?

@dtchepak

dtchepak commented Aug 9, 2026

Copy link
Copy Markdown
Member

@dtchepak What's your opinion on auto-trigger? Shall I do that as well? Or do you prefer keeping it manual?

oops replied on #988 (review)

Happy to go with trigger-on-tag, although would like to have a guard rail that prevents that if CHANGELOG isn't updated (e.g. still has unreleased heading, or latest version doesn't match tag), but can look at that in a separate commit (or just drop changelog in favour of github releases changelogs?)

@dtchepak

Copy link
Copy Markdown
Member

Found a potential issue with this for attempt at 6.2.0 release? https://github.com/nsubstitute/NSubstitute/actions/runs/31483094369/job/93752259341

Run dotnet nuget push bin/*.nupkg --source https://api.nuget.org/v3/index.json
  dotnet nuget push bin/*.nupkg --source https://api.nuget.org/v3/index.json
  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
  env:
    DOTNET_ROOT: C:\Program Files\dotnet
    NUGET_API_KEY: ***
error: File does not exist (bin/*.nupkg).

I'll try have a look at this tomorrow if you don't get a chance to in the meantime 🙇

@zvirja

zvirja commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

@dtchepak Thanks for testing and sorry for the hassle. I didn't have an opportunity to test it myself.
Let's see if my fix helps!

@dtchepak

Copy link
Copy Markdown
Member

🙌 https://www.nuget.org/packages/NSubstitute/6.2.0

Thanks a lot @zvirja !

@zvirja

zvirja commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

@dtchepak Thanks for the extremely quick feedback loop :) Have a lovely day!

This was referenced Aug 13, 2026
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.

NuGet Trusted Publishing

2 participants