Support a few more scenarios thru XmlComments tests #97
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 | |
on: | |
push: | |
pull_request: | |
types: [opened, reopened] | |
branches: [main] | |
release: | |
types: [published] | |
env: | |
Config: Release | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup env event ${{ github.event_name }} action ${{ github.event.action }} ref ${{ github.ref }}@${{ github.sha }} | |
run: | | |
version=0.0.1-alpha | |
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-8) | |
if [[ ${{ github.ref }} =~ ^refs/tags/v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then | |
# override alpha version | |
if [[ ${{ github.event_name }} == release ]]; then | |
version=${BASH_REMATCH[1]} | |
else | |
version=${BASH_REMATCH[1]}-beta$SHORT_SHA | |
fi | |
fi | |
echo Version:$version | |
echo "Version $version" >> "$GITHUB_STEP_SUMMARY" | |
echo "version=$version" >> "$GITHUB_ENV" | |
echo "buildopts=--configuration $Config --no-restore -p:RepositoryCommit=$GITHUB_SHA -p:Version=$version" >> "$GITHUB_ENV" | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 7.0.x | |
- name: Install dependencies | |
run: dotnet restore *.sln || (ls -lha && exit 1) | |
- name: Build ${{ env.buildopts }} | |
run: dotnet build *.sln ${{ env.buildopts }} || dotnet build NET ${{ env.buildopts }} --verbosity detailed | |
- name: Run Tests | |
run: dotnet test *.sln ${{ env.buildopts }} --logger "trx;LogFileName=test-results.trx" --collect:"XPlat Code Coverage" --results-directory ./coverage | |
- name: Generate Test Report | |
uses: dorny/test-reporter@v1 | |
if: success() || failure() | |
with: | |
name: Test Report | |
path: "**/test-results.trx" | |
reporter: dotnet-trx | |
fail-on-error: true | |
- name: Code Coverage Report | |
if: success() || failure() | |
uses: irongut/CodeCoverageSummary@v1.3.0 | |
with: | |
filename: coverage/**/coverage.cobertura.xml | |
badge: true | |
fail_below_min: false | |
format: markdown | |
hide_branch_rate: false | |
hide_complexity: false | |
indicators: true | |
output: both | |
- name: Write to Job Summary | |
if: success() || failure() | |
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY | |
- name: Add Coverage PR Comment | |
uses: marocchino/sticky-pull-request-comment@v2 | |
if: (success() || failure()) && github.event_name == 'pull_request' | |
with: | |
recreate: true | |
path: code-coverage-results.md | |
- name: NuGet Package ${{ github.repository_owner }} ${{ env.version }} | |
run: | | |
dotnet pack VatValidation/VatValidation.csproj ${{ env.buildopts }} --verbosity normal --output . | |
ls -lh *nupkg | |
- name: NuGet Package Upload ${{ github.repository_owner }} ${{ env.version }} | |
if: github.event_name == 'release' | |
env: | |
ghnuget: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json | |
run: | | |
dotnet nuget push *.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source ${{ env.ghnuget }} --skip-duplicate | |
dotnet nuget push *.snupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source ${{ env.ghnuget }} --skip-duplicate | |
dotnet nuget push *.nupkg --api-key ${{ secrets.NUGETKEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate |