Skip to content

Shared github action to deploy a NuGet package to the public Microsoft NuGet gallery

License

Notifications You must be signed in to change notification settings

alsi-lawr/deploy-nuget

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deploy to NuGet

This reusable action builds a .NET project and deploys the resulting package to NuGet. It supports configuration for custom project paths and versioning, and securely handles the NuGet API key as a secret.

Test Workflow GitHub release) Licence

Usage

Simply use this action in your workflow by specifying the project file path, version, and your NuGet API key.

Inputs

  • project: Required. The path to the project directory of the .NET project that you want to build and deploy.
  • version: Required. The version to assign to the NuGet package. Typically, this is dynamically generated from tags or other versioning strategies.
  • nuget-api-key: Required. The NuGet API key used to push the package to NuGet.org. This should be stored securely as a GitHub Secret.
  • dotnet-version: Optional. The .NET SDK version to use. Defaults to 8.0.
  • build-only: Optional. If true, only build the project, do not deploy. Defaults to false.

Example

name: Deploy

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
      
      - name: Deploy to NuGet
        uses: alsi-lawr/deploy-nuget@v1
        with:
          project: 'src/MyProject'  # Specify the correct path to your project file directory
          version: 1.0.${{ github.run_number }}  # Example using the run number
          nuget-api-key: ${{ secrets.NUGET_API_KEY }}  # NuGet API key stored as a secret
          dotnet-version: '8.0'

Security

  • NuGet API Key: The nuget-api-key input should always be stored as a secret to avoid exposing sensitive information. You can add this secret in your GitHub repository settings under Settings > Secrets and variables > Actions.

Additional Notes

  • This action leverages Docker to run inside a .NET SDK container, ensuring a consistent build environment.
  • The action automatically restores NuGet packages, adds Microsoft.SourceLink.GitHub, and builds the project with various settings optimized for CI/CD environments.

Contributing

Contributions are welcome! Please refer to the contributing guidelines for more information.

About

Shared github action to deploy a NuGet package to the public Microsoft NuGet gallery

Resources

License

Stars

Watchers

Forks

Packages

No packages published