fix: pipeline net config #196
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: .NET Core Desktop | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
strategy: | |
matrix: | |
configuration: [Release] | |
runs-on: windows-latest # For a list of available runner types, refer to | |
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on | |
env: | |
Proj_Name: ShortcutsGrid | |
Test_Proj_Dir: ShortcutsGrid.Tests | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# Install the .NET Core workload | |
- name: Install .NET Core | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild | |
- name: Setup MSBuild.exe | |
uses: microsoft/setup-msbuild@v2 | |
# Execute all unit tests and collect coverage | |
- name: Unit Tests and collect coverage | |
run: | | |
dotnet test --configuration Release --collect:"XPlat Code Coverage" /p:CollectCoverage=true | |
dir | |
# Install report generator and setup | |
- name: Report generator setup | |
run: | | |
dotnet tool install --global dotnet-reportgenerator-globaltool --version 4.8.13 | |
dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools --version 4.8.13 | |
dotnet new tool-manifest | |
dotnet tool install dotnet-reportgenerator-globaltool --version 4.8.13 | |
#https://danielpalme.github.io/ReportGenerator/usage.html | |
# Execute report generator | |
- name: Execute report generator | |
run: | | |
$curDir = Get-Location | |
cd ${{ env.Test_Proj_Dir }} | |
[xml]$xml = Get-Content ..\ShortcutsGrid\ShortcutsGrid.csproj | |
$version = $xml.Project.PropertyGroup.VersionPrefix | |
$url = "https://img.shields.io/badge/version-" + $version + "-blue.svg" | |
$wc = New-Object System.Net.WebClient | |
$wc.DownloadFile($url, ".github\badge_version.svg") | |
cd TestResults | |
$dirList = Get-ChildItem -Directory -Name -attributes D -Recurse | |
cd $dirList | |
$nmspc = "${{ env.Proj_Name }}" | |
$ExcludeList = "-" + $nmspc + ".App" | |
$ExcludeList += ";-" + $nmspc + ".Models.MessageBoxWrapper" | |
$ExcludeList += ";-" + $nmspc + ".Services.Run.RunDialog" | |
reportgenerator "-reports:coverage.cobertura.xml" "-targetdir:coveragereport" -reporttypes:Badges "-classfilters:$ExcludeList" | |
reportgenerator "-reports:coverage.cobertura.xml" "-targetdir:coveragereport" -reporttypes:Html "-classfilters:$ExcludeList" | |
cd coveragereport | |
copy badge_linecoverage.svg $curDir\.github | |
# PublishProfiles makes exes and adding them to artifacts | |
- name: Publish profiles | |
run: | | |
cd ${{ env.Proj_Name }} | |
#dotnet publish ShortcutsGrid.csproj /p:PublishProfile="Win System" | |
#copy "bin\Win System\net8.0-windows\publish\win-x64\Win System.exe" ..\\${{ env.Test_Proj_Dir }}\\TestResults | |
$exes = "Win System","Win Admin","Office","Utils","Browsers","Connections","Disk Tools","Audio","Image","Video","Hardware","Virtual Machines","Programming","Games" | |
foreach ($name in $exes){dotnet publish ShortcutsGrid.csproj /p:PublishProfile="$name"} | |
foreach ($name in $exes){copy "bin\$name\net8.0-windows\publish\win-x64\$name.exe" ..\\${{ env.Test_Proj_Dir }}\\TestResults} | |
# Upload artifacts in the ations section | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: artifacts | |
path: ${{ env.Test_Proj_Dir }}\\TestResults | |
retention-days: 5 | |
# Git - upload artifact back in the repo | |
- name: Git commands | |
if: ${{ github.event_name != 'pull_request'}} | |
run: | | |
git config --global user.email ${{ secrets.MY_EMAIL }} | |
git config --global user.name "from workflow" | |
git add .github/badge_linecoverage.svg | |
git add .github/badge_version.svg | |
git commit -m "add artifact files" | |
git push origin $github.ref_name | |
# github.ref_name is branch name |