Skip to content

Commit 9aedf0d

Browse files
authored
Merge pull request #32 from datalust/dev
1.1.0 Release
2 parents 98d85b2 + 9639fca commit 9aedf0d

38 files changed

+574
-110
lines changed

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# If this file is renamed, the incrementing run attempt number will be reset.
2+
3+
name: CI
4+
5+
on:
6+
push:
7+
branches: [ "dev", "main" ]
8+
pull_request:
9+
branches: [ "dev", "main" ]
10+
11+
env:
12+
CI_BUILD_NUMBER_BASE: ${{ github.run_number }}
13+
CI_TARGET_BRANCH: ${{ github.head_ref || github.ref_name }}
14+
15+
jobs:
16+
build:
17+
18+
runs-on: ubuntu-24.04
19+
20+
permissions:
21+
contents: write
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Setup
26+
uses: actions/setup-dotnet@v4
27+
with:
28+
dotnet-version: 8.0.x
29+
- name: Compute build number
30+
run: |
31+
echo "CI_BUILD_NUMBER=$(($CI_BUILD_NUMBER_BASE+90))" >> $GITHUB_ENV
32+
- name: Build and Publish
33+
env:
34+
DOTNET_CLI_TELEMETRY_OPTOUT: true
35+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
36+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
shell: pwsh
38+
run: |
39+
./Build.ps1

Build.ps1

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,78 @@
1-
# This script originally (c) 2016 Serilog Contributors - license Apache 2.0
2-
3-
echo "build: Build started"
1+
Write-Output "build: Build started"
42

53
Push-Location $PSScriptRoot
64

5+
Write-Output "build: Tool versions follow"
6+
7+
dotnet --version
8+
dotnet --list-sdks
9+
710
if(Test-Path .\artifacts) {
8-
echo "build: Cleaning .\artifacts"
9-
Remove-Item .\artifacts -Force -Recurse
11+
Write-Output "build: Cleaning ./artifacts"
12+
Remove-Item ./artifacts -Force -Recurse
1013
}
1114

1215
& dotnet restore --no-cache
13-
if($LASTEXITCODE -ne 0) { exit 1 }
1416

15-
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
16-
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
17-
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "main" -and $revision -ne "local"]
17+
$dbp = [Xml] (Get-Content .\Directory.Build.props)
18+
$versionPrefix = $dbp.Project.PropertyGroup.VersionPrefix
1819

19-
echo "build: Version suffix is $suffix"
20+
Write-Output "build: Package version prefix is $versionPrefix"
2021

21-
foreach ($src in ls src/Seq.App.*) {
22+
$branch = @{ $true = $env:CI_TARGET_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$NULL -ne $env:CI_TARGET_BRANCH];
23+
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:CI_BUILD_NUMBER, 10); $false = "local" }[$NULL -ne $env:CI_BUILD_NUMBER];
24+
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '([^a-zA-Z0-9\-]*)', '')-$revision"}[$branch -eq "main" -and $revision -ne "local"]
25+
26+
Write-Output "build: Package version suffix is $suffix"
27+
28+
foreach ($src in Get-ChildItem src/*) {
2229
Push-Location $src
2330

24-
echo "build: Packaging app project in $src"
31+
Write-Output "build: Packaging project in $src"
2532

26-
if (Test-Path ./obj/publish) {
27-
Remove-Item -Recurse -Force ./obj/publish
28-
}
29-
3033
if ($suffix) {
3134
& dotnet publish -c Release -o ./obj/publish --version-suffix=$suffix
32-
& dotnet pack -c Release -o ..\..\artifacts --no-build --version-suffix=$suffix
35+
& dotnet pack -c Release -o ../../artifacts --no-build --version-suffix=$suffix
3336
} else {
3437
& dotnet publish -c Release -o ./obj/publish
35-
& dotnet pack -c Release -o ..\..\artifacts --no-build
38+
& dotnet pack -c Release -o ../../artifacts --no-build
3639
}
37-
if($LASTEXITCODE -ne 0) { throw "Build failed" }
40+
if($LASTEXITCODE -ne 0) { throw "Packaging failed" }
3841

3942
Pop-Location
4043
}
4144

42-
foreach ($src in @("src/Seq.Syntax", "src/Seq.Mail", "src/Seq.Apps.Testing")) {
43-
Push-Location $src
44-
45-
echo "build: Packaging library in $src"
46-
47-
if ($suffix) {
48-
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix
49-
} else {
50-
& dotnet pack -c Release -o ..\..\artifacts
51-
}
52-
if($LASTEXITCODE -ne 0) { throw "Build failed" }
53-
54-
Pop-Location
55-
}
45+
Write-Output "build: Checking complete solution builds"
46+
& dotnet build
47+
if($LASTEXITCODE -ne 0) { throw "Solution build failed" }
5648

57-
foreach ($test in ls test/*.Tests) {
49+
foreach ($test in Get-ChildItem test/*.Tests) {
5850
Push-Location $test
5951

60-
echo "build: Testing project in $test"
52+
Write-Output "build: Testing project in $test"
6153

6254
& dotnet test -c Release
6355
if($LASTEXITCODE -ne 0) { throw "Testing failed" }
6456

6557
Pop-Location
6658
}
6759

68-
Pop-Location
60+
Pop-Location
61+
62+
if ($env:NUGET_API_KEY) {
63+
# GitHub Actions will only supply this to branch builds and not PRs. We publish
64+
# builds from any branch this action targets (i.e. main and dev).
65+
66+
Write-Output "build: Publishing NuGet packages"
67+
68+
foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) {
69+
& dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg"
70+
if($LASTEXITCODE -ne 0) { throw "Publishing failed" }
71+
}
72+
73+
if (!($suffix)) {
74+
Write-Output "build: Creating release for version $versionPrefix"
75+
76+
iex "gh release create v$versionPrefix --title v$versionPrefix --generate-notes $(get-item ./artifacts/*.nupkg) $(get-item ./artifacts/*.snupkg)"
77+
}
78+
}

Directory.Build.props

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project>
2+
<PropertyGroup>
3+
<VersionPrefix>1.1.0</VersionPrefix>
4+
</PropertyGroup>
5+
</Project>

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
# Seq Mail Apps [![Build status](https://ci.appveyor.com/api/projects/status/6jo5xhyfans07msl/branch/dev?svg=true)](https://ci.appveyor.com/project/datalust/seq-app-mail/branch/dev)
1+
# Seq Mail Apps
22

33
This repository contains the Seq output apps for various email services, built on a shared email templating system.
44

55
| Package id | Description |
66
|-------------------------------------------------------------------------------------|-----------------------------------------------------------------|
7+
| [`Seq.App.Mail.AmazonSes`](https://nuget.org/packages/seq.app.mail.amazonses) | Send email using the Amazon Simple Email Service (SES) API. |
78
| [`Seq.App.Mail.Microsoft365`](https://nuget.org/packages/seq.app.mail.microsoft365) | Send email through Microsoft 365 using the Microsoft Graph API. |
89
| [`Seq.App.Mail.Smtp`](https://nuget.org/packages/seq.app.mail.smtp) | Send email using the SMTP protocol. |
910

1011
> Need to send email using a protocol or API not listed here? Let us know!
1112
12-
1313
## Getting started
1414

1515
Install the app under _Settings > Apps_, using one of the package ids from the table above.
@@ -30,9 +30,16 @@ When starting an instance of the app in Seq, the following parameters can be sup
3030
| **Body** | The email body. | Yes | See `src/Seq.Mail/Resources` |
3131
| **Body is plain text** | If checked, the body template will be interpreted as plain text, rather than HTML. | | |
3232

33+
### `Seq.App.Mail.AmazonSes`
34+
35+
| Property | Description | Template? | Default |
36+
|-------------------|------------------------------|---|---|
37+
| **Access key id** | An Amazon SES access key id. | | |
38+
| **Client id** | An Amazon SES secret key. | | |
39+
3340
### `Seq.App.Mail.Microsoft365`
3441

35-
To send mail using the Microsoft 365 app, first create an app registration in Azure. The app must have the `Mail.Send` permission
42+
To send mail using the Microsoft 365 app, first create an app registration in Azure. The app must have the `Mail.Send` permission
3643
for the Microsoft Graph API.
3744

3845
| Property | Description | Template? | Default |
@@ -54,6 +61,8 @@ for the Microsoft Graph API.
5461

5562
## Templates
5663

64+
The Seq mail apps support the [Seq template language](https://docs.datalust.co/docs/template-syntax).
65+
5766
Event and notification properties can be inserted dynamically into many of the settings listed above, by surrounding them
5867
with braces:
5968

appveyor.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

harness/Seq.Mail.TestHarness/Seq.Mail.TestHarness.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
11+
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
1212
</ItemGroup>
1313

1414
<ItemGroup>

seq-app-mail.sln

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{0F8E84A5-952
1111
ProjectSection(SolutionItems) = preProject
1212
.gitattributes = .gitattributes
1313
.gitignore = .gitignore
14-
appveyor.yml = appveyor.yml
15-
Build.ps1 = Build.ps1
1614
LICENSE = LICENSE
1715
README.md = README.md
1816
RunLocalSmtp.ps1 = RunLocalSmtp.ps1
17+
Directory.Build.props = Directory.Build.props
18+
Build.ps1 = Build.ps1
1919
EndProjectSection
2020
EndProject
2121
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "asset", "asset", "{AC60371C-2888-45BB-9770-2A690DEA80FA}"
@@ -43,6 +43,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "harness", "harness", "{E684
4343
EndProject
4444
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Seq.Mail.TestHarness", "harness\Seq.Mail.TestHarness\Seq.Mail.TestHarness.csproj", "{53B48FC5-E76D-4442-9259-DB57CDB53232}"
4545
EndProject
46+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Seq.App.Mail.AmazonSes", "src\Seq.App.Mail.AmazonSes\Seq.App.Mail.AmazonSes.csproj", "{D124E851-B1CE-4DAD-8C1A-45697701D190}"
47+
EndProject
48+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{A5CC96EF-1E35-4836-9EE6-11F114D3E41D}"
49+
EndProject
50+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{6D4A81AD-7209-4848-AFF5-232E4E3FDF41}"
51+
ProjectSection(SolutionItems) = preProject
52+
.github\workflows\ci.yml = .github\workflows\ci.yml
53+
EndProjectSection
54+
EndProject
4655
Global
4756
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4857
Debug|Any CPU = Debug|Any CPU
@@ -81,6 +90,10 @@ Global
8190
{53B48FC5-E76D-4442-9259-DB57CDB53232}.Debug|Any CPU.Build.0 = Debug|Any CPU
8291
{53B48FC5-E76D-4442-9259-DB57CDB53232}.Release|Any CPU.ActiveCfg = Release|Any CPU
8392
{53B48FC5-E76D-4442-9259-DB57CDB53232}.Release|Any CPU.Build.0 = Release|Any CPU
93+
{D124E851-B1CE-4DAD-8C1A-45697701D190}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
94+
{D124E851-B1CE-4DAD-8C1A-45697701D190}.Debug|Any CPU.Build.0 = Debug|Any CPU
95+
{D124E851-B1CE-4DAD-8C1A-45697701D190}.Release|Any CPU.ActiveCfg = Release|Any CPU
96+
{D124E851-B1CE-4DAD-8C1A-45697701D190}.Release|Any CPU.Build.0 = Release|Any CPU
8497
EndGlobalSection
8598
GlobalSection(SolutionProperties) = preSolution
8699
HideSolutionNode = FALSE
@@ -94,6 +107,8 @@ Global
94107
{A836BDA9-335E-49E1-AA68-DA3D8B6DABA0} = {B03B3086-D197-4B32-9AE2-8536C345EA2D}
95108
{7E46171B-8E2F-42EB-8C10-526578F9BED0} = {91E482DE-E1E7-4CE1-9511-C0AF07F3648A}
96109
{53B48FC5-E76D-4442-9259-DB57CDB53232} = {E684AE47-A861-44F3-A648-A512652ED9C5}
110+
{D124E851-B1CE-4DAD-8C1A-45697701D190} = {91E482DE-E1E7-4CE1-9511-C0AF07F3648A}
111+
{6D4A81AD-7209-4848-AFF5-232E4E3FDF41} = {A5CC96EF-1E35-4836-9EE6-11F114D3E41D}
97112
EndGlobalSection
98113
GlobalSection(ExtensibilityGlobals) = postSolution
99114
SolutionGuid = {EB6672D6-318E-493E-8B60-77F5A7A90E66}

seq-app-mail.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
22
<s:Boolean x:Key="/Default/UserDictionary/Words/=Comparand/@EntryIndexedValue">True</s:Boolean>
33
<s:Boolean x:Key="/Default/UserDictionary/Words/=formattable/@EntryIndexedValue">True</s:Boolean>
4+
<s:Boolean x:Key="/Default/UserDictionary/Words/=nblumhardt/@EntryIndexedValue">True</s:Boolean>
45
<s:Boolean x:Key="/Default/UserDictionary/Words/=seqcli/@EntryIndexedValue">True</s:Boolean>
56
<s:Boolean x:Key="/Default/UserDictionary/Words/=seqid/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using System;
2+
using System.Linq;
3+
using System.Threading;
4+
using System.Threading.Tasks;
5+
using Amazon.SimpleEmail.Model;
6+
using MimeKit;
7+
using Seq.Apps;
8+
using Seq.Mail;
9+
10+
// ReSharper disable UnusedAutoPropertyAccessor.Global
11+
12+
namespace Seq.App.Mail.AmazonSes;
13+
14+
[SeqApp("Amazon Simple Email Service (SES) Mail",
15+
Description = "Send events and notifications by email, using the Amazon Simple Email Service (SES) API.")]
16+
public class AmazonSesMailApp: MailApp
17+
{
18+
readonly IAmazonSesMailGateway _mailGateway;
19+
AmazonSesOptions? _options;
20+
21+
internal AmazonSesMailApp(IAmazonSesMailGateway mailGateway)
22+
{
23+
_mailGateway = mailGateway;
24+
}
25+
26+
public AmazonSesMailApp()
27+
: this (new AmazonSimpleEmailServiceClientMailGateway())
28+
{
29+
}
30+
31+
[SeqAppSetting(
32+
DisplayName = "Access key id",
33+
HelpText = "An AWS access key id.")]
34+
public string? AccessKeyId { get; set; }
35+
36+
[SeqAppSetting(
37+
DisplayName = "Secret key",
38+
HelpText = "An AWS secret key.",
39+
InputType = SettingInputType.Password)]
40+
public string? SecretKey { get; set; }
41+
42+
protected override void OnAttached()
43+
{
44+
base.OnAttached();
45+
46+
_options = new AmazonSesOptions(
47+
NormalizeOption(AccessKeyId) ?? throw new InvalidOperationException("An access key id is required."),
48+
NormalizeOption(SecretKey) ?? throw new InvalidOperationException("A secret key is required."));
49+
}
50+
51+
protected override async Task SendAsync(MimeMessage message, CancellationToken cancel)
52+
{
53+
const string charset = "UTF-8";
54+
var subject = new Content { Data = message.Subject, Charset = charset };
55+
56+
var body = new Body
57+
{
58+
Html = message.HtmlBody != null ? new Content { Data = message.HtmlBody, Charset = charset } : null,
59+
Text = message.TextBody != null ? new Content { Data = message.TextBody, Charset = charset } : null
60+
};
61+
62+
var sesMessage = new Message
63+
{
64+
Subject = subject,
65+
Body = body
66+
};
67+
68+
var destination = new Destination { ToAddresses = message.To.Select(addr => addr.ToString()).ToList() };
69+
70+
var request = new SendEmailRequest
71+
{
72+
Source = message.From.Single().ToString(),
73+
Destination = destination,
74+
Message = sesMessage
75+
};
76+
77+
await _mailGateway.SendAsync(_options!, request, cancel);
78+
}
79+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace Seq.App.Mail.AmazonSes;
2+
3+
class AmazonSesOptions
4+
{
5+
public string AccessKeyId { get; }
6+
public string SecretKey { get; }
7+
8+
public AmazonSesOptions(string accessKeyId, string secretKey)
9+
{
10+
AccessKeyId = accessKeyId;
11+
SecretKey = secretKey;
12+
}
13+
}

0 commit comments

Comments
 (0)