Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 fix in the installing template via nuget package #21

Merged
merged 4 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 43 additions & 48 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,66 +73,61 @@ categories:
# Using regex for defining rules - https://regexr.com/
# https://stackoverflow.com/questions/58899999/regexp-to-match-conventional-commit-syntax
# Note: because of escaping logic inside of release drafter our regex should be escaped correctly and drafter wil un-escape it internally
# - Escaped regex: When writing a regular expression as a string in code, special characters like (, ), and : need to be escaped with a backslash (\) because these characters have special meanings in regex.
# - Escaped regex: When writing a regular expression as a string in code, special characters like (, ), and : need to be escaped with a backslash (\) because these characters have special meanings in regex.
# - Unescaped regex: If you use a raw regex literal (i.e., surrounded by slashes /.../), the regex engine interprets it directly, and you don’t need to double-escape the special characters.
autolabeler:
- label: 'chore'
branch:
- '/^(chore)(\([a-z ]+\))?\/.+/'
title:
- '/^(chore)(\([a-z ]+\))?: .+/'
branch:
- '/^(chore)(\([a-z ]+\))?\/.+/'
title:
- '/^(chore)(\([a-z ]+\))?: .+/'
- label: 'enhancement'
branch:
- '/^(refactor)(\([a-z ]+\))?\/.+/'
title:
- '/^(refactor)(\([a-z ]+\))?: .+/'
branch:
- '/^(refactor)(\([a-z ]+\))?\/.+/'
title:
- '/^(refactor)(\([a-z ]+\))?: .+/'
- label: 'documentation'
branch:
- '/^(docs)(\([a-z ]+\))?\/.+/'
title:
- '/^(docs)(\([a-z ]+\))?: .+/'
branch:
- '/^(docs)(\([a-z ]+\))?\/.+/'
title:
- '/^(docs)(\([a-z ]+\))?: .+/'
- label: 'ci-cd'
branch:
- '/^(ci)(\([a-z ]+\))?\/.+/'
title:
- '/^(ci)(\([a-z ]+\))?: .+/'
- label: 'devops'
branch:
- '/^(ci)(\([a-z ]+\))?\/.+/'
title:
- '/^(ci)(\([a-z ]+\))?: .+/'
branch:
- '/^(ci)(\([a-z ]+\))?\/.+/'
title:
- '/^(ci)(\([a-z ]+\))?: .+/'
- label: 'test'
branch:
- '/^(test)(\([a-z ]+\))?\/.+/'
title:
- '/^(test)(\([a-z ]+\))?: .+/'
branch:
- '/^(test)(\([a-z ]+\))?\/.+/'
title:
- '/^(test)(\([a-z ]+\))?: .+/'
- label: 'bug'
branch:
- '/^(fix)(\([a-z ]+\))?\/.+/'
title:
- '/^(fix)(\([a-z ]+\))?: .+/'
branch:
- '/^(fix)(\([a-z ]+\))?\/.+/'
title:
- '/^(fix)(\([a-z ]+\))?: .+/'
- label: 'style'
branch:
- '/^(style)(\([a-z ]+\))?\/.+/'
title:
- '/^(style)(\([a-z ]+\))?: .+/'
branch:
- '/^(style)(\([a-z ]+\))?\/.+/'
title:
- '/^(style)(\([a-z ]+\))?: .+/'
- label: 'feature'
branch:
- '/^(feat)(\([a-z ]+\))?\/.+/'
title:
- '/^(feat)(\([a-z ]+\))?: .+/'
branch:
- '/^(feat)(\([a-z ]+\))?\/.+/'
title:
- '/^(feat)(\([a-z ]+\))?: .+/'
- label: 'minor'
branch:
- '/^(feat)(\([a-z ]+\))?\/.+/'
title:
- '/^(feat)(\([a-z ]+\))?: .+/'
branch:
- '/^(feat)(\([a-z ]+\))?\/.+/'
title:
- '/^(feat)(\([a-z ]+\))?: .+/'
- label: 'patch'
branch:
- '/^(fix)(\([a-z ]+\))?\/.+/'
- '/^(ci)(\([a-z ]+\))?\/.+/'
title:
- '/^(fix)(\([a-z ]+\))?: .+/'
- '/^(ci)(\([a-z ]+\))?: .+/'
branch:
- '/^(fix)(\([a-z ]+\))?\/.+/'
- '/^(ci)(\([a-z ]+\))?\/.+/'
title:
- '/^(fix)(\([a-z ]+\))?: .+/'
- '/^(ci)(\([a-z ]+\))?: .+/'

change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ jobs:
# https://github.com/dotnet/Nerdbank.GitVersioning/blob/main/doc/cloudbuild.md#github-actions
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
# Download the NuGet package created in the previous job
- uses: actions/download-artifact@v3
# .nupkg should be in the same folder that we have `.template.config`, so we should put it in the root of source directory
- uses: actions/download-artifact@v4
with:
name: nuget
path: ${{ env.NuGetDirectory }}
## Optional. Default is $GITHUB_WORKSPACE
# path: ${{ github.workspace}}

# Install the .NET SDK indicated in the global.json file
- name: Setup .NET Core
Expand All @@ -91,13 +93,13 @@ jobs:

# for publish package to github for each commit
- name: Publish NuGet Package Version ${{ steps.nbgv.outputs.SemVer2 }} to GitHub
run: dotnet nuget push ${{ env.NuGetDirectory }}/*.nupkg --skip-duplicate --api-key ${{ env.GHC_API_KEY }} --source ${{ env.GHC_SOURCE }}
run: dotnet nuget push *.nupkg --skip-duplicate --api-key ${{ env.GHC_API_KEY }} --source ${{ env.GHC_SOURCE }}
if: github.event_name == 'push' && (startswith(github.ref, 'refs/heads') || startswith(github.ref, 'refs/tags'))

# Publish all NuGet packages to NuGet.org
# Use --skip-duplicate to prevent errors if a package with the same version already exists.
# If you retry a failed workflow, already published packages will be skipped without error.
# https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-push
- name: Publish NuGet Package Version ${{ steps.nbgv.outputs.SemVer2 }} to Nuget
run: dotnet nuget push ${{ env.NuGetDirectory }}/*.nupkg --skip-duplicate --source ${{ env.FEED_SOURCE }} --api-key ${{ env.FEED_API_KEY }}
run: dotnet nuget push *.nupkg --skip-duplicate --source ${{ env.FEED_SOURCE }} --api-key ${{ env.FEED_API_KEY }}
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags')
52 changes: 28 additions & 24 deletions src/Shared/Logging/Extensions/DependencyInjectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public static WebApplicationBuilder AddCustomSerilog(
// https://github.com/serilog/serilog-settings-configuration
loggerConfiguration.ReadFrom.Configuration(
builder.Configuration,
new ConfigurationReaderOptions {SectionName = nameof(SerilogOptions)});
new ConfigurationReaderOptions { SectionName = nameof(SerilogOptions) }
);

extraConfigure?.Invoke(loggerConfiguration);

Expand All @@ -56,16 +57,16 @@ public static WebApplicationBuilder AddCustomSerilog(
.Enrich.WithExceptionDetails(
new DestructuringOptionsBuilder()
.WithDefaultDestructurers()
.WithDestructurers(new[] {new DbUpdateExceptionDestructurer()}));

.WithDestructurers(new[] { new DbUpdateExceptionDestructurer() })
);

if (serilogOptions.UseConsole)
{
// https://github.com/serilog/serilog-sinks-async
// https://github.com/lucadecamillis/serilog-sinks-spectre
loggerConfiguration.WriteTo.Async(
writeTo =>
writeTo.Spectre(outputTemplate: serilogOptions.LogTemplate));
loggerConfiguration.WriteTo.Async(writeTo =>
writeTo.Spectre(outputTemplate: serilogOptions.LogTemplate)
);
}

// https://github.com/serilog/serilog-sinks-async
Expand All @@ -74,7 +75,7 @@ public static WebApplicationBuilder AddCustomSerilog(
// elasticsearch sink internally is async
// https://www.nuget.org/packages/Elastic.Serilog.Sinks
loggerConfiguration.WriteTo.Elasticsearch(
new[] {new Uri(serilogOptions.ElasticSearchUrl),},
new[] { new Uri(serilogOptions.ElasticSearchUrl) },
opts =>
{
opts.DataStream = new DataStreamName(
Expand All @@ -84,17 +85,17 @@ public static WebApplicationBuilder AddCustomSerilog(
builder.Environment.EnvironmentName
}-{
DateTime.Now
:yyyy-MM}");
:yyyy-MM}"
);

opts.BootstrapMethod = BootstrapMethod.Failure;

opts.ConfigureChannel = channelOpts =>
{
channelOpts.BufferOptions =
new BufferOptions
{ExportMaxConcurrency = 10};
};
});
{
channelOpts.BufferOptions = new BufferOptions { ExportMaxConcurrency = 10 };
};
}
);
}

// https://github.com/serilog-contrib/serilog-sinks-grafana-loki
Expand All @@ -104,9 +105,10 @@ public static WebApplicationBuilder AddCustomSerilog(
serilogOptions.GrafanaLokiUrl,
new[]
{
new LokiLabel {Key = "service", Value = "food-delivery"},
new LokiLabel { Key = "service", Value = "food-delivery" },
},
["app"]);
["app"]
);
}

if (!string.IsNullOrEmpty(serilogOptions.SeqUrl))
Expand All @@ -124,15 +126,17 @@ public static WebApplicationBuilder AddCustomSerilog(

if (!string.IsNullOrEmpty(serilogOptions.LogPath))
{
loggerConfiguration.WriteTo.Async(
writeTo =>
writeTo.File(
serilogOptions.LogPath,
outputTemplate: serilogOptions.LogTemplate,
rollingInterval: RollingInterval.Day,
rollOnFileSizeLimit: true));
loggerConfiguration.WriteTo.Async(writeTo =>
writeTo.File(
serilogOptions.LogPath,
outputTemplate: serilogOptions.LogTemplate,
rollingInterval: RollingInterval.Day,
rollOnFileSizeLimit: true
)
);
}
});
}
);

return builder;
}
Expand Down
30 changes: 15 additions & 15 deletions version.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "1.3.4",
"gitCommitIdShortAutoMinimum": 7,
"nugetPackageVersion": {
"semVer": 2
},
"publicReleaseRefSpec": ["^refs/tags/v\\d+\\.\\d+"],
"release": {
"firstUnstableTag": "preview",
"versionIncrement": "minor"
},
"cloudBuild": {
"buildNumber": {
"enabled": true
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "1.3.5",
"gitCommitIdShortAutoMinimum": 7,
"nugetPackageVersion": {
"semVer": 2
},
"publicReleaseRefSpec": ["^refs/tags/v\\d+\\.\\d+"],
"release": {
"firstUnstableTag": "preview",
"versionIncrement": "minor"
},
"cloudBuild": {
"buildNumber": {
"enabled": true
}
}
}
}
11 changes: 9 additions & 2 deletions vertical-slice-template.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
<!-- https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#package-properties -->
<!-- https://learn.microsoft.com/en-us/nuget/reference/msbuild-targets#pack-target -->
<!-- https://www.meziantou.net/publishing-a-nuget-package-following-best-practices-using-github.htm#enable-the-dotnet-sd -->
<!-- dotnet pack Template.csproj -o . -->

<!-- .nupkg should be in the same folder that we have `.template.config` -->
<!-- dotnet pack vertical-slice-template.csproj -o ./ -->
<!-- dotnet new install . -->
<Project Sdk="Microsoft.NET.Sdk">

Expand Down Expand Up @@ -35,14 +37,19 @@
</PropertyGroup>

<ItemGroup>
<Content Include="**\*" Exclude="**\bin\**\*;**\obj\**\*;**\.template.config\**\*;vertical-slice-template.csproj.csproj;vertical-slice-template.csproj.nuspec;icon.png;**\*.user;**\*.lock.json;**\node_modules\**\*;**\.idea\**\*;**\.DS_Store;**\.git\**\*;**\.github\**\*;**\.vs\**\*;**\*LICENSE;**\*nupkg;**\*.gitattributes;**\*.gitignore;**\*nuget.config;"/>
<Content Include="**\*" Exclude="**\node_modules\**;**\bin\**;**\obj\**;.\.vs\**;vertical-slice-template.nuspec;.\vertical-slice-template.csproj;icon.png;**\*.user;**\*.lock.json;**\.idea\**\*;**\.DS_Store;**\.git\**;**\.github\**;**\*LICENSE;**\*nupkg;**\*.gitattributes;**\*.gitignore;**\*nuget.config;"/>
<Compile Remove="**\*"/>
</ItemGroup>

<ItemGroup>
<None Include="icon.png" Pack="true" PackagePath="\"/>
<None Include="readme.md" Pack="true" PackagePath="\"/>
<None Include="readme-nuget.md" Pack="true" PackagePath="\"/>
<None Include=".\.github\workflows\build-test.yml"/>
</ItemGroup>

<ItemGroup>
<None Include=".template.config\**\*" Pack="true" PackagePath=".template.config\" />
</ItemGroup>

</Project>
Loading