From 9f1ae8dbbe2069f87d19c6d6675ebc8e234fde6b Mon Sep 17 00:00:00 2001 From: lk-code <1656571+lk-code@users.noreply.github.com> Date: Tue, 4 Nov 2025 11:56:44 +0100 Subject: [PATCH 1/3] update cicd --- .github/workflows/dotnet.yml | 670 +++++++++++++++-------------- .github/workflows/pull-request.yml | 52 +-- source/FluentDataBuilder.slnx | 2 + 3 files changed, 368 insertions(+), 356 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 2348270..20eaa8b 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -1,337 +1,343 @@ name: .NET Build on: - push: - branches: - - main - workflow_dispatch: + push: + branches: + - main + workflow_dispatch: + +env: + DOTNET_VERSION: "8.0.x" + VERSION: 8.0.${{ github.run_number }} + USERNAME: lk-code + NUGET_FILE: "**/*.nupkg" jobs: - build: - - runs-on: windows-latest - - env: - VERSION: 8.0.${{ github.run_number }} - USERNAME: lk-code - NUGET_FILE: "**/*.nupkg" - - steps: - - - name: Checkout repository - uses: actions/checkout@v4.1.1 - - - name: Setup .NET - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 8.0.x - - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: 17 - distribution: 'zulu' - - - name: Restore dependencies - run: dotnet restore source/ - - - name: Cache SonarCloud packages - uses: actions/cache@v3 - with: - path: ~\sonar\cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - - - name: Cache SonarCloud scanner - id: cache-sonar-scanner - uses: actions/cache@v3 - with: - path: .\.sonar\scanner - key: ${{ runner.os }}-sonar-scanner - restore-keys: ${{ runner.os }}-sonar-scanner - - - name: Install SonarCloud scanner - if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' - shell: pwsh - run: | - New-Item -Path .\.sonar\scanner -ItemType Directory - dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner - - - name: Start Analyze - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - shell: pwsh - run: | - .\.sonar\scanner\dotnet-sonarscanner begin /k:"lk-code_fluent-data-builder" /o:"lk-code-github" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" - - - name: Initialize GitHub NuGet Provider - shell: pwsh - run: | - dotnet nuget add source --username ${{ env.USERNAME }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/lk-code/index.json" - - - - - name: Build FluentDataBuilder - shell: pwsh - run: | - dotnet build -c Release source/FluentDataBuilder/FluentDataBuilder.csproj - - - name: Pack FluentDataBuilder - shell: pwsh - run: | - dotnet pack -c Release source/FluentDataBuilder/FluentDataBuilder.csproj /p:PackageVersion=${{ env.VERSION }} - - - name: Temporary NuGet FluentDataBuilder - shell: pwsh - run: | - dotnet nuget push source/FluentDataBuilder/nupkg/FluentDataBuilder.${{ env.VERSION }}.nupkg --source https://nuget.pkg.github.com/lk-code/index.json --api-key ${{ secrets.GITHUB_TOKEN }} - - - name: Wait for FluentDataBuilder Published - shell: pwsh - run: | - $i = 0 - $max = 10 - $sleep = 5 - $url = "https://nuget.pkg.github.com/lk-code/fluentdatabuilder/${{ env.VERSION }}.json" - $headers = @{ - "Authorization" = "Bearer ${{ secrets.GITHUB_TOKEN }}" - } - do { - $i++ - Write-Host "Waiting for NuGet to publish $url" - Start-Sleep -Seconds $sleep - } while ((Invoke-WebRequest -Uri $url -UseBasicParsing -Headers $headers).StatusCode -ne 200 -and $i -lt $max) - if ($i -eq $max) { - throw "NuGet not published after $max tries" - } - - - - - name: Add NuGets FluentDataBuilder.Json - shell: pwsh - run: | - dotnet add source/FluentDataBuilder.Json/FluentDataBuilder.Json.csproj package FluentDataBuilder --version ${{ env.VERSION }} - - - name: Build FluentDataBuilder.Json - shell: pwsh - run: | - dotnet build -c Release source/FluentDataBuilder.Json/FluentDataBuilder.Json.csproj - - - name: Pack FluentDataBuilder.Json - shell: pwsh - run: | - dotnet pack -c Release source/FluentDataBuilder.Json/FluentDataBuilder.Json.csproj /p:PackageVersion=${{ env.VERSION }} - - - name: Temporary NuGet FluentDataBuilder.Json - shell: pwsh - run: | - dotnet nuget push source/FluentDataBuilder.Json/nupkg/FluentDataBuilder.Json.${{ env.VERSION }}.nupkg --source https://nuget.pkg.github.com/lk-code/index.json --api-key ${{ secrets.GITHUB_TOKEN }} - - - name: Wait for FluentDataBuilder.Json Published - shell: pwsh - run: | - $i = 0 - $max = 10 - $sleep = 5 - $url = "https://nuget.pkg.github.com/lk-code/fluentdatabuilder.json/${{ env.VERSION }}.json" - $headers = @{ - "Authorization" = "Bearer ${{ secrets.GITHUB_TOKEN }}" - } - do { - $i++ - Write-Host "Waiting for NuGet to publish $url" - Start-Sleep -Seconds $sleep - } while ((Invoke-WebRequest -Uri $url -UseBasicParsing -Headers $headers).StatusCode -ne 200 -and $i -lt $max) - if ($i -eq $max) { - throw "NuGet not published after $max tries" - } - - - - - name: Add NuGets FluentDataBuilder.NewtonsoftJson - shell: pwsh - run: | - dotnet add source/FluentDataBuilder.NewtonsoftJson/FluentDataBuilder.NewtonsoftJson.csproj package FluentDataBuilder --version ${{ env.VERSION }} - - - name: Build FluentDataBuilder.NewtonsoftJson - shell: pwsh - run: | - dotnet build -c Release source/FluentDataBuilder.NewtonsoftJson/FluentDataBuilder.NewtonsoftJson.csproj - - - name: Pack FluentDataBuilder.NewtonsoftJson - shell: pwsh - run: | - dotnet pack -c Release source/FluentDataBuilder.NewtonsoftJson/FluentDataBuilder.NewtonsoftJson.csproj /p:PackageVersion=${{ env.VERSION }} - - - name: Temporary NuGet FluentDataBuilder.NewtonsoftJson - shell: pwsh - run: | - dotnet nuget push source/FluentDataBuilder.NewtonsoftJson/nupkg/FluentDataBuilder.NewtonsoftJson.${{ env.VERSION }}.nupkg --source https://nuget.pkg.github.com/lk-code/index.json --api-key ${{ secrets.GITHUB_TOKEN }} - - - name: Wait for FluentDataBuilder.NewtonsoftJson Published - shell: pwsh - run: | - $i = 0 - $max = 10 - $sleep = 5 - $url = "https://nuget.pkg.github.com/lk-code/fluentdatabuilder.newtonsoftjson/${{ env.VERSION }}.json" - $headers = @{ - "Authorization" = "Bearer ${{ secrets.GITHUB_TOKEN }}" - } - do { - $i++ - Write-Host "Waiting for NuGet to publish $url" - Start-Sleep -Seconds $sleep - } while ((Invoke-WebRequest -Uri $url -UseBasicParsing -Headers $headers).StatusCode -ne 200 -and $i -lt $max) - if ($i -eq $max) { - throw "NuGet not published after $max tries" - } - - - - - name: Add NuGets FluentDataBuilder.Xml - shell: pwsh - run: | - dotnet add source/FluentDataBuilder.Xml/FluentDataBuilder.Xml.csproj package FluentDataBuilder --version ${{ env.VERSION }} - - - name: Build FluentDataBuilder.Xml - shell: pwsh - run: | - dotnet build -c Release source/FluentDataBuilder.Xml/FluentDataBuilder.Xml.csproj - - - name: Pack FluentDataBuilder.Xml - shell: pwsh - run: | - dotnet pack -c Release source/FluentDataBuilder.Xml/FluentDataBuilder.Xml.csproj /p:PackageVersion=${{ env.VERSION }} - - - name: Temporary NuGet FluentDataBuilder.Xml - shell: pwsh - run: | - dotnet nuget push source/FluentDataBuilder.Xml/nupkg/FluentDataBuilder.Xml.${{ env.VERSION }}.nupkg --source https://nuget.pkg.github.com/lk-code/index.json --api-key ${{ secrets.GITHUB_TOKEN }} - - - name: Wait for FluentDataBuilder.Xml Published - shell: pwsh - run: | - $i = 0 - $max = 10 - $sleep = 5 - $url = "https://nuget.pkg.github.com/lk-code/fluentdatabuilder.xml/${{ env.VERSION }}.json" - $headers = @{ - "Authorization" = "Bearer ${{ secrets.GITHUB_TOKEN }}" - } - do { - $i++ - Write-Host "Waiting for NuGet to publish $url" - Start-Sleep -Seconds $sleep - } while ((Invoke-WebRequest -Uri $url -UseBasicParsing -Headers $headers).StatusCode -ne 200 -and $i -lt $max) - if ($i -eq $max) { - throw "NuGet not published after $max tries" - } - - - - - name: Add NuGets FluentDataBuilder.Yaml - shell: pwsh - run: | - dotnet add source/FluentDataBuilder.Yaml/FluentDataBuilder.Yaml.csproj package FluentDataBuilder --version ${{ env.VERSION }} - - - name: Build FluentDataBuilder.Yaml - shell: pwsh - run: | - dotnet build -c Release source/FluentDataBuilder.Yaml/FluentDataBuilder.Yaml.csproj - - - name: Pack FluentDataBuilder.Yaml - shell: pwsh - run: | - dotnet pack -c Release source/FluentDataBuilder.Yaml/FluentDataBuilder.Yaml.csproj /p:PackageVersion=${{ env.VERSION }} - - - name: Temporary NuGet FluentDataBuilder.Yaml - shell: pwsh - run: | - dotnet nuget push source/FluentDataBuilder.Yaml/nupkg/FluentDataBuilder.Yaml.${{ env.VERSION }}.nupkg --source https://nuget.pkg.github.com/lk-code/index.json --api-key ${{ secrets.GITHUB_TOKEN }} - - - name: Wait for FluentDataBuilder.Yaml Published - shell: pwsh - run: | - $i = 0 - $max = 10 - $sleep = 5 - $url = "https://nuget.pkg.github.com/lk-code/fluentdatabuilder.yaml/${{ env.VERSION }}.json" - $headers = @{ - "Authorization" = "Bearer ${{ secrets.GITHUB_TOKEN }}" - } - do { - $i++ - Write-Host "Waiting for NuGet to publish $url" - Start-Sleep -Seconds $sleep - } while ((Invoke-WebRequest -Uri $url -UseBasicParsing -Headers $headers).StatusCode -ne 200 -and $i -lt $max) - if ($i -eq $max) { - throw "NuGet not published after $max tries" - } - - - - - name: Add NuGets FluentDataBuilder.Microsoft.Extensions.Configuration - shell: pwsh - run: | - dotnet add source/FluentDataBuilder.Microsoft.Extensions.Configuration/FluentDataBuilder.Microsoft.Extensions.Configuration.csproj package FluentDataBuilder --version ${{ env.VERSION }} - dotnet add source/FluentDataBuilder.Microsoft.Extensions.Configuration/FluentDataBuilder.Microsoft.Extensions.Configuration.csproj package FluentDataBuilder.Json --version ${{ env.VERSION }} - - - name: Build FluentDataBuilder.Microsoft.Extensions.Configuration - shell: pwsh - run: | - dotnet build -c Release source/FluentDataBuilder.Microsoft.Extensions.Configuration/FluentDataBuilder.Microsoft.Extensions.Configuration.csproj - - - name: Pack FluentDataBuilder.Microsoft.Extensions.Configuration - shell: pwsh - run: | - dotnet pack -c Release source/FluentDataBuilder.Microsoft.Extensions.Configuration/FluentDataBuilder.Microsoft.Extensions.Configuration.csproj /p:PackageVersion=${{ env.VERSION }} - - - name: Temporary NuGet FluentDataBuilder.Microsoft.Extensions.Configuration - shell: pwsh - run: | - dotnet nuget push source/FluentDataBuilder.Microsoft.Extensions.Configuration/nupkg/FluentDataBuilder.Microsoft.Extensions.Configuration.${{ env.VERSION }}.nupkg --source https://nuget.pkg.github.com/lk-code/index.json --api-key ${{ secrets.GITHUB_TOKEN }} - - - name: Wait for FluentDataBuilder.Microsoft.Extensions.Configuration Published - shell: pwsh - run: | - $i = 0 - $max = 10 - $sleep = 5 - $url = "https://nuget.pkg.github.com/lk-code/fluentdatabuilder.microsoft.extensions.configuration/${{ env.VERSION }}.json" - $headers = @{ - "Authorization" = "Bearer ${{ secrets.GITHUB_TOKEN }}" - } - do { - $i++ - Write-Host "Waiting for NuGet to publish $url" - Start-Sleep -Seconds $sleep - } while ((Invoke-WebRequest -Uri $url -UseBasicParsing -Headers $headers).StatusCode -ne 200 -and $i -lt $max) - if ($i -eq $max) { - throw "NuGet not published after $max tries" - } - - - - - name: Finish Analyze - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - shell: pwsh - run: | - .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" - - - name: Set Version Git Tag - run: | - git tag ${{ env.VERSION }} - git push origin ${{ env.VERSION }} - - - name: Upload Build Artifact - uses: actions/upload-artifact@v4.6.0 - with: - name: ${{ env.VERSION }} - path: "**/*.${{ env.VERSION }}.nupkg" - - - name: Publish - run: dotnet nuget push "**/*.${{ env.VERSION }}.nupkg" --no-symbols --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source "nuget.org" + build: + + runs-on: windows-latest + + steps: + + - name: Checkout repository + uses: actions/checkout@v4.1.1 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'zulu' + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: Install SonarQube Cloud scanner + run: | + dotnet tool install --global dotnet-sonarscanner + + - name: Install ReportGenerator + run: | + dotnet tool install --global dotnet-reportgenerator-globaltool + + - name: Install .NET Coverage + run: | + dotnet tool install --global dotnet-coverage + + - name: Restore dependencies + run: dotnet restore source/ + + - name: Begin SonarQube + shell: pwsh + env: + SONARTOKEN: ${{ secrets.SONAR_TOKEN }} + run: | + dotnet-sonarscanner begin ` + /k:"lk-code_fluent-data-builder" ` + /o:"lk-code-github" ` + /d:sonar.token="$env:SONARTOKEN" ` + /d:sonar.host.url="https://sonarcloud.io" ` + /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml ` + + - name: .NET Build + shell: pwsh + run: | + dotnet build --no-restore + + - name: Collect Test Coverage + shell: pwsh + run: | + dotnet-coverage collect "dotnet test ${{ env.UNIT_TEST_CSPROJ }} --no-build" -f xml -o "coverage.xml" + + + + - name: Initialize GitHub NuGet Provider + shell: pwsh + run: | + dotnet nuget add source --username ${{ env.USERNAME }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/lk-code/index.json" + + + + - name: Build FluentDataBuilder + shell: pwsh + run: | + dotnet build -c Release source/FluentDataBuilder/FluentDataBuilder.csproj + + - name: Pack FluentDataBuilder + shell: pwsh + run: | + dotnet pack -c Release source/FluentDataBuilder/FluentDataBuilder.csproj /p:PackageVersion=${{ env.VERSION }} + + - name: Temporary NuGet FluentDataBuilder + shell: pwsh + run: | + dotnet nuget push source/FluentDataBuilder/nupkg/FluentDataBuilder.${{ env.VERSION }}.nupkg --source https://nuget.pkg.github.com/lk-code/index.json --api-key ${{ secrets.GITHUB_TOKEN }} + + - name: Wait for FluentDataBuilder Published + shell: pwsh + run: | + $i = 0 + $max = 10 + $sleep = 5 + $url = "https://nuget.pkg.github.com/lk-code/fluentdatabuilder/${{ env.VERSION }}.json" + $headers = @{ + "Authorization" = "Bearer ${{ secrets.GITHUB_TOKEN }}" + } + do { + $i++ + Write-Host "Waiting for NuGet to publish $url" + Start-Sleep -Seconds $sleep + } while ((Invoke-WebRequest -Uri $url -UseBasicParsing -Headers $headers).StatusCode -ne 200 -and $i -lt $max) + if ($i -eq $max) { + throw "NuGet not published after $max tries" + } + + + + - name: Add NuGets FluentDataBuilder.Json + shell: pwsh + run: | + dotnet add source/FluentDataBuilder.Json/FluentDataBuilder.Json.csproj package FluentDataBuilder --version ${{ env.VERSION }} + + - name: Build FluentDataBuilder.Json + shell: pwsh + run: | + dotnet build -c Release source/FluentDataBuilder.Json/FluentDataBuilder.Json.csproj + + - name: Pack FluentDataBuilder.Json + shell: pwsh + run: | + dotnet pack -c Release source/FluentDataBuilder.Json/FluentDataBuilder.Json.csproj /p:PackageVersion=${{ env.VERSION }} + + - name: Temporary NuGet FluentDataBuilder.Json + shell: pwsh + run: | + dotnet nuget push source/FluentDataBuilder.Json/nupkg/FluentDataBuilder.Json.${{ env.VERSION }}.nupkg --source https://nuget.pkg.github.com/lk-code/index.json --api-key ${{ secrets.GITHUB_TOKEN }} + + - name: Wait for FluentDataBuilder.Json Published + shell: pwsh + run: | + $i = 0 + $max = 10 + $sleep = 5 + $url = "https://nuget.pkg.github.com/lk-code/fluentdatabuilder.json/${{ env.VERSION }}.json" + $headers = @{ + "Authorization" = "Bearer ${{ secrets.GITHUB_TOKEN }}" + } + do { + $i++ + Write-Host "Waiting for NuGet to publish $url" + Start-Sleep -Seconds $sleep + } while ((Invoke-WebRequest -Uri $url -UseBasicParsing -Headers $headers).StatusCode -ne 200 -and $i -lt $max) + if ($i -eq $max) { + throw "NuGet not published after $max tries" + } + + + + - name: Add NuGets FluentDataBuilder.NewtonsoftJson + shell: pwsh + run: | + dotnet add source/FluentDataBuilder.NewtonsoftJson/FluentDataBuilder.NewtonsoftJson.csproj package FluentDataBuilder --version ${{ env.VERSION }} + + - name: Build FluentDataBuilder.NewtonsoftJson + shell: pwsh + run: | + dotnet build -c Release source/FluentDataBuilder.NewtonsoftJson/FluentDataBuilder.NewtonsoftJson.csproj + + - name: Pack FluentDataBuilder.NewtonsoftJson + shell: pwsh + run: | + dotnet pack -c Release source/FluentDataBuilder.NewtonsoftJson/FluentDataBuilder.NewtonsoftJson.csproj /p:PackageVersion=${{ env.VERSION }} + + - name: Temporary NuGet FluentDataBuilder.NewtonsoftJson + shell: pwsh + run: | + dotnet nuget push source/FluentDataBuilder.NewtonsoftJson/nupkg/FluentDataBuilder.NewtonsoftJson.${{ env.VERSION }}.nupkg --source https://nuget.pkg.github.com/lk-code/index.json --api-key ${{ secrets.GITHUB_TOKEN }} + + - name: Wait for FluentDataBuilder.NewtonsoftJson Published + shell: pwsh + run: | + $i = 0 + $max = 10 + $sleep = 5 + $url = "https://nuget.pkg.github.com/lk-code/fluentdatabuilder.newtonsoftjson/${{ env.VERSION }}.json" + $headers = @{ + "Authorization" = "Bearer ${{ secrets.GITHUB_TOKEN }}" + } + do { + $i++ + Write-Host "Waiting for NuGet to publish $url" + Start-Sleep -Seconds $sleep + } while ((Invoke-WebRequest -Uri $url -UseBasicParsing -Headers $headers).StatusCode -ne 200 -and $i -lt $max) + if ($i -eq $max) { + throw "NuGet not published after $max tries" + } + + + + - name: Add NuGets FluentDataBuilder.Xml + shell: pwsh + run: | + dotnet add source/FluentDataBuilder.Xml/FluentDataBuilder.Xml.csproj package FluentDataBuilder --version ${{ env.VERSION }} + + - name: Build FluentDataBuilder.Xml + shell: pwsh + run: | + dotnet build -c Release source/FluentDataBuilder.Xml/FluentDataBuilder.Xml.csproj + + - name: Pack FluentDataBuilder.Xml + shell: pwsh + run: | + dotnet pack -c Release source/FluentDataBuilder.Xml/FluentDataBuilder.Xml.csproj /p:PackageVersion=${{ env.VERSION }} + + - name: Temporary NuGet FluentDataBuilder.Xml + shell: pwsh + run: | + dotnet nuget push source/FluentDataBuilder.Xml/nupkg/FluentDataBuilder.Xml.${{ env.VERSION }}.nupkg --source https://nuget.pkg.github.com/lk-code/index.json --api-key ${{ secrets.GITHUB_TOKEN }} + + - name: Wait for FluentDataBuilder.Xml Published + shell: pwsh + run: | + $i = 0 + $max = 10 + $sleep = 5 + $url = "https://nuget.pkg.github.com/lk-code/fluentdatabuilder.xml/${{ env.VERSION }}.json" + $headers = @{ + "Authorization" = "Bearer ${{ secrets.GITHUB_TOKEN }}" + } + do { + $i++ + Write-Host "Waiting for NuGet to publish $url" + Start-Sleep -Seconds $sleep + } while ((Invoke-WebRequest -Uri $url -UseBasicParsing -Headers $headers).StatusCode -ne 200 -and $i -lt $max) + if ($i -eq $max) { + throw "NuGet not published after $max tries" + } + + + + - name: Add NuGets FluentDataBuilder.Yaml + shell: pwsh + run: | + dotnet add source/FluentDataBuilder.Yaml/FluentDataBuilder.Yaml.csproj package FluentDataBuilder --version ${{ env.VERSION }} + + - name: Build FluentDataBuilder.Yaml + shell: pwsh + run: | + dotnet build -c Release source/FluentDataBuilder.Yaml/FluentDataBuilder.Yaml.csproj + + - name: Pack FluentDataBuilder.Yaml + shell: pwsh + run: | + dotnet pack -c Release source/FluentDataBuilder.Yaml/FluentDataBuilder.Yaml.csproj /p:PackageVersion=${{ env.VERSION }} + + - name: Temporary NuGet FluentDataBuilder.Yaml + shell: pwsh + run: | + dotnet nuget push source/FluentDataBuilder.Yaml/nupkg/FluentDataBuilder.Yaml.${{ env.VERSION }}.nupkg --source https://nuget.pkg.github.com/lk-code/index.json --api-key ${{ secrets.GITHUB_TOKEN }} + + - name: Wait for FluentDataBuilder.Yaml Published + shell: pwsh + run: | + $i = 0 + $max = 10 + $sleep = 5 + $url = "https://nuget.pkg.github.com/lk-code/fluentdatabuilder.yaml/${{ env.VERSION }}.json" + $headers = @{ + "Authorization" = "Bearer ${{ secrets.GITHUB_TOKEN }}" + } + do { + $i++ + Write-Host "Waiting for NuGet to publish $url" + Start-Sleep -Seconds $sleep + } while ((Invoke-WebRequest -Uri $url -UseBasicParsing -Headers $headers).StatusCode -ne 200 -and $i -lt $max) + if ($i -eq $max) { + throw "NuGet not published after $max tries" + } + + + + - name: Add NuGets FluentDataBuilder.Microsoft.Extensions.Configuration + shell: pwsh + run: | + dotnet add source/FluentDataBuilder.Microsoft.Extensions.Configuration/FluentDataBuilder.Microsoft.Extensions.Configuration.csproj package FluentDataBuilder --version ${{ env.VERSION }} + dotnet add source/FluentDataBuilder.Microsoft.Extensions.Configuration/FluentDataBuilder.Microsoft.Extensions.Configuration.csproj package FluentDataBuilder.Json --version ${{ env.VERSION }} + + - name: Build FluentDataBuilder.Microsoft.Extensions.Configuration + shell: pwsh + run: | + dotnet build -c Release source/FluentDataBuilder.Microsoft.Extensions.Configuration/FluentDataBuilder.Microsoft.Extensions.Configuration.csproj + + - name: Pack FluentDataBuilder.Microsoft.Extensions.Configuration + shell: pwsh + run: | + dotnet pack -c Release source/FluentDataBuilder.Microsoft.Extensions.Configuration/FluentDataBuilder.Microsoft.Extensions.Configuration.csproj /p:PackageVersion=${{ env.VERSION }} + + - name: Temporary NuGet FluentDataBuilder.Microsoft.Extensions.Configuration + shell: pwsh + run: | + dotnet nuget push source/FluentDataBuilder.Microsoft.Extensions.Configuration/nupkg/FluentDataBuilder.Microsoft.Extensions.Configuration.${{ env.VERSION }}.nupkg --source https://nuget.pkg.github.com/lk-code/index.json --api-key ${{ secrets.GITHUB_TOKEN }} + + - name: Wait for FluentDataBuilder.Microsoft.Extensions.Configuration Published + shell: pwsh + run: | + $i = 0 + $max = 10 + $sleep = 5 + $url = "https://nuget.pkg.github.com/lk-code/fluentdatabuilder.microsoft.extensions.configuration/${{ env.VERSION }}.json" + $headers = @{ + "Authorization" = "Bearer ${{ secrets.GITHUB_TOKEN }}" + } + do { + $i++ + Write-Host "Waiting for NuGet to publish $url" + Start-Sleep -Seconds $sleep + } while ((Invoke-WebRequest -Uri $url -UseBasicParsing -Headers $headers).StatusCode -ne 200 -and $i -lt $max) + if ($i -eq $max) { + throw "NuGet not published after $max tries" + } + + + + - name: End SonarQube + shell: pwsh + env: + SONARTOKEN: ${{ secrets.SONAR_TOKEN }} + run: | + dotnet-sonarscanner end /d:sonar.token="$env:SONARTOKEN" + + - name: Set Version Git Tag + run: | + git tag ${{ env.VERSION }} + git push origin ${{ env.VERSION }} + + - name: Upload Build Artifact + uses: actions/upload-artifact@v4.6.0 + with: + name: ${{ env.VERSION }} + path: "**/*.${{ env.VERSION }}.nupkg" + + - name: Publish + run: dotnet nuget push "**/*.${{ env.VERSION }}.nupkg" --no-symbols --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source "nuget.org" diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 62f117f..acc571d 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,30 +1,34 @@ name: Pull Request on: - pull_request: - branches: [ "main" ] - + pull_request: + branches: [ "main" ] + +env: + DOTNET_VERSION: "8.0.x" + jobs: - pull-request-check: + pull-request-check: + + runs-on: ubuntu-latest + + steps: + + - name: Checkout repository + uses: actions/checkout@v4.1.1 + with: + fetch-depth: 0 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} - runs-on: ubuntu-latest + - name: Restore dependencies + run: dotnet restore source/ - steps: - - - name: Setup .NET - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 8.0.x - - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Restore dependencies - run: dotnet restore source/ - - - name: Build and analyze - shell: pwsh - run: | - dotnet build --configuration Release --no-restore source/ - dotnet test source/ + - name: Build and analyze + shell: pwsh + run: | + dotnet build --configuration Release --no-restore source/ + dotnet test source/ diff --git a/source/FluentDataBuilder.slnx b/source/FluentDataBuilder.slnx index f2b7c35..fa95e7a 100644 --- a/source/FluentDataBuilder.slnx +++ b/source/FluentDataBuilder.slnx @@ -21,6 +21,8 @@ + + From 61a572e1cf854ce9113f8d74772a693b130a1c99 Mon Sep 17 00:00:00 2001 From: lk-code <1656571+lk-code@users.noreply.github.com> Date: Tue, 4 Nov 2025 12:03:53 +0100 Subject: [PATCH 2/3] update cicd --- .github/workflows/dotnet.yml | 3 ++- .github/workflows/pull-request.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 20eaa8b..32301ba 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -8,6 +8,7 @@ on: env: DOTNET_VERSION: "8.0.x" + PROJECT_FILE: "source/FluentDataBuilder.sln" VERSION: 8.0.${{ github.run_number }} USERNAME: lk-code NUGET_FILE: "**/*.nupkg" @@ -46,7 +47,7 @@ jobs: dotnet tool install --global dotnet-coverage - name: Restore dependencies - run: dotnet restore source/ + run: dotnet restore ${{ env.PROJECT_FILE }} - name: Begin SonarQube shell: pwsh diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index acc571d..c219291 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -6,6 +6,7 @@ on: env: DOTNET_VERSION: "8.0.x" + PROJECT_FILE: "source/FluentDataBuilder.sln" jobs: pull-request-check: @@ -25,7 +26,7 @@ jobs: dotnet-version: ${{ env.DOTNET_VERSION }} - name: Restore dependencies - run: dotnet restore source/ + run: dotnet restore ${{ env.PROJECT_FILE }} - name: Build and analyze shell: pwsh From 1dbdea79f9fb5af6bc59935a2e9e1e9f0d8cb4bf Mon Sep 17 00:00:00 2001 From: lk-code <1656571+lk-code@users.noreply.github.com> Date: Tue, 4 Nov 2025 12:05:54 +0100 Subject: [PATCH 3/3] update cicd --- .github/workflows/pull-request.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index c219291..732985f 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -31,5 +31,5 @@ jobs: - name: Build and analyze shell: pwsh run: | - dotnet build --configuration Release --no-restore source/ - dotnet test source/ + dotnet build --configuration Release --no-restore ${{ env.PROJECT_FILE }} + dotnet test ${{ env.PROJECT_FILE }}