Skip to content
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
Binary file added .DS_Store
Binary file not shown.
Binary file added .github/.DS_Store
Binary file not shown.
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# If this file is renamed, the incrementing run attempt number will be reset.

name: CI

on:
push:
branches: [ "dev", "main" ]
pull_request:
branches: [ "dev", "main" ]

env:
CI_BUILD_NUMBER_BASE: ${{ github.run_number }}
CI_TARGET_BRANCH: ${{ github.head_ref || github.ref_name }}

jobs:
build:

# The build must run on Windows so that .NET Framework targets can be built and tested.
runs-on: windows-latest

permissions:
contents: write

steps:
- uses: actions/checkout@v4
- name: Setup
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Compute build number
shell: bash
run: |
echo "CI_BUILD_NUMBER=$(($CI_BUILD_NUMBER_BASE+2300))" >> $GITHUB_ENV
- name: Build and Publish
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: pwsh
run: |
./Build.ps1
94 changes: 61 additions & 33 deletions Build.ps1
Original file line number Diff line number Diff line change
@@ -1,51 +1,79 @@
Write-Output "build: Build started"
Write-Output "build: Tool versions follow"

dotnet --version
dotnet --list-sdks

& dotnet --info
& dotnet --list-sdks
Write-Output "build: Build started"

Push-Location $PSScriptRoot
try {
if(Test-Path .\artifacts) {
Write-Output "build: Cleaning ./artifacts"
Remove-Item ./artifacts -Force -Recurse
}

if(Test-Path .\artifacts) {
Write-Output "build: Cleaning .\artifacts"
Remove-Item .\artifacts -Force -Recurse
}
& dotnet restore --no-cache

& dotnet restore --no-cache
$dbp = [Xml] (Get-Content .\Directory.Version.props)
$versionPrefix = $dbp.Project.PropertyGroup.VersionPrefix

$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "main" -and $revision -ne "local"]
$commitHash = $(git rev-parse --short HEAD)
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
Write-Output "build: Package version prefix is $versionPrefix"

Write-Output "build: Package version suffix is $suffix"
Write-Output "build: Build version suffix is $buildSuffix"
$branch = @{ $true = $env:CI_TARGET_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$NULL -ne $env:CI_TARGET_BRANCH];
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:CI_BUILD_NUMBER, 10); $false = "local" }[$NULL -ne $env:CI_BUILD_NUMBER];
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '([^a-zA-Z0-9\-]*)', '')-$revision"}[$branch -eq "main" -and $revision -ne "local"]
$commitHash = $(git rev-parse --short HEAD)
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]

foreach ($src in Get-ChildItem src/*) {
Push-Location $src
Write-Output "build: Package version suffix is $suffix"
Write-Output "build: Build version suffix is $buildSuffix"

Write-Output "build: Packaging project in $src"
& dotnet build -c Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true
if($LASTEXITCODE -ne 0) { throw "Build failed" }

& dotnet build -c Release --version-suffix=$buildSuffix
if ($suffix) {
& dotnet pack -c Release --include-source -o ..\..\artifacts --version-suffix=$suffix --no-build
} else {
& dotnet pack -c Release --include-source -o ..\..\artifacts --no-build
foreach ($src in Get-ChildItem src/*) {
Push-Location $src

Write-Output "build: Packaging project in $src"

if ($suffix) {
& dotnet pack -c Release --no-build --no-restore -o ../../artifacts --version-suffix=$suffix
} else {
& dotnet pack -c Release --no-build --no-restore -o ../../artifacts
}
if($LASTEXITCODE -ne 0) { throw "Packaging failed" }

Pop-Location
}
if($LASTEXITCODE -ne 0) { throw "failed" }

Pop-Location
}
foreach ($test in Get-ChildItem test/*.Tests) {
Push-Location $test

Write-Output "build: Testing project in $test"

& dotnet test -c Release --no-build --no-restore
if($LASTEXITCODE -ne 0) { throw "Testing failed" }

Pop-Location
}

if ($env:NUGET_API_KEY) {
# GitHub Actions will only supply this to branch builds and not PRs. We publish
# builds from any branch this action targets (i.e. main and dev).

foreach ($test in Get-ChildItem test/*.Tests) {
Push-Location $test
Write-Output "build: Publishing NuGet packages"

Write-Output "build: Testing project in $test"
foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) {
& dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg"
if($LASTEXITCODE -ne 0) { throw "Publishing failed" }
}

& dotnet test -c Release
if($LASTEXITCODE -ne 0) { throw "failed" }
if (!($suffix)) {
Write-Output "build: Creating release for version $versionPrefix"

iex "gh release create v$versionPrefix --title v$versionPrefix --generate-notes $(get-item ./artifacts/*.nupkg) $(get-item ./artifacts/*.snupkg)"
}
}
} finally {
Pop-Location
}

Pop-Location
22 changes: 20 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
<Project>
<!-- Workaround for https://github.com/dotnet/sdk/pull/908 -->
<Target Name="GetPackagingOutputs" />
<!-- Properties in this file are expected to be identical for all Serilog organization projects. If
a property value is project-specific, please record it in the CSPROJ file instead. -->
<Import Project="$(MSBuildThisFileDirectory)Directory.Version.props" />
<PropertyGroup>
<LangVersion>latest</LangVersion>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<!-- The condition is required to support BenchmarkDotNet -->
<SignAssembly Condition="Exists('$(MSBuildThisFileDirectory)assets/Serilog.snk')">true</SignAssembly>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)assets/Serilog.snk</AssemblyOriginatorKeyFile>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
</Project>
5 changes: 5 additions & 0 deletions Directory.Version.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<PropertyGroup>
<VersionPrefix>4.1.0</VersionPrefix>
</PropertyGroup>
</Project>
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Serilog.Sinks.Email [![Build status](https://ci.appveyor.com/api/projects/status/sfvp7dw8u6aiodj1/branch/main?svg=true)](https://ci.appveyor.com/project/serilog/serilog-sinks-email/branch/main)
# Serilog.Sinks.Email&nbsp;[![Build status](https://github.com/serilog/serilog-sinks-email/actions/workflows/ci.yml/badge.svg?branch=dev)](https://github.com/serilog/serilog-sinks-email/actions)&nbsp;[![NuGet Version](http://img.shields.io/nuget/v/Serilog.Sinks.Email.svg?style=flat)](https://www.nuget.org/packages/Serilog.Sinks.Email/)

Sends log events by SMTP email.

> ℹ️ Version 3.x of this package changes the name and structure of many configuration parameters from their 2.x names; see below for detailed information.

**Package** - [Serilog.Sinks.Email](http://nuget.org/packages/serilog.sinks.email)
**Package Id:** [Serilog.Sinks.Email](http://nuget.org/packages/serilog.sinks.email)

```csharp
await using var log = new LoggerConfiguration()
Expand Down Expand Up @@ -47,7 +47,7 @@ await using var log = new LoggerConfiguration()
batchingOptions: new()
{
BatchSizeLimit = 10,
Period = TimeSpan.FromSeconds(30),
BufferingTimeLimit = TimeSpan.FromSeconds(30),
})
.CreateLogger();
```
Expand All @@ -73,7 +73,7 @@ await using var log = new LoggerConfiguration()
batchingOptions: new()
{
BatchSizeLimit = 10,
Period = TimeSpan.FromSeconds(30),
BufferingTimeLimit = TimeSpan.FromSeconds(30),
})
.CreateLogger();
```
Expand Down
10 changes: 0 additions & 10 deletions Setup.ps1

This file was deleted.

22 changes: 0 additions & 22 deletions appveyor.yml

This file was deleted.

23 changes: 0 additions & 23 deletions build.sh

This file was deleted.

2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"sdk": {
"version": "9.0.200",
"allowPrerelease": false,
"version": "8.0.100",
"rollForward": "latestFeature"
}
}
6 changes: 3 additions & 3 deletions serilog-sinks-email.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{DACEA9
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitignore = .gitignore
appveyor.yml = appveyor.yml
README.md = README.md
assets\Serilog.snk = assets\Serilog.snk
Build.ps1 = Build.ps1
Directory.Build.props = Directory.Build.props
Directory.Version.props = Directory.Version.props
global.json = global.json
README.md = README.md
assets\Serilog.snk = assets\Serilog.snk
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{340DBC35-BD09-414B-818C-978FBCA4CDF1}"
Expand Down
7 changes: 0 additions & 7 deletions setup.sh

This file was deleted.

18 changes: 4 additions & 14 deletions src/Serilog.Sinks.Email/Serilog.Sinks.Email.csproj
Original file line number Diff line number Diff line change
@@ -1,37 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Send Serilog events as SMTP email using MailKit.</Description>
<VersionPrefix>4.0.0</VersionPrefix>
<Authors>Serilog Contributors</Authors>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net462;net471</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworks);netstandard2.0;net6.0;net8.0</TargetFrameworks>
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TargetFrameworks>$(TargetFrameworks);netstandard2.0;net6.0;net8.0;net9.0</TargetFrameworks>
<PackageTags>serilog;smtp;mailkit</PackageTags>
<PackageIcon>serilog-sink-nuget.png</PackageIcon>
<PackageProjectUrl>https://serilog.net/</PackageProjectUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<TreatSpecificWarningsAsErrors />
<PolySharpIncludeRuntimeSupportedAttributes>true</PolySharpIncludeRuntimeSupportedAttributes>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RootNamespace>Serilog</RootNamespace>
<Nullable>enable</Nullable>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
</PropertyGroup>

<ItemGroup>
<None Include="../../serilog-sink-nuget.png" Pack="true" Visible="false" PackagePath="/" />
<None Include="../../README.md" Pack="true" Visible="false" PackagePath="/" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="PolySharp" Version="1.14.1" PrivateAssets="All" />
<PackageReference Include="Serilog" Version="4.0.0" />
<PackageReference Include="MailKit" Version="4.6.0" />
<PackageReference Include="PolySharp" Version="1.15.0" PrivateAssets="All" />
<PackageReference Include="Serilog" Version="4.2.0" />
<PackageReference Include="MailKit" Version="4.11.0" />
</ItemGroup>

</Project>
12 changes: 6 additions & 6 deletions src/Serilog.Sinks.Email/Sinks/Email/EmailSinkOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ public EmailSinkOptions()
public ICredentialsByHost? Credentials { get; set; }

/// <summary>
/// The <see cref="ITextFormatter"/> or <see cref="IBatchTextFormatter"/> implementation
/// to write log entries to email. Specify <c>null</c> to use the default body. . Consider using
/// <see cref="MessageTemplateTextFormatter"/> or <c>Serilog.Expressions</c> templates.
/// The <see cref="ITextFormatter"/> implementation to format email subjects. Specify
/// <c>null</c> to use the default subject. Consider using <see cref="MessageTemplateTextFormatter"/> or
/// <c>Serilog.Expressions</c> templates.
/// </summary>
public ITextFormatter Subject { get; set; } = new MessageTemplateTextFormatter(DefaultSubject);

/// <summary>
/// The <see cref="ITextFormatter"/> implementation to format email subjects. Specify
/// <c>null</c> to use the default subject. Consider using <see cref="MessageTemplateTextFormatter"/> or
/// <c>Serilog.Expressions</c> templates.
/// The <see cref="ITextFormatter"/> or <see cref="IBatchTextFormatter"/> implementation
/// to write log entries to email. Specify <c>null</c> to use the default body. Consider using
/// <see cref="MessageTemplateTextFormatter"/> or <c>Serilog.Expressions</c> templates.
/// </summary>
public ITextFormatter Body { get; set; } = new MessageTemplateTextFormatter(DefaultBody);

Expand Down
Loading