diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c3f81e7..d8a32cd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ on: branches: [master] env: - MAJOR_MINOR: '0.4' + MAJOR_MINOR: '1.0' permissions: contents: write @@ -28,42 +28,17 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: | - 8.0.x - 9.0.x - 10.0.x - - - name: Restore - run: dotnet restore - - - name: Build - run: dotnet build -c Release --no-restore 2>&1 | tee build.log - - - name: Check warnings - run: | - WARNING_COUNT=$(grep -c " warning " build.log || true) - echo "Build warnings: $WARNING_COUNT" - if [ "$WARNING_COUNT" -gt 10 ]; then - echo "::error::Build has $WARNING_COUNT warnings (threshold: 10)" - exit 1 - fi - - - name: Test with coverage - # Skip Integration (needs Mongo/Redis) and TimeCritical (wall-clock asserts) tests on shared CI runners. - run: dotnet test -c Release --no-build --verbosity normal --filter "(Category!=Integration)&(Category!=TimeCritical)" --collect:"XPlat Code Coverage" --results-directory ./coverage - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v5 - with: - directory: ./coverage - fail_ci_if_error: false - token: ${{ secrets.CODECOV_TOKEN }} + dotnet-version: 10.0.x + # Version is computed BEFORE the build so it can be passed as -p:Version. + # Passing it only to `dotnet pack` sets PackageVersion alone, leaving + # AssemblyVersion and FileVersion at their default 1.0.0.0 inside the + # shipped assembly. - name: Compute version id: version run: | LATEST_TAG=$(git tag -l "${MAJOR_MINOR}.*" --sort=-v:refname \ - | grep -E "^${MAJOR_MINOR}\.[0-9]+$" \ + | { grep -E "^${MAJOR_MINOR}\.[0-9]+$" || true; } \ | head -1) if [ -z "$LATEST_TAG" ]; then @@ -98,25 +73,56 @@ jobs: echo "version=$PRE_VERSION" >> "$GITHUB_OUTPUT" echo "Computed pre-release version: $PRE_VERSION" - - name: Pack (stable — push to master) - if: github.ref == 'refs/heads/master' && github.event_name == 'push' + # Pull requests build the pre-release version, pushes to master the + # stable one. One value drives build and pack so the assembly and the + # package can never disagree. + - name: Resolve build version + id: buildversion + shell: bash run: | - dotnet pack Tharga.Cache/Tharga.Cache.csproj -c Release --no-build -o ./artifacts -p:PackageVersion=${{ steps.version.outputs.version }} - dotnet pack Tharga.Cache.Redis/Tharga.Cache.Redis.csproj -c Release --no-build -o ./artifacts -p:PackageVersion=${{ steps.version.outputs.version }} - dotnet pack Tharga.Cache.MongoDB/Tharga.Cache.MongoDB.csproj -c Release --no-build -o ./artifacts -p:PackageVersion=${{ steps.version.outputs.version }} - dotnet pack Tharga.Cache.File/Tharga.Cache.File.csproj -c Release --no-build -o ./artifacts -p:PackageVersion=${{ steps.version.outputs.version }} - dotnet pack Tharga.Cache.Blazor/Tharga.Cache.Blazor.csproj -c Release --no-build -o ./artifacts -p:PackageVersion=${{ steps.version.outputs.version }} - dotnet pack Tharga.Cache.Mcp/Tharga.Cache.Mcp.csproj -c Release --no-build -o ./artifacts -p:PackageVersion=${{ steps.version.outputs.version }} - - - name: Pack (pre-release — pull request) - if: github.event_name == 'pull_request' + if [ "${{ github.event_name }}" = "pull_request" ]; then + VERSION="${{ steps.preversion.outputs.version }}" + else + VERSION="${{ steps.version.outputs.version }}" + fi + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + echo "Building as: $VERSION" + + - name: Restore + run: dotnet restore + + - name: Build + run: dotnet build -c Release --no-restore -p:Version=${{ steps.buildversion.outputs.version }} 2>&1 | tee build.log + + - name: Check warnings + run: | + WARNING_COUNT=$(grep -c " warning " build.log || true) + echo "Build warnings: $WARNING_COUNT" + if [ "$WARNING_COUNT" -gt 10 ]; then + echo "::error::Build has $WARNING_COUNT warnings (threshold: 10)" + exit 1 + fi + + - name: Test with coverage + # Skip Integration (needs Mongo/Redis) and TimeCritical (wall-clock asserts) tests on shared CI runners. + run: dotnet test -c Release --no-build --verbosity normal --filter "(Category!=Integration)&(Category!=TimeCritical)" --collect:"XPlat Code Coverage" --results-directory ./coverage + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v5 + with: + directory: ./coverage + fail_ci_if_error: false + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Pack + shell: bash run: | - dotnet pack Tharga.Cache/Tharga.Cache.csproj -c Release --no-build -o ./artifacts -p:PackageVersion=${{ steps.preversion.outputs.version }} - dotnet pack Tharga.Cache.Redis/Tharga.Cache.Redis.csproj -c Release --no-build -o ./artifacts -p:PackageVersion=${{ steps.preversion.outputs.version }} - dotnet pack Tharga.Cache.MongoDB/Tharga.Cache.MongoDB.csproj -c Release --no-build -o ./artifacts -p:PackageVersion=${{ steps.preversion.outputs.version }} - dotnet pack Tharga.Cache.File/Tharga.Cache.File.csproj -c Release --no-build -o ./artifacts -p:PackageVersion=${{ steps.preversion.outputs.version }} - dotnet pack Tharga.Cache.Blazor/Tharga.Cache.Blazor.csproj -c Release --no-build -o ./artifacts -p:PackageVersion=${{ steps.preversion.outputs.version }} - dotnet pack Tharga.Cache.Mcp/Tharga.Cache.Mcp.csproj -c Release --no-build -o ./artifacts -p:PackageVersion=${{ steps.preversion.outputs.version }} + dotnet pack Tharga.Cache/Tharga.Cache.csproj -c Release --no-build -o ./artifacts -p:Version=${{ steps.buildversion.outputs.version }} + dotnet pack Tharga.Cache.Redis/Tharga.Cache.Redis.csproj -c Release --no-build -o ./artifacts -p:Version=${{ steps.buildversion.outputs.version }} + dotnet pack Tharga.Cache.MongoDB/Tharga.Cache.MongoDB.csproj -c Release --no-build -o ./artifacts -p:Version=${{ steps.buildversion.outputs.version }} + dotnet pack Tharga.Cache.File/Tharga.Cache.File.csproj -c Release --no-build -o ./artifacts -p:Version=${{ steps.buildversion.outputs.version }} + dotnet pack Tharga.Cache.Blazor/Tharga.Cache.Blazor.csproj -c Release --no-build -o ./artifacts -p:Version=${{ steps.buildversion.outputs.version }} + dotnet pack Tharga.Cache.Mcp/Tharga.Cache.Mcp.csproj -c Release --no-build -o ./artifacts -p:Version=${{ steps.buildversion.outputs.version }} - name: Upload artifacts uses: actions/upload-artifact@v4 @@ -138,10 +144,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: | - 8.0.x - 9.0.x - 10.0.x + dotnet-version: 10.0.x - name: Build for CodeQL run: dotnet build -c Release @@ -175,7 +178,7 @@ jobs: id: version run: | LATEST_TAG=$(git tag -l "${MAJOR_MINOR}.*" --sort=-v:refname \ - | grep -E "^${MAJOR_MINOR}\.[0-9]+$" \ + | { grep -E "^${MAJOR_MINOR}\.[0-9]+$" || true; } \ | head -1) if [ -z "$LATEST_TAG" ]; then @@ -191,9 +194,15 @@ jobs: - name: Push to NuGet run: | + # Only *.nupkg is globbed. Each matching package's sibling .snupkg is + # uploaded automatically by dotnet nuget push, so symbols must NOT be + # pushed explicitly or nuget.org sees a duplicate. + ls -l ./artifacts/ for pkg in ./artifacts/*.nupkg; do echo "Pushing $pkg..." - dotnet nuget push "$pkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate || true + # --skip-duplicate already makes a re-run of an existing version a + # success, so a failure here is a real failure and must fail the job. + dotnet nuget push "$pkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate done - name: Create GitHub Release @@ -249,7 +258,7 @@ jobs: id: version run: | LATEST_TAG=$(git tag -l "${MAJOR_MINOR}.*" --sort=-v:refname \ - | grep -E "^${MAJOR_MINOR}\.[0-9]+$" \ + | { grep -E "^${MAJOR_MINOR}\.[0-9]+$" || true; } \ | head -1) if [ -z "$LATEST_TAG" ]; then @@ -274,9 +283,15 @@ jobs: - name: Push to NuGet run: | + # Only *.nupkg is globbed. Each matching package's sibling .snupkg is + # uploaded automatically by dotnet nuget push, so symbols must NOT be + # pushed explicitly or nuget.org sees a duplicate. + ls -l ./artifacts/ for pkg in ./artifacts/*.nupkg; do echo "Pushing $pkg..." - dotnet nuget push "$pkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate || true + # --skip-duplicate already makes a re-run of an existing version a + # success, so a failure here is a real failure and must fail the job. + dotnet nuget push "$pkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate done - name: Create GitHub Pre-release @@ -300,10 +315,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: | - 8.0.x - 9.0.x - 10.0.x + dotnet-version: 10.0.x - name: Install DocFX run: dotnet tool install -g docfx diff --git a/Sample/Tharga.Cache.Console/Tharga.Cache.Console.csproj b/Sample/Tharga.Cache.Console/Tharga.Cache.Console.csproj index 88fd6c5..0519e87 100644 --- a/Sample/Tharga.Cache.Console/Tharga.Cache.Console.csproj +++ b/Sample/Tharga.Cache.Console/Tharga.Cache.Console.csproj @@ -7,7 +7,7 @@ - + diff --git a/Tharga.Cache.Blazor/Tharga.Cache.Blazor.csproj b/Tharga.Cache.Blazor/Tharga.Cache.Blazor.csproj index 384a02d..8179598 100644 --- a/Tharga.Cache.Blazor/Tharga.Cache.Blazor.csproj +++ b/Tharga.Cache.Blazor/Tharga.Cache.Blazor.csproj @@ -1,13 +1,13 @@  - net9.0;net10.0 + net10.0 enable - 1.0.0 Daniel Bohlin Thargelion AB Tharga Cache Blazor Component for manageing the Tharga Cache features in blazor. https://thargelion.net/assets/component-cache.png + MIT True README.md portable @@ -16,9 +16,19 @@ true true true + + snupkg - 1701;1702;CS1591;CS0809 + + 1701;1702;CS1591;CS0809;NU5048 @@ -27,7 +37,7 @@ - + diff --git a/Tharga.Cache.File/Tharga.Cache.File.csproj b/Tharga.Cache.File/Tharga.Cache.File.csproj index cdb1b14..314ee1b 100644 --- a/Tharga.Cache.File/Tharga.Cache.File.csproj +++ b/Tharga.Cache.File/Tharga.Cache.File.csproj @@ -2,16 +2,20 @@ net10.0 enable - 1.0.0 Daniel Bohlin Thargelion AB Tharga Cache File File cache features. https://thargelion.net/assets/component-cache.png + MIT True https://github.com/Tharga/Cache README.md true + + snupkg true true true @@ -21,7 +25,13 @@ enable - 1701;1702;CS1591 + + 1701;1702;CS1591;NU5048 diff --git a/Tharga.Cache.Mcp/Tharga.Cache.Mcp.csproj b/Tharga.Cache.Mcp/Tharga.Cache.Mcp.csproj index d84f08f..8effc5d 100644 --- a/Tharga.Cache.Mcp/Tharga.Cache.Mcp.csproj +++ b/Tharga.Cache.Mcp/Tharga.Cache.Mcp.csproj @@ -1,18 +1,22 @@ - + - net8.0;net9.0;net10.0 + net10.0 enable - 1.0.0 Daniel Bohlin Thargelion AB Tharga Cache MCP Exposes Tharga.Cache monitoring data (cache types, items, persistence health, fetch queue) and actions (clear all, clear stale) via MCP (Model Context Protocol). Plugs into Tharga.Mcp. https://thargelion.net/assets/component-cache.png + MIT True https://github.com/Tharga/Cache README.md true + + snupkg true true true @@ -22,7 +26,13 @@ - 1701;1702;CS1591;CS0809 + + 1701;1702;CS1591;CS0809;NU5048 @@ -33,7 +43,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tharga.Cache.MongoDB/Tharga.Cache.MongoDB.csproj b/Tharga.Cache.MongoDB/Tharga.Cache.MongoDB.csproj index 3e839c6..52f3d43 100644 --- a/Tharga.Cache.MongoDB/Tharga.Cache.MongoDB.csproj +++ b/Tharga.Cache.MongoDB/Tharga.Cache.MongoDB.csproj @@ -1,17 +1,21 @@  - net8.0;net9.0;net10.0 + net10.0 enable - 1.0.0 Daniel Bohlin Thargelion AB Tharga Cache MongoDB MongoDB cache features. https://thargelion.net/assets/component-cache.png + MIT True https://github.com/Tharga/Cache README.md true + + snupkg true true true @@ -21,7 +25,13 @@ enable - 1701;1702;CS1591 + + 1701;1702;CS1591;NU5048 @@ -39,7 +49,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Tharga.Cache.Redis/Tharga.Cache.Redis.csproj b/Tharga.Cache.Redis/Tharga.Cache.Redis.csproj index 2d419d8..f88a938 100644 --- a/Tharga.Cache.Redis/Tharga.Cache.Redis.csproj +++ b/Tharga.Cache.Redis/Tharga.Cache.Redis.csproj @@ -1,18 +1,22 @@  - net8.0;net9.0;net10.0 + net10.0 enable - 1.0.0 Daniel Bohlin Thargelion AB Tharga Cache Redis Redis cache features. https://thargelion.net/assets/component-cache.png + MIT True https://github.com/Tharga/Cache README.md true + + snupkg true true true @@ -23,7 +27,13 @@ - 1701;1702;CS1591 + + 1701;1702;CS1591;NU5048 diff --git a/Tharga.Cache.sln b/Tharga.Cache.sln index 74debe2..4e7182f 100644 --- a/Tharga.Cache.sln +++ b/Tharga.Cache.sln @@ -9,7 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tharga.Cache.Tests", "Tharg EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B2037503-DDED-46E6-BF80-9E2914A10291}" ProjectSection(SolutionItems) = preProject - azure-pipelines.yml = azure-pipelines.yml + .github\workflows\build.yml = .github\workflows\build.yml + LICENSE = LICENSE README.md = README.md switcher.json = switcher.json EndProjectSection diff --git a/Tharga.Cache/Tharga.Cache.csproj b/Tharga.Cache/Tharga.Cache.csproj index e32773b..59f110d 100644 --- a/Tharga.Cache/Tharga.Cache.csproj +++ b/Tharga.Cache/Tharga.Cache.csproj @@ -1,18 +1,22 @@  - net8.0;net9.0;net10.0 + net10.0 enable - 1.1.0 Daniel Bohlin Thargelion AB Tharga Cache Memory cache features. https://thargelion.net/assets/component-cache.png + MIT True https://github.com/Tharga/Cache README.md true + + snupkg true true true @@ -23,7 +27,13 @@ - 1701;1702;CS1591 + + 1701;1702;CS1591;NU5048