Handle Events With Delegate #63
Workflow file for this run
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, Test, Publish | |
on: | |
push: | |
branches: [ main ] | |
paths-ignore: | |
- "*.md" | |
- "*.png" | |
- "*.drawio" | |
- ".gitignore" | |
tags: | |
- '[0-9]+.[0-9]+.[0-9]+*' | |
pull_request: | |
branches: [ main ] | |
paths-ignore: | |
- "*.md" | |
- "*.png" | |
- "*.drawio" | |
- ".gitignore" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
checks: write | |
steps: | |
- uses: actions/checkout@v4 | |
- id: set-version | |
name: Set Version | |
run: | | |
ref=${{ github.ref }} | |
pattern="^refs/tags/[0-9]+.[0-9]+.[0-9]+(-.+)?$" | |
if [[ $ref =~ $pattern ]]; then | |
is_release=true | |
else | |
is_release=false | |
fi | |
echo "IS_RELEASE=$is_release" >> $GITHUB_ENV | |
if $is_release == true; then | |
version=$(echo $ref | cut -c 11-) | |
else | |
version="0.0.1-build$(date +'%Y%m%d'-'%H%M%S')" | |
fi | |
echo "VERSION=$version" >> $GITHUB_ENV | |
- id: print-version | |
name: Print Version | |
run: | | |
echo "is release: ${{ env.IS_RELEASE }}" | |
echo "version: ${{ env.VERSION }}" | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- name: Restore dependencies | |
run: dotnet restore EventBrokerSlim.sln | |
- name: Build | |
run: dotnet build EventBrokerSlim.sln --no-restore --configuration Release -p:Version=${{ env.VERSION }} | |
- name: Run Unit Tests | |
run: dotnet test test/M.EventBrokerSlim.Tests/M.EventBrokerSlim.Tests.csproj --no-build --no-restore --verbosity normal --configuration Release --logger trx --collect:"XPlat Code Coverage" --results-directory testresults | |
- name: Install Markdown Test Report Tool | |
if: success() || failure() | |
run: dotnet tool install --global LiquidTestReports.Cli --version 2.0.0-beta.2 | |
- name: Generate Markdown Test Report | |
if: success() || failure() | |
run: liquid --inputs "File=**/*.trx;Format=Trx" --output-file testresults/testresults.md --title "Unit Tests" | |
- name: Output Unit Tests Summary | |
if: success() || failure() | |
run: | | |
summary=$(<"testresults/testresults.md") | |
echo "$summary" >> "$GITHUB_STEP_SUMMARY" | |
- name: Unit Tests Code Coverage Report | |
uses: danielpalme/ReportGenerator-GitHub-Action@5.2.4 | |
with: | |
reports: "**/coverage.cobertura.xml" | |
targetdir: "coveragereport" | |
reporttypes: "MarkdownSummaryGithub" | |
verbosity: "Info" | |
title: "Unit Tests Code Coverage" | |
toolpath: "reportgeneratortool" | |
- name: Output Code Coverage Summary | |
if: success() || failure() | |
run: | | |
summary=$(<"coveragereport/SummaryGithub.md") | |
echo "$summary" >> "$GITHUB_STEP_SUMMARY" | |
- name: Create NuGet Package | |
if: ${{ success() && env.IS_RELEASE == 'true' }} | |
run: dotnet pack src/M.EventBrokerSlim/M.EventBrokerSlim.csproj -p:PackageVersion=${{ env.VERSION }} --output ./ --configuration Release --no-restore --no-build -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg | |
- name: Publish NuGet Package | |
if: ${{ success() && env.IS_RELEASE == 'true' }} | |
run: dotnet nuget push "*.nupkg" -k ${{ secrets.NUGET_API }} -s https://api.nuget.org/v3/index.json |