Skip to content

Fix flacky test

Fix flacky test #6

name: Build and Publish
on:
push:
branches: [ master, main ]
tags:
- 'v*'
pull_request:
branches: [ master, main ]
workflow_dispatch:
inputs:
publish:
description: 'Publish to NuGet'
required: true
type: boolean
default: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- 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 --configuration Release --no-restore
- name: Test
run: dotnet test --configuration Release --no-build --verbosity normal
- name: Pack
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || github.event.inputs.publish == 'true')
run: dotnet pack --configuration Release --no-build --output ./artifacts
- name: Upload artifacts
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || github.event.inputs.publish == 'true')
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: ./artifacts/*.nupkg
publish:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || github.event.inputs.publish == 'true')
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: ./artifacts
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Publish to NuGet
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}