Merge pull request #5 from carldebilly/dev/update-artifacts #22
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 and Restore | |
on: | |
push: | |
branches: | |
- master | |
- release/* | |
pull_request: | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Need full history for GitVersion | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '8.0' | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '9.0' | |
- name: Build | |
run: dotnet build Yllibed.HttpServer.sln /p:Configuration=Release | |
- name: Collect NuGet packages | |
shell: pwsh | |
run: | | |
$OutputDir = "nuget-packages" | |
New-Item -ItemType Directory -Force -Path $OutputDir | |
Get-ChildItem -Path . -Recurse -Filter *.nupkg | Copy-Item -Destination $OutputDir | |
- name: Upload NuGet packages as artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
compression-level: 9 | |
name: nuget-packages | |
path: nuget-packages/ | |
if-no-files-found: error | |
- name: Test | |
#run: dotnet test Yllibed.HttpServer.sln /p:Configuration=Release /p:CollectCoverage=true /p:CoverletOutputFormat=opencover --no-build | |
run: dotnet test Yllibed.HttpServer.sln /p:Configuration=Release --no-build | |
publish: | |
if: github.ref == 'refs/heads/master' # Only on master branch (non-dev) | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: nuget-packages | |
path: ./nuget-packages | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '8.0' | |
- name: Push NuGet packages | |
env: | |
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
run: | | |
dotnet nuget push ./nuget-packages/*.nupkg --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json |