Skip to content

Commit f91e286

Browse files
authored
Merge pull request #2 from Zio-Net/basic-ci
feat: Add CI and NuGet publishing workflows with version detection
2 parents c465432 + e4c4648 commit f91e286

File tree

4 files changed

+114
-0
lines changed

4 files changed

+114
-0
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
jobs:
8+
build-and-test:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Setup .NET
16+
uses: actions/setup-dotnet@v4
17+
with:
18+
dotnet-version: |
19+
8.0.x
20+
9.0.x
21+
10.0.x
22+
23+
- name: Restore
24+
run: dotnet restore
25+
26+
- name: Build
27+
run: dotnet build -c Release --no-restore
28+
29+
- name: Test
30+
run: dotnet test -c Release --no-build
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Publish NuGet Packages
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 2
16+
17+
- name: Setup .NET
18+
uses: actions/setup-dotnet@v4
19+
with:
20+
dotnet-version: |
21+
8.0.x
22+
9.0.x
23+
10.0.x
24+
25+
- name: Restore
26+
run: dotnet restore
27+
28+
- name: Build
29+
run: dotnet build -c Release --no-restore
30+
31+
- name: Test
32+
run: dotnet test -c Release --no-build
33+
34+
- name: Detect version changes
35+
id: version-check
36+
run: |
37+
check_version_change() {
38+
local file="$1"
39+
local output_name="$2"
40+
if git diff HEAD~1 HEAD -- "$file" | grep -q '<Version>'; then
41+
echo "${output_name}=true" >> "$GITHUB_OUTPUT"
42+
else
43+
echo "${output_name}=false" >> "$GITHUB_OUTPUT"
44+
fi
45+
}
46+
47+
check_version_change "src/TypedRequestContext/TypedRequestContext.csproj" "core_changed"
48+
check_version_change "src/TypedRequestContext.Propagation/TypedRequestContext.Propagation.csproj" "propagation_changed"
49+
50+
- name: Pack & Push TypedRequestContext
51+
if: steps.version-check.outputs.core_changed == 'true'
52+
run: |
53+
dotnet pack src/TypedRequestContext/TypedRequestContext.csproj -c Release --no-build -o ./nupkgs
54+
dotnet nuget push ./nupkgs/TypedRequestContext.*.nupkg \
55+
--api-key ${{ secrets.NUGET_API_KEY }} \
56+
--source https://api.nuget.org/v3/index.json \
57+
--skip-duplicate
58+
59+
- name: Pack & Push TypedRequestContext.Propagation
60+
if: steps.version-check.outputs.propagation_changed == 'true'
61+
run: |
62+
dotnet pack src/TypedRequestContext.Propagation/TypedRequestContext.Propagation.csproj -c Release --no-build -o ./nupkgs
63+
dotnet nuget push ./nupkgs/TypedRequestContext.Propagation.*.nupkg \
64+
--api-key ${{ secrets.NUGET_API_KEY }} \
65+
--source https://api.nuget.org/v3/index.json \
66+
--skip-duplicate

src/TypedRequestContext.Propagation/TypedRequestContext.Propagation.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,19 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<PackageId>TypedRequestContext.Propagation</PackageId>
8+
<Version>1.0.0</Version>
9+
<Authors>Otapiero</Authors>
810
<Description>Optional propagation extension for TypedRequestContext with serializer/deserializer and header provider support.</Description>
11+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
12+
<RepositoryUrl>https://github.com/Zio-Net/TypedRequestContext</RepositoryUrl>
13+
<PackageReadmeFile>README.md</PackageReadmeFile>
914
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1015
</PropertyGroup>
1116

17+
<ItemGroup>
18+
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
19+
</ItemGroup>
20+
1221
<ItemGroup>
1322
<ProjectReference Include="..\TypedRequestContext\TypedRequestContext.csproj" />
1423
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0" />

src/TypedRequestContext/TypedRequestContext.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,19 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<PackageId>TypedRequestContext</PackageId>
8+
<Version>1.0.0</Version>
9+
<Authors>Otapiero</Authors>
810
<Description>Typed request context middleware for ASP.NET Core with AsyncLocal accessor support.</Description>
11+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
12+
<RepositoryUrl>https://github.com/Zio-Net/TypedRequestContext</RepositoryUrl>
13+
<PackageReadmeFile>README.md</PackageReadmeFile>
914
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1015
</PropertyGroup>
1116

17+
<ItemGroup>
18+
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
19+
</ItemGroup>
20+
1221
<ItemGroup>
1322
<FrameworkReference Include="Microsoft.AspNetCore.App" />
1423
</ItemGroup>

0 commit comments

Comments
 (0)