Publish C# SDKs automatically
Publish C# SDKs automatically
You can publish SDKs generated in Postman to NuGet.org. Automated publishing is supported through GitHub Actions, which can be configured to publish your SDKs to NuGet.org whenever a new release is created in your GitHub repository. By default, the predefined workflow creates a new release every time an automatic PR is merged.
You can also publish manually from your local machine. To learn more, see Publish C# SDKs generated in Postman.
To publish your SDKs automatically, use a NuGet API key stored in GitHub secrets.
Prerequisites
- A NuGet.org account.
- The package ID is available, or you own it. The first push of a new ID registers it to your account.
- Optional but recommended: a reserved package ID prefix (for example,
YourCompany.*) so others can’t publish under your prefix.
Create a NuGet API key and add it to your GitHub repo
A NuGet API key (NUGET_API_KEY) is used to authenticate package publishing to NuGet.org.
To create a NuGet API key and add it to your GitHub repo, do the following:
- Sign in at NuGet.org and select Your username > API Keys > Create.
- Create an API key with Push scope and a glob pattern restricted to your package ID or prefix, and set an expiration (maximum 365 days).
- Copy the key (starts with
oy2...). It’s shown only once. - In GitHub, select your repository and click Settings > Secrets and variables > Actions > New repository secret. Name it
NUGET_API_KEYand paste the key.
- Keys expire (maximum 365 days). Rotate the secret before it expires to avoid CI failures.
- After a push, NuGet.org validates and indexes the package before it appears in search, which can take a few minutes.