Skip to content

dotnet-main

dotnet-main #23

Workflow file for this run

# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: dotnet-main
on:
workflow_dispatch:
push:
branches: [ "main" ]
permissions:
contents: read
issues: read
checks: write
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
- name: setup
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
- name: retrieve version
uses: dotnet/nbgv@master
id: nbgv
- name: install
run: dotnet tool restore && dotnet restore
- name: format
run: dotnet format "./PiBox.sln" --verify-no-changes --no-restore
- name: build
run: dotnet build --no-restore --nologo -c Release
- name: test & cover
run: dotnet dotnet-dotcover test --no-build --no-restore --nologo -c Release --dcReportType=DetailedXML --logger trx --results-directory "./test-results"
- name: publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: test-results/**/*.trx
- name: publish coverage results
uses: im-open/code-coverage-report-generator@4
with:
reports: 'dotCover.Output.xml'
targetdir: './coverage-results'
title: dotnet code coverage
reporttypes: 'MarkdownSummary;'
assemblyfilters: +PiBox*
- name: Create a status check for the code coverage results
id: dotnet-coverage-check
#You may also reference just the major or major.minor version
uses: im-open/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
summary-file: './coverage-results/Summary.md'
report-name: '.NET Code Coverage' # Default: Code Coverage Results
check-name: 'dotnet code coverage' # Default: code coverage
create-status-check: false # Default: true
create-pr-comment: false # Default: true
update-comment-if-one-exists: false # Default: true
update-comment-key: 'dotnet' # Default: N/A, used to further identify a comment to update if this action is used more than once in a workflow
ignore-threshold-failures: false # Default: false
line-threshold: 80 # Default: 0, which means thresholds are not applied
branch-threshold: 0 # Default: 0, which means thresholds are not applied
- name: Upload coverage report artifact
uses: actions/upload-artifact@v3
with:
name: Coverage Report
path: coverage-results/**
- name: Write to Job Summary
run: cat ./coverage-results/Summary.md >> $GITHUB_STEP_SUMMARY
- name: Create package
run: dotnet pack --no-restore --nologo --no-build -p:PackageOutputPath='./publish' -c Release -p:PackageVersion=${NBGV_SimpleVersion} -p:PublicRelease=true -p:SymbolPackageFormat=snupkg --include-symbols --include-source
- name: Upload publish artifacts
uses: actions/upload-artifact@v3
with:
name: upload artifacts
path: '**/publish/*'
- name: Publish nuget packages
run: dotnet nuget push "**/publish/*.nupkg" -s 'https://api.nuget.org/v3/index.json' --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate