NuGet Package Publishing Guide¶
This guide provides step-by-step instructions for publishing NuGet packages to GitHub Packages for this repository.
1. Create a Personal Access Token (PAT) for GitHub Packages¶
- Go to https://github.com/settings/tokens to manage or create your Personal Access Tokens.
- Go to your GitHub account settings.
- Navigate to Developer settings > Personal access tokens > Tokens (classic).
- Click Generate new token.
- Give your token a name and select an expiration date.
- Under Select scopes, check at least:
repowrite:packagesread:packages- Click Generate token and copy the token. You will not be able to see it again!
2. Add the PAT as a GitHub Actions Secret¶
- Go to your repository on GitHub.
- Click Settings > Secrets and variables > Actions.
- Click New repository secret.
- Name the secret
NUGET_PUBLISH_TOKEN. - Paste your PAT as the value and save.
3. Update Nuget.config (for local development)¶
If you want to push packages from your local machine, add your PAT to your Nuget.config:
<configuration>
<packageSources>
<add key="Luckbox" value="https://nuget.pkg.github.com/<OWNER>/index.json" />
</packageSources>
<packageSourceCredentials>
<Luckbox>
<add key="Username" value="<YOUR_GITHUB_USERNAME>" />
<add key="ClearTextPassword" value="<YOUR_PERSONAL_ACCESS_TOKEN>" />
</Luckbox>
</packageSourceCredentials>
<packageSourceMapping>
<packageSource key="Luckbox">
<package pattern="LBS.*" />
<!-- Match the GitHub packages you reference -->
</packageSource>
</packageSourceMapping>
</configuration>
<OWNER> with your GitHub username or organization.
- Replace <YOUR_GITHUB_USERNAME> and <YOUR_PERSONAL_ACCESS_TOKEN> with your credentials.
4. Publishing from CI/CD (GitHub Actions)¶
- The workflow uses the
NUGET_PUBLISH_TOKENsecret to authenticate and push packages. - No manual update to
Nuget.configis needed for CI/CD; it is handled by the workflow.
5. Publishing from Local Machine (Optional)¶
- Ensure your
Nuget.configis updated as above. - Run the following commands:
For more details, see the GitHub Docs: Publishing a package.