Skip to content

Commit 2d88d79

Browse files
committed
Add Trusted Publishing doc
1 parent d3a92e3 commit 2d88d79

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

docs/nuget-org/overview-nuget-org.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ Once you have a NuGet package (*.nupkg* file) to publish, you publish it to NuGe
3333

3434
When you [publish a package](../create-packages/creating-a-package.md), you include the API key value in the CLI command.
3535

36+
## Trusted publishing
37+
38+
NuGet.org supports [Trusted Publishing](trusted-publishing.md), which is a secure and streamlined way to publish NuGet packages.
39+
3640
## ID prefixes
3741

3842
When you publish packages, you can reserve and protect your identity by [reserving ID prefixes](id-prefix-reservation.md). When installing a package, package consumers are provided with additional information indicating that the package they are consuming is not deceptive in its identifying properties.

docs/nuget-org/trusted-publishing.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
title: Trusted publishing
3+
description: Trusted Publishing on nuget.org
4+
author: etvorun
5+
ms.author: evgenyt
6+
ms.date: 07/01/2025
7+
ms.topic: conceptual
8+
---
9+
10+
# Trusted Publishing on nuget.org
11+
12+
Trusted Publishing is a secure and streamlined way to publish NuGet packages without needing to manage long-lived API keys. Instead, it uses short-lived credentials issued by a trusted CI/CD system like GitHub Actions.
13+
14+
This approach improves security by reducing the risk of credential leaks and simplifies automation by eliminating the need to rotate or store API keys.
15+
16+
To learn more about the broader industry effort behind this, check out the [OpenSSF initiative](https://repos.openssf.org/trusted-publishers-for-all-package-repositories).
17+
18+
> ⚠️ **Note:** If you don't see the **Trusted Publishing** option in your nuget.org account, the feature may not be available for your account yet. It will roll out gradually as the feature becomes generally available.
19+
20+
21+
22+
## How it works
23+
24+
Trusted Publishing allows nuget.org to securely integrate with your CI/CD provider.
25+
26+
When your workflow runs, the CI/CD provider (like GitHub Actions) issues a short-lived token.
27+
This token is sent to nuget.org, which verifies it and uses it to generate a temporary API key.
28+
That API key is then used by the workflow to publish your package.
29+
This approach eliminates the need to store long-lived API keys and helps keep your publishing process secure and automated.
30+
31+
Currently, nuget.org supports [GitHub Actions](https://docs.github.com/actions/how-tos) as a trusted publisher.
32+
33+
## GitHub Actions
34+
35+
To use Trusted Publishing with GitHub Actions:
36+
37+
1. Log into nuget.org.
38+
2. Click your username in the top-right corner and select **Trusted Publishing** from the dropdown menu.
39+
3. Add a new Trusted Publisher, specifying your GitHub organization, repository, workflow file, and other required details.
40+
4. In GitHub, configure your GitHub Actions workflow to request a short-lived API key from nuget.org and publish your package.
41+
42+
Here's a basic GitHub Actions workflow YAML example:
43+
44+
```yaml
45+
steps:
46+
# TODO: steps to produce artifacts/my-sdk.nupkg
47+
# Get a short-lived NuGet API key to use for package publishing
48+
- name: NuGet login
49+
id: nuget_login
50+
uses: nuget/login@v1
51+
with:
52+
user: ${{secrets.NUGET_USER}}
53+
source: https://api.nuget.org/v3/index.json
54+
55+
# Use short-lived NuGet API key to publish the package
56+
- name: NuGet push
57+
run: dotnet nuget push artifacts/my-sdk.nupkg -k ${{steps.nuget_login.outputs.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json
58+
```
59+

0 commit comments

Comments
 (0)