Skip to content

Remove sonar qube junk files #47

Remove sonar qube junk files

Remove sonar qube junk files #47

Workflow file for this run

name: .NET Core
on:
push:
branches:
- develop
- beta
- stable
pull_request:
branches:
- develop
- beta
- stable
jobs:
build:
runs-on: windows-latest
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Install DocFX
if: github.ref == 'refs/heads/develop'
run: choco install docfx -y
- name: Install SonarCloud scanner
if: env.SONAR_TOKEN != '' && ((github.event_name == 'push' && github.ref == 'refs/heads/develop') || (github.event_name == 'pull_request' && github.base_ref == 'develop' && github.event.pull_request.head.repo.full_name == github.repository))
run: dotnet tool install --global dotnet-sonarscanner
- name: Begin SonarCloud analysis
if: env.SONAR_TOKEN != '' && ((github.event_name == 'push' && github.ref == 'refs/heads/develop') || (github.event_name == 'pull_request' && github.base_ref == 'develop' && github.event.pull_request.head.repo.full_name == github.repository))
run: |
dotnet sonarscanner begin `
/k:"justcoding121_advanced-algorithms" `
/o:"justcoding121" `
/d:sonar.token="$env:SONAR_TOKEN" `
/d:sonar.host.url="https://sonarcloud.io" `
/d:sonar.dotnet.excludeTestProjects=true `
/d:sonar.cs.opencover.reportsPaths="artifacts/test-results/**/coverage.opencover.xml" `
/d:sonar.cs.vstest.reportsPaths="artifacts/test-results/*.trx"
- name: Build
run: dotnet build src/Advanced.Algorithms.sln
- name: Test with coverage
run: dotnet test src/Advanced.Algorithms.sln --no-build --logger "trx;LogFileName=test-results.trx" --results-directory artifacts/test-results --collect:"XPlat Code Coverage;Format=opencover,cobertura"
- name: End SonarCloud analysis
if: env.SONAR_TOKEN != '' && ((github.event_name == 'push' && github.ref == 'refs/heads/develop') || (github.event_name == 'pull_request' && github.base_ref == 'develop' && github.event.pull_request.head.repo.full_name == github.repository))
run: dotnet sonarscanner end /d:sonar.token="$env:SONAR_TOKEN"
- name: Upload test and coverage results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-and-coverage-results
path: artifacts/test-results
if-no-files-found: warn
retention-days: 7
- name: Update Documentation
if: github.ref == 'refs/heads/develop'
run: docfx .github/docfx.json
- name: Publish Documentation
if: github.ref == 'refs/heads/develop'
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: Update documentation
committer_name: GitHub Actions
committer_email: actions@github.com
# Only commit DocFX output — never Sonar/coverage/tool install artifacts
add: 'docs'
publish:
name: Publish NuGet package
needs: build
if: github.event_name == 'push' && (github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/stable')
runs-on: windows-latest
environment: nuget-publish
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Pack Beta
if: github.ref == 'refs/heads/beta'
run: dotnet pack src/Advanced.Algorithms/Advanced.Algorithms.csproj --version-suffix "beta" --output artifacts
- name: Pack Stable
if: github.ref == 'refs/heads/stable'
run: dotnet pack src/Advanced.Algorithms/Advanced.Algorithms.csproj --output artifacts
- name: Resolve package version
id: package
run: |
$package = Get-ChildItem artifacts -Filter *.nupkg | Select-Object -First 1
if (-not $package) { throw "No NuGet package was produced." }
if ($package.BaseName -notmatch '^Advanced\.Algorithms\.(.+)$') {
throw "Unexpected package name: $($package.Name)"
}
$version = $Matches[1]
"name=$($package.Name)" >> $env:GITHUB_OUTPUT
"path=$($package.FullName)" >> $env:GITHUB_OUTPUT
"version=$version" >> $env:GITHUB_OUTPUT
"tag=$version" >> $env:GITHUB_OUTPUT
"prerelease=$(if ($version -match '-beta$') { 'true' } else { 'false' })" >> $env:GITHUB_OUTPUT
- name: NuGet login
id: login
uses: NuGet/login@v1
with:
user: ${{ secrets.NUGET_USER }}
- name: Publish package
run: |
dotnet nuget push "${{ steps.package.outputs.path }}" --source "nuget" --api-key "${{ steps.login.outputs.NUGET_API_KEY }}"
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
$tag = "${{ steps.package.outputs.tag }}"
$version = "${{ steps.package.outputs.version }}"
$package = "${{ steps.package.outputs.path }}"
$prerelease = "${{ steps.package.outputs.prerelease }}" -eq "true"
if (gh release view $tag 2>$null) {
Write-Host "Release $tag already exists; uploading package asset if missing."
gh release upload $tag $package --clobber
}
else {
$args = @(
"release", "create", $tag,
$package,
"--title", $version,
"--generate-notes",
"--target", $env:GITHUB_SHA
)
if ($prerelease) { $args += "--prerelease" }
gh @args
}