From 734b74ab765ec074e35a04eec9ec8321f99498ed Mon Sep 17 00:00:00 2001
From: Dan H <dan.r.hartley@gmail.com>
Date: Tue, 16 Jan 2024 22:02:22 +0000
Subject: [PATCH] build

---
 .github/workflows/main-build.yml | 20 +++++++++++++++++++-
 scripts/dotnet_build.sh          |  6 +++++-
 scripts/github_release.sh        |  5 ++---
 3 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/main-build.yml b/.github/workflows/main-build.yml
index 539aad9..eb7ee14 100644
--- a/.github/workflows/main-build.yml
+++ b/.github/workflows/main-build.yml
@@ -9,36 +9,54 @@ jobs:
     steps:
     - name: GIT checkout
       uses: actions/checkout@v4
+
     - name: Setup .NET 8
       uses: actions/setup-dotnet@v3
       with:
         dotnet-version: 8.0.x
+
     - name: Install dependencies
       run: dotnet restore
+
     - name: Build
       run: dotnet build --configuration Release --no-restore
+
     - name: Test net8.0
       run: dotnet test --configuration Release --no-build --verbosity normal --framework net8.0 --collect:"XPlat Code Coverage;Format=lcov"
+
     - name: Copy test coverage file
       run: Get-Childitem –Path ".\tests\Fastenshtein.Tests\TestResults\" -Include "coverage.info" -File -Recurse | Move-Item -Destination "coverage.net8.info"
+
     - name: Test net48
       run: dotnet test --configuration Release --no-build --verbosity normal --framework net48 --collect:"XPlat Code Coverage;Format=lcov"
+
     - name: Copy test coverage file
       run: Get-Childitem –Path ".\tests\Fastenshtein.Tests\TestResults\" -Include "coverage.info" -File -Recurse | Move-Item -Destination coverage.net48.info
+
     - name: Upload test coverage to Coveralls
       uses: coverallsapp/github-action@v2
       with:
         format: lcov
         files: coverage.net8.info coverage.net48.info
+
     - name: Pack
       run: dotnet pack --configuration Release --no-build --nologo
-    - name: Upload Artifact
+
+    - name: Upload NuGet package artifact
       uses: actions/upload-artifact@v4
       with:
         name: Fastenshtein
         path: src\Fastenshtein\bin\Release\Fastenshtein.*.*upkg
+
+    - name: Upload code coverage report artifact
+      uses: actions/upload-artifact@v4
+      with:
+        name: Code Coverage
+        path: coverage.*.info
+
     - name: Run benchmark
       run: .\benchmarks\Fastenshtein.Benchmarking\bin\Release\net8.0\Fastenshtein.Benchmarking.exe
+
     - name: Upload benchmarks-results to Artifacts
       uses: actions/upload-artifact@v4
       with:
diff --git a/scripts/dotnet_build.sh b/scripts/dotnet_build.sh
index 199212b..a9afb87 100755
--- a/scripts/dotnet_build.sh
+++ b/scripts/dotnet_build.sh
@@ -5,7 +5,11 @@ dotnet restore ../
 dotnet build ../ --configuration Release --no-restore /p:ContinuousIntegrationBuild=true
 
 if [[ $1 = "code_coverage" ]]; then
-  dotnet test ../ --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage;Format=lcov"
+  dotnet test ../ --configuration Release --no-build --verbosity normal --framework net8.0 --collect:"XPlat Code Coverage;Format=lcov"
+  find -name "coverage.info" -type f -exec mv {} ../coverage.net8.info \;
+
+  dotnet test ../ --configuration Release --no-build --verbosity normal --framework net48 --collect:"XPlat Code Coverage;Format=lcov"
+  find -name "coverage.info" -type f -exec mv {} ../coverage.net48.info \;
 else
   dotnet test ../ --configuration Release --no-build --verbosity normal
 fi
diff --git a/scripts/github_release.sh b/scripts/github_release.sh
index 86f836f..9d29dde 100755
--- a/scripts/github_release.sh
+++ b/scripts/github_release.sh
@@ -5,15 +5,14 @@ mkdir ../release
 
 dotnet --info > ../release/dotnet_info.txt
 
-find ../tests/Fastenshtein.Tests/TestResults -name coverage.info -exec cp "{}" ../release  \;
-
 find ../src/Fastenshtein/bin/Release -name "Fastenshtein.*.nupkg" -exec cp "{}" ../release/Fastenshtein.nupkg \;
 find ../src/Fastenshtein/bin/Release -name "Fastenshtein.*.snupkg" -exec cp "{}" ../release/Fastenshtein.snupkg \;
 
 gh release create $1 \
   "../release/Fastenshtein.nupkg" \
   "../release/Fastenshtein.snupkg" \
-  "../release/coverage.info#Code coverage report" \
+  "../coverage.net48.info#Code coverage report net48" \
+  "../coverage.net8.info#Code coverage report net8" \
   "../release/dotnet_info.txt#Built with" \
   --draft \
   --generate-notes
\ No newline at end of file