Skip to content

Build and Publish NuGet Package #11

Build and Publish NuGet Package

Build and Publish NuGet Package #11

Workflow file for this run

name: Build and Publish NuGet Package
on:
push:
branches:
- test
tags:
- 'v*'
env:
DOTNET_VERSION: '8.0.x'
PROJECT_PATH: 'src/Invoicetronic.Sdk/Invoicetronic.Sdk.csproj'
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore dependencies
run: dotnet restore ${{ env.PROJECT_PATH }}
- name: Build
run: dotnet build ${{ env.PROJECT_PATH }} --configuration Release --no-restore
- name: Run tests
run: dotnet test --no-restore --verbosity normal
- name: Pack
run: dotnet pack ${{ env.PROJECT_PATH }} --configuration Release --no-build --output nupkgs
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: ./nupkgs/*.nupkg
generate_release_notes: true
make_latest: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Push to NuGet
if: startsWith(github.ref, 'refs/tags/')
run: dotnet nuget push ./nupkgs/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate