hotfix #49
Workflow file for this run
This file contains hidden or 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
# 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: .NET PreRelease | |
on: | |
push: | |
branches: [ "feature/**" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 9.0.x | |
- name: .NET Tool Restore | |
run: dotnet tool restore | |
- name: Version Bump | |
uses: SiqiLu/dotnet-bump-version@2.0.0 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
version_mask: 0.0.0.1 | |
version_files: "version.xml" | |
- name: Set Version Env Var | |
run: | | |
LIBRARY_VERSION=$(dotnet pwsh -c "(Select-Xml -Path ./version.xml -XPath '/Version' | Select-Object -ExpandProperty Node).InnerText") | |
LIBRARY_TAG=v$LIBRARY_VERSION-rc | |
echo "LIBRARY_VERSION=$LIBRARY_VERSION" >> $GITHUB_ENV | |
echo "LIBRARY_TAG=$LIBRARY_TAG" >> $GITHUB_ENV | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --no-restore /p:VersionPrefix=${{ env.LIBRARY_VERSION }} /p:VersionSuffix=rc | |
- name: Test | |
run: dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage" --settings ./tests/TempMail.Client.Tests/coverlet.runsettings --results-directory ./coverage | |
- name: Code Coverage Summary | |
run: | | |
dotnet pwsh -c \ | |
' | |
$lr = [System.Math]::Round( ` | |
$( ` | |
Select-Xml -Path ./coverage/*/coverage.cobertura.xml -XPath "//package" ` | |
| Select-Object -ExpandProperty Node ` | |
| Select-Object -Property line-rate)."line-rate", 2 ` | |
) * 100; | |
@{ | |
files = @{ | |
"temp-mail-dotnet-code-coverage.json" = @{ | |
content = $(@{ | |
schemaVersion = 1; | |
label = "Code Coverage"; | |
message = $lr.ToString(); | |
color = (&{if ($lr -ge 90) {"green"} else { if ($lr -gt 60) {"yellow"} else {"orange"} } }) | |
} | ConvertTo-Json) | |
} | |
} | |
} | ConvertTo-Json' > code-coverage-badge.json | |
- name: Create Awesome Badge | |
run: | | |
data=$(cat code-coverage-badge.json) | |
echo "$data" | |
curl -L \ | |
-X PATCH \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.GH_GIST_API_KEY }}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
"https://api.github.com/gists/89c85cdd66cced45519b7928f2740687" \ | |
-d "$data" | |
- name: Publish NuGet Packages | |
run: | |
mkdir ./package | |
cp ./src/TempMail.Client/bin/Debug/TempMail.Client.*.nupkg ./package | |
cp ./src/TempMail.Client.AspNetCore/bin/Debug/TempMail.Client.AspNetCore.*.nupkg ./package | |
dotnet nuget push ./package/TempMail.Client.*.nupkg -k ${{ secrets.NUGET_ORG_API_KEY }} -s https://api.nuget.org/v3/index.json | |
dotnet nuget push ./package/TempMail.Client.AspNetCore.*.nupkg -k ${{ secrets.NUGET_ORG_API_KEY }} -s https://api.nuget.org/v3/index.json | |
- name: GitHub Tag | |
uses: IIlyichev/github-tag-action@v6.3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
custom_tag: ${{ env.LIBRARY_TAG }} | |
tag_prefix: "" | |
- name: GitHub Release | |
uses: elgohr/Github-Release-Action@v5 | |
with: | |
title: ${{ env.LIBRARY_TAG }} | |
tag: ${{ env.LIBRARY_TAG }} | |
workdir: package |