diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 04a7997..9ad9b8b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,192 +1,192 @@ -name: CI - -on: - push: - branches: [main] - pull_request: - branches: [main] - -env: - DOTNET_NOLOGO: true - -jobs: - pr-checks: - if: github.event_name == 'pull_request' - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: write - steps: - - name: Checkout - uses: actions/checkout@v6 - with: - fetch-depth: 0 - - - name: Setup .NET - uses: actions/setup-dotnet@v5 - with: - dotnet-version: | - 8.0.x - 10.0.x - - - name: Restore - run: dotnet restore JD.SemanticKernel.Extensions.slnx - - - name: Build (Release) - run: > - dotnet build JD.SemanticKernel.Extensions.slnx - --configuration Release - --no-restore - /p:ContinuousIntegrationBuild=true - - - name: Verify formatting - run: > - dotnet format JD.SemanticKernel.Extensions.slnx - --severity warn - --verify-no-changes - - - name: Test with coverage - run: > - dotnet test JD.SemanticKernel.Extensions.slnx - --configuration Release - --no-build - --collect:"XPlat Code Coverage" - -- - DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura - DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Include="[JD.SemanticKernel*]*" - DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Exclude="[*Tests]*" - - - name: Install ReportGenerator - run: dotnet tool update -g dotnet-reportgenerator-globaltool - - - name: Combine coverage reports - shell: bash - run: | - REPORTS=$(find . -type f -path "*/TestResults/*/coverage.cobertura.xml" | tr '\n' ';') - reportgenerator \ - -reports:"$REPORTS" \ - -targetdir:"coverage-report" \ - -reporttypes:"HtmlInline;Cobertura;TextSummary;Badges" \ - -assemblyfilters:"+JD.SemanticKernel*;-*Tests*" \ - -filefilters:"-**/*.Tests/*;-**/*Tests*/**" - echo "COVERAGE_SUMMARY<> $GITHUB_ENV - cat coverage-report/Summary.txt >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV - - - name: Upload coverage report - uses: actions/upload-artifact@v7 - with: - name: coverage-report - path: coverage-report - - - name: Add coverage summary to PR - uses: marocchino/sticky-pull-request-comment@v2 - with: - recreate: true - message: | - ## Code Coverage - ``` - ${{ env.COVERAGE_SUMMARY }} - ``` - - release: - if: github.event_name == 'push' && github.ref == 'refs/heads/main' - runs-on: ubuntu-latest - permissions: - contents: write - packages: write - steps: - - name: Checkout - uses: actions/checkout@v6 - with: - fetch-depth: 0 - - - name: Setup .NET - uses: actions/setup-dotnet@v5 - with: - dotnet-version: | - 8.0.x - 10.0.x - - - name: Restore - run: dotnet restore JD.SemanticKernel.Extensions.slnx - - - name: Determine version (NBGV) - id: nbgv - uses: dotnet/nbgv@master - with: - setAllVars: true - - - name: Build (Release) - run: > - dotnet build JD.SemanticKernel.Extensions.slnx - --configuration Release - --no-restore - /p:ContinuousIntegrationBuild=true - - - name: Test (Release) - run: > - dotnet test JD.SemanticKernel.Extensions.slnx - --configuration Release - --no-build - - - name: Pack - run: > - dotnet pack JD.SemanticKernel.Extensions.slnx - --configuration Release - --no-build - --output ./artifacts - /p:ContinuousIntegrationBuild=true - - - name: Upload packages - uses: actions/upload-artifact@v7 - with: - name: nuget-packages - path: | - ./artifacts/*.nupkg - - - name: Push to NuGet.org - env: - NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} - run: | - if [ -n "$NUGET_API_KEY" ]; then - dotnet nuget push ./artifacts/*.nupkg \ - --api-key "$NUGET_API_KEY" \ - --source https://api.nuget.org/v3/index.json \ - --skip-duplicate - else - echo "Skipping NuGet.org push: API key not set." - fi - - - name: Push to GitHub Packages - run: | - dotnet nuget push "./artifacts/*.nupkg" \ - --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \ - --api-key "${{ secrets.GITHUB_TOKEN }}" \ - --skip-duplicate - - - name: Create git tag - shell: bash - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - set -euo pipefail - TAG="v${NBGV_NuGetPackageVersion}" - if git rev-parse "$TAG" >/dev/null 2>&1; then - echo "Tag $TAG already exists — skipping." - else - gh api "repos/${{ github.repository }}/git/refs" \ - -X POST \ - -f "ref=refs/tags/$TAG" \ - -f "sha=${{ github.sha }}" - echo "Created tag $TAG" - fi - - - name: Create GitHub Release - uses: softprops/action-gh-release@v2 - with: - tag_name: v${{ env.NBGV_NuGetPackageVersion }} - name: Release v${{ env.NBGV_NuGetPackageVersion }} - files: | - ./artifacts/*.nupkg - generate_release_notes: true +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +env: + DOTNET_NOLOGO: true + +jobs: + pr-checks: + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Setup .NET + uses: actions/setup-dotnet@v5 + with: + dotnet-version: | + 8.0.x + 10.0.x + + - name: Restore + run: dotnet restore JD.SemanticKernel.Extensions.slnx + + - name: Build (Release) + run: > + dotnet build JD.SemanticKernel.Extensions.slnx + --configuration Release + --no-restore + /p:ContinuousIntegrationBuild=true + + - name: Verify formatting + run: > + dotnet format JD.SemanticKernel.Extensions.slnx + --severity warn + --verify-no-changes + + - name: Test with coverage + run: > + dotnet test JD.SemanticKernel.Extensions.slnx + --configuration Release + --no-build + --collect:"XPlat Code Coverage" + -- + DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura + DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Include="[JD.SemanticKernel*]*" + DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Exclude="[*Tests]*" + + - name: Install ReportGenerator + run: dotnet tool update -g dotnet-reportgenerator-globaltool + + - name: Combine coverage reports + shell: bash + run: | + REPORTS=$(find . -type f -path "*/TestResults/*/coverage.cobertura.xml" | tr '\n' ';') + reportgenerator \ + -reports:"$REPORTS" \ + -targetdir:"coverage-report" \ + -reporttypes:"HtmlInline;Cobertura;TextSummary;Badges" \ + -assemblyfilters:"+JD.SemanticKernel*;-*Tests*" \ + -filefilters:"-**/*.Tests/*;-**/*Tests*/**" + echo "COVERAGE_SUMMARY<> $GITHUB_ENV + cat coverage-report/Summary.txt >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + + - name: Upload coverage report + uses: actions/upload-artifact@v7 + with: + name: coverage-report + path: coverage-report + + - name: Add coverage summary to PR + uses: marocchino/sticky-pull-request-comment@v3 + with: + recreate: true + message: | + ## Code Coverage + ``` + ${{ env.COVERAGE_SUMMARY }} + ``` + + release: + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Setup .NET + uses: actions/setup-dotnet@v5 + with: + dotnet-version: | + 8.0.x + 10.0.x + + - name: Restore + run: dotnet restore JD.SemanticKernel.Extensions.slnx + + - name: Determine version (NBGV) + id: nbgv + uses: dotnet/nbgv@master + with: + setAllVars: true + + - name: Build (Release) + run: > + dotnet build JD.SemanticKernel.Extensions.slnx + --configuration Release + --no-restore + /p:ContinuousIntegrationBuild=true + + - name: Test (Release) + run: > + dotnet test JD.SemanticKernel.Extensions.slnx + --configuration Release + --no-build + + - name: Pack + run: > + dotnet pack JD.SemanticKernel.Extensions.slnx + --configuration Release + --no-build + --output ./artifacts + /p:ContinuousIntegrationBuild=true + + - name: Upload packages + uses: actions/upload-artifact@v7 + with: + name: nuget-packages + path: | + ./artifacts/*.nupkg + + - name: Push to NuGet.org + env: + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + run: | + if [ -n "$NUGET_API_KEY" ]; then + dotnet nuget push ./artifacts/*.nupkg \ + --api-key "$NUGET_API_KEY" \ + --source https://api.nuget.org/v3/index.json \ + --skip-duplicate + else + echo "Skipping NuGet.org push: API key not set." + fi + + - name: Push to GitHub Packages + run: | + dotnet nuget push "./artifacts/*.nupkg" \ + --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \ + --api-key "${{ secrets.GITHUB_TOKEN }}" \ + --skip-duplicate + + - name: Create git tag + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -euo pipefail + TAG="v${NBGV_NuGetPackageVersion}" + if git rev-parse "$TAG" >/dev/null 2>&1; then + echo "Tag $TAG already exists — skipping." + else + gh api "repos/${{ github.repository }}/git/refs" \ + -X POST \ + -f "ref=refs/tags/$TAG" \ + -f "sha=${{ github.sha }}" + echo "Created tag $TAG" + fi + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: v${{ env.NBGV_NuGetPackageVersion }} + name: Release v${{ env.NBGV_NuGetPackageVersion }} + files: | + ./artifacts/*.nupkg + generate_release_notes: true