Skip to content

Publish to NuGet in CI build #53

Publish to NuGet in CI build

Publish to NuGet in CI build #53

Workflow file for this run

name: .NET
on:
push:
branches: [ "main", "release/*" ]
pull_request:
branches: [ "main", "release/*" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work
- uses: dotnet/nbgv@master
with:
setAllVars: true
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Test
run: dotnet test --no-build --verbosity normal --configuration Release
- name: Pack NuGet package
if: github.event_name == 'push'
run: dotnet pack --no-build --configuration Release --output ./artifacts
- name: Upload NuGet artifacts
if: github.event_name == 'push'
uses: actions/upload-artifact@v4
with:
name: Syncerbell-${{ env.NBGV_NuGetPackageVersion }}
path: |
./artifacts/*.nupkg
./artifacts/*.snupkg
if-no-files-found: warn
- name: Publish to NuGet
if: github.event_name == 'push'
run: dotnet nuget push "./artifacts/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json