Skip to content

Throw PlatformNotSupportedException on non-Windows platforms (#32) #69

Throw PlatformNotSupportedException on non-Windows platforms (#32)

Throw PlatformNotSupportedException on non-Windows platforms (#32) #69

Workflow file for this run

name: Build and Test
on:
push:
branches: [ master, dev ]
tags: [ 'v*' ]
paths:
- 'src/**'
pull_request:
branches: [ master ]
paths:
- 'src/**'
workflow_dispatch:
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
NUGET_XMLDOC_MODE: skip
Dotnet_Sdk_Version: 8.0.x
Solution_Path: src/SslCertBinding.Net.sln
Artifact_Dir: src/artifacts/
Obj_Dir: src/artifacts/obj/
Coverage_Dir: src/artifacts/coverage/
NugetPackage_Dir: src/artifacts/package/
DotNetFrameworkToTestOnLinux: net6.0
jobs:
build:
name: Build and test on Windows
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.Dotnet_Sdk_Version }}
- name: Restore NuGet packages
run: dotnet restore "${{ env.Solution_Path }}"
- name: Build all targets
run: dotnet build "${{ env.Solution_Path }}" -c Release --no-restore
- name: Execute unit tests
run: dotnet test "${{ env.Solution_Path }}" -c Release --no-build --no-restore --verbosity normal --collect:"XPlat Code Coverage" --results-directory "${{ env.Coverage_Dir }}"
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
env_vars: ${{ runner.os }}
flags: unittests
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: Output artifacts
path: |
${{ env.Artifact_Dir }}
!${{ env.Obj_Dir }}
!${{ env.Coverage_Dir }}
if-no-files-found: error
test-on-linux:
name: Test on Linux
needs: [ build ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.Dotnet_Sdk_Version }}
- name: Execute unit tests
run: dotnet test "${{ env.Solution_Path }}" -c Release --framework "${{ env.DotNetFrameworkToTestOnLinux }}" --verbosity normal --collect:"XPlat Code Coverage" --results-directory "${{ env.Coverage_Dir }}"
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
env_vars: ${{ runner.os }}
flags: unittests
token: ${{ secrets.CODECOV_TOKEN }}
publish-nuget:
name: Publish NuGet packages to NuGet.org
needs: [ build, test-on-linux]
runs-on: ubuntu-latest
if: |
github.event.repository.fork == false &&
startsWith(github.ref, 'refs/tags/')
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: Output artifacts
path: ${{ env.Artifact_Dir }}
- name: Install .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.Dotnet_Sdk_Version }}
- name: Push NuGet packages to NuGet.org
run: dotnet nuget push "${{ env.NugetPackage_Dir }}**/*.nupkg" --api-key ${{ secrets.NUGET_TOKEN }} --skip-duplicate --source https://api.nuget.org/v3/index.json