This is a simple build, test, pack and NuGet push for .NET projects. "Default" in that it assumes the dotnet
SDK commands build
, test
, pack
and nuget push
can be run and all required information is defaulted (e.g. solutions, projects, tests). It also assumes that all NuGet packages that are packed with the dotnet pack
SDK command will be pushed to the NuGet registry.
- If the
nuget_source
input isn't supplied, the organizational GitHub NuGet registry (https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
) is assumed.
This workflow leverages dotnet-build-test-pack-push-default.yml
and allows a simple configuration for push actions, ignoring pushed tags, with packages being pushed to the GitHub NuGet registry:
name: Push
on:
push:
branches:
- '**'
tags-ignore:
- '**'
jobs:
push:
permissions:
checks: write
contents: read
packages: write
uses: NetChris/workflows/.github/workflows/push-dotnet-build-test-pack-push-default.yml@SHA
Note the permissions
requirement.
To upgrade the .NET SDK version to use for dotnet
commands, update the following bit in each file where dotnet
is called:
# ...
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.x'
# ...
This workflow leverages dotnet-build-test-pack-push-default.yml
and allows a simple configuration for pre-release actions, with packages being pushed to NuGet.org:
# Put this in a "publish-nuget-org-pre-release.yml" file
name: Pre-Release - NuGet.org
on:
release:
types: [prereleased]
jobs:
push:
permissions:
contents: read
packages: write
uses: NetChris/workflows/.github/workflows/pre-release-nuget-org.yml@SHA
secrets: inherit
- Note the
permissions
requirement - Note the
secrets: inherit
requirement - Replace
SHA
with the appropriate SHA version of this repository - A similar workflow exists,
pre-release-nuget-github.yml
, for the GitHub NuGet registry
This workflow leverages dotnet-build-test-pack-push-default.yml
and allows a simple configuration for release actions, with packages being pushed to NuGet.org:
# Put this in a "publish-nuget-org-release.yml" file
name: Release - NuGet.org
on:
release:
types: [released]
jobs:
push:
permissions:
contents: read
packages: write
uses: NetChris/workflows/.github/workflows/release-nuget-org.yml@SHA
secrets: inherit
- Note the
permissions
requirement - Note the
secrets: inherit
requirement - Replace
SHA
with the appropriate SHA version of this repository - A similar workflow exists,
release-nuget-github.yml
, for the GitHub NuGet registry