A reusable workflow for deploying to NuGet.
- Add a new workflow under
.github/workflows/
with the following contents.name: Deploy on: push: branches: - release/nuget jobs: deploy: uses: Arthri/deploy-nuget/.github/workflows/deploy.yml@v1 secrets: NUGET-API-KEY: ${{ secrets.NUGET_API_KEY }}
- Create a new environment named
NuGet (Stable)
with a secret namedNUGET-API-KEY
containing the API key used to publish packages to NuGet.
- Create a pull request from
master
torelease/nuget
. - Merge pull request.
- Expect workflow to build project and upload NuGet package to NuGet.
- Head to your repository's settings tab.
- Go to
Code and automation > Environments
. - Create a new environment named
NuGet (Stable)
. - Configure environment.
- Add a secret named
NUGET-API-KEY
jobs:
deploy:
uses: Arthri/deploy-nuget/.github/workflows/deploy.yml@v1
with:
changelog: |
- Added this
- Removed that
By default, the workflow acquires NUGET-API-KEY
from an environment named NuGet (Stable)
. The environment name can be changed using the environment-name
parameter.
jobs:
deploy:
uses: Arthri/deploy-nuget/.github/workflows/deploy.yml@v1
with:
environment-name: Custom Environment Name
By default, the workflow builds the singular solution or csproj in the repository's root. If there is more than one solution or project in the root, a project must be specified manually using the project-path
parameter.
jobs:
deploy:
uses: Arthri/deploy-nuget/.github/workflows/deploy.yml@v1
with:
project-path: ./src/Test.App/Test.App.csproj
By default, the inputted version will be sanitized to remove the v
prefix and any directories. For example, a/b/c/v1.0.0
will turn into 1.0.0
, and v1.2.3
will turn into 1.2.3
. Sanitization is configurable. The following example demonstrates disabling version sanitization.
jobs:
deploy:
uses: Arthri/deploy-nuget/.github/workflows/deploy.yml@v1
with:
sanitize-version: false
By default, the package's version will be set to the $(Version)
property of a project. It can be overridden using configuration options.
jobs:
deploy:
uses: Arthri/deploy-nuget/.github/workflows/deploy.yml@v1
with:
version: v1.0.0