Skip to content

Commit 25b19c7

Browse files
Merge pull request #10 from encryptedtouhid/feature/ci-cd
creating release with ci-cd
2 parents e853e05 + e4e7192 commit 25b19c7

4 files changed

Lines changed: 160 additions & 15 deletions

File tree

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup .NET
17+
uses: actions/setup-dotnet@v4
18+
with:
19+
dotnet-version: '8.0.x'
20+
21+
- name: Restore dependencies
22+
run: dotnet restore
23+
24+
- name: Build
25+
run: dotnet build --configuration Release --no-restore
26+
27+
- name: Test
28+
run: dotnet test --configuration Release --no-build --verbosity normal
29+
30+
- name: Pack (verify)
31+
run: dotnet pack CpuGuard.NET/CpuGuard.NET.csproj --configuration Release --no-build --output ./artifacts
32+
33+
- name: Upload artifacts
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: nuget-package
37+
path: ./artifacts/*.nupkg
38+
retention-days: 7

.github/workflows/release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Release to NuGet
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Setup .NET
16+
uses: actions/setup-dotnet@v4
17+
with:
18+
dotnet-version: '8.0.x'
19+
20+
- name: Extract version from tag
21+
id: get_version
22+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
23+
24+
- name: Restore dependencies
25+
run: dotnet restore
26+
27+
- name: Build
28+
run: dotnet build --configuration Release --no-restore
29+
30+
- name: Test
31+
run: dotnet test --configuration Release --no-build --verbosity normal
32+
33+
- name: Pack
34+
run: dotnet pack CpuGuard.NET/CpuGuard.NET.csproj --configuration Release --no-build -p:PackageVersion=${{ steps.get_version.outputs.VERSION }} --output ./artifacts
35+
36+
- name: Push to NuGet
37+
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
38+
39+
- name: Create GitHub Release
40+
uses: softprops/action-gh-release@v1
41+
with:
42+
files: ./artifacts/*.nupkg
43+
generate_release_notes: true
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CpuGuard.NET/CpuGuard.NET.csproj

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@
44
<TargetFramework>netstandard2.1</TargetFramework>
55
<Nullable>enable</Nullable>
66
<Version>2.0.0</Version>
7+
<PackageVersion>$(Version)</PackageVersion>
78
<Authors>Khaled Md Tuhidul Hossain</Authors>
89
<Company>EncryptedTouhid</Company>
910
<Description>Comprehensive resource management middleware for ASP.NET Core applications. Features include CPU and memory limiting, gradual throttling, rate limiting, health checks, OpenTelemetry metrics, and a real-time dashboard.</Description>
1011
<PackageTags>cpu limit middleware aspnetcore throttling performance memory rate-limiting health-check opentelemetry dashboard</PackageTags>
1112
<RepositoryUrl>https://github.com/encryptedtouhid/CpuGuard.NET</RepositoryUrl>
12-
<PackageLicenseFile>LICENSE</PackageLicenseFile>
13+
<RepositoryType>git</RepositoryType>
14+
<PackageProjectUrl>https://github.com/encryptedtouhid/CpuGuard.NET</PackageProjectUrl>
15+
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
1316
<PackageReadmeFile>README.md</PackageReadmeFile>
17+
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
18+
<IncludeSymbols>true</IncludeSymbols>
19+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1420
</PropertyGroup>
1521

1622
<ItemGroup>
@@ -29,19 +35,9 @@
2935
<EmbeddedResource Include="Dashboard\dashboard.html" />
3036
</ItemGroup>
3137

32-
33-
3438
<ItemGroup>
35-
<None Update="LICENSE">
36-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
37-
<Pack>True</Pack>
38-
<PackagePath>\</PackagePath>
39-
</None>
40-
<None Update="README.md">
41-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
42-
<Pack>True</Pack>
43-
<PackagePath>\</PackagePath>
44-
</None>
39+
<None Include="..\LICENSE.md" Pack="true" PackagePath="\" />
40+
<None Include="..\README.md" Pack="true" PackagePath="\" />
4541
</ItemGroup>
4642

4743
</Project>

RELEASE-NOTE.md

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,71 @@
1-
# Release Notes for CpuGuard.NET
2-
## Version 1.0.1
1+
# Release Notes for CpuGuard.NET
2+
3+
## Version 2.0.0
4+
5+
### Major Release - Comprehensive Resource Management
6+
7+
This release transforms CpuGuard.NET into a full-featured resource management middleware with 10 new capabilities.
8+
9+
#### New Features
10+
11+
1. **Memory Limiting (MemoryGuard)**
12+
- Monitor and limit memory usage with percentage or absolute byte thresholds
13+
- Configurable response handling when limits are exceeded
14+
15+
2. **Custom Response Handlers**
16+
- Define custom responses for throttled requests
17+
- Support for JSON, HTML, or any content type
18+
19+
3. **Event Callbacks**
20+
- Subscribe to `OnCpuLimitExceeded` and `OnMemoryLimitExceeded` events
21+
- Integrate with logging, alerting, and monitoring systems
22+
23+
4. **Health Check Integration**
24+
- ASP.NET Core health check support with `AddCpuGuardHealthChecks()`
25+
- Configurable degraded and unhealthy thresholds
26+
27+
5. **OpenTelemetry Metrics**
28+
- Built-in metrics: `cpuguard_requests_throttled_total`, `cpuguard_cpu_usage_percent`, etc.
29+
- Export to Prometheus, Grafana, and other observability platforms
30+
31+
6. **Gradual Throttling**
32+
- Progressive request delays as resource usage increases
33+
- Soft limit (start delaying) and hard limit (reject) thresholds
34+
- Linear or exponential delay modes
35+
36+
7. **Path Exclusions**
37+
- Exclude specific paths from all guards (e.g., `/health`, `/metrics`)
38+
- Support for custom exclusion predicates
39+
40+
8. **Rate Limiting**
41+
- Per-client rate limiting with Fixed Window, Sliding Window, or Token Bucket algorithms
42+
- CPU-aware rate limiting that reduces limits under high load
43+
- Standard `X-RateLimit-*` response headers
44+
45+
9. **Real-time Dashboard**
46+
- Built-in HTML dashboard with live charts at `/cpuguard/dashboard`
47+
- JSON stats API at `/cpuguard/stats` and `/cpuguard/stats/full`
48+
- CPU/memory gauges, request statistics, and system info
49+
50+
10. **Background Resource Monitoring**
51+
- Async CPU sampling via `ResourceMonitorService`
52+
- Accurate resource tracking without blocking requests
53+
54+
#### Breaking Changes
55+
56+
- Middleware now requires service registration via `AddCpuGuard()`, `AddMemoryGuard()`, etc.
57+
- Legacy API (`UseCpuLimitMiddleware`) still supported but deprecated
58+
59+
#### New Dependencies
60+
61+
- `Microsoft.Extensions.Hosting.Abstractions` (6.0.0)
62+
- `Microsoft.Extensions.Diagnostics.HealthChecks` (6.0.0)
63+
- `OpenTelemetry.Api` (1.7.0)
64+
- `System.Text.Json` (8.0.5)
65+
66+
---
67+
68+
## Version 1.0.1
369
#### Whole Application CPU Limit:
470

571
1. Introduced a middleware component to limit CPU usage across the entire ASP.NET Core application.

0 commit comments

Comments
 (0)