Build, Test, and Publish #3
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build, Test, and Publish | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '9.0.x' | |
- name: Install dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --configuration Release --no-restore | |
- name: Test | |
run: dotnet test --verbosity normal | |
publish-nuget: | |
needs: build-and-test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '9.0.x' | |
# Use GitVersion | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: '6.x' | |
- name: Determine Version | |
id: gitversion | |
uses: gittools/actions/gitversion/[email protected] | |
- name: Publish NuGet Package | |
run: | | |
dotnet nuget add source --name "nuget.org" --source "https://api.nuget.org/v3/index.json" | |
dotnet pack --configuration Release --no-build --output ./nupkg/ | |
dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source "nuget.org" | |
env: | |
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ steps.gitversion.outputs.semVer }} | |
name: v${{ steps.gitversion.outputs.semVer }} | |
files: | | |
./nupkg/*.nupkg |