Skip to content

Build, test, and pack NuGet #2

Build, test, and pack NuGet

Build, test, and pack NuGet #2

Workflow file for this run

name: "build"
run-name: Build, test, and pack NuGet
on:
push:
branches: ["main"]
paths:
- "src/**"
pull_request:
branches: ["main"]
paths:
- "src/**"
- ".github/workflows/build-main.yml"
jobs:
package:
name: pack
runs-on: ubuntu-latest
outputs:
version: "${{ steps.gitversion.outputs.nuGetVersion }}"
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: "5.x"
preferLatestVersion: true
- name: Determine version
id: gitversion
uses: gittools/actions/gitversion/execute@v0
with:
updateAssemblyInfo: true
useConfigFile: true
configFilePath: gitversion.yml
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.x"
dotnet-quality: "ga"
- name: Build library
run: >
dotnet build src/Indicators.csproj
--configuration Release
--property:Version=${{ steps.gitversion.outputs.nuGetVersion }}
--property:ContinuousIntegrationBuild=true
-warnAsError
- name: Pack for NuGet
run: >
dotnet pack src/Indicators.csproj
--configuration Release
--no-build
--include-symbols
--output NuGet
-p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersion }}
- name: Save NuGet package
uses: actions/upload-artifact@v3
with:
name: packages
path: NuGet
- name: Show version
run: |
{
echo "### Identified semantic version"
echo "| Variable | Value |"
echo "| --------------- | ----------------------------------------------- |"
echo "| Major | ${{ steps.gitversion.outputs.major }} |"
echo "| Minor | ${{ steps.gitversion.outputs.minor }} |"
echo "| Patch | ${{ steps.gitversion.outputs.patch }} |"
echo "| PreReleaseTag | ${{ steps.gitversion.outputs.preReleaseTag }} |"
echo "| MajorMinorPatch | ${{ steps.gitversion.outputs.majorMinorPatch }} |"
echo "| SemVer | ${{ steps.gitversion.outputs.semVer }} |"
echo "| NuGetVersion | ${{ steps.gitversion.outputs.nuGetVersion }} |"
} >> $GITHUB_STEP_SUMMARY
testing:
name: test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.x"
dotnet-quality: "ga"
- name: Build solution
run: >
dotnet build
--configuration Release
--property:ContinuousIntegrationBuild=true
-warnAsError
- name: Test library
run: >
dotnet test
--configuration Release
--no-build
--verbosity normal
--collect:"XPlat Code Coverage"
--results-directory ./coverage
- name: Generate code coverage
uses: irongut/[email protected]
with:
filename: coverage/**/coverage.cobertura.xml
badge: true
fail_below_min: true
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '60 80'
- name: Update PR summmary
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md
- name: Save test results
uses: actions/upload-artifact@v3
with:
name: test-results
path: TestResults
if: ${{ always() }}