Skip to content

Commit 505a303

Browse files
committed
Introduce Actions build
1 parent 1560831 commit 505a303

File tree

5 files changed

+95
-64
lines changed

5 files changed

+95
-64
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 & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,76 @@
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"]
18-
19-
echo "build: Version suffix is $suffix"
20-
21-
foreach ($src in ls src/Seq.App.*) {
22-
Push-Location $src
17+
$dbp = [Xml] (Get-Content .\Directory.Build.props)
18+
$versionPrefix = $dbp.Project.PropertyGroup.VersionPrefix
2319

24-
echo "build: Packaging app project in $src"
20+
Write-Output "build: Package version prefix is $versionPrefix"
2521

26-
if (Test-Path ./obj/publish) {
27-
Remove-Item -Recurse -Force ./obj/publish
28-
}
29-
30-
if ($suffix) {
31-
& dotnet publish -c Release -o ./obj/publish --version-suffix=$suffix
32-
& dotnet pack -c Release -o ..\..\artifacts --no-build --version-suffix=$suffix
33-
} else {
34-
& dotnet publish -c Release -o ./obj/publish
35-
& dotnet pack -c Release -o ..\..\artifacts --no-build
36-
}
37-
if($LASTEXITCODE -ne 0) { throw "Build failed" }
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"]
3825

39-
Pop-Location
40-
}
26+
Write-Output "build: Package version suffix is $suffix"
4127

42-
foreach ($src in @("src/Seq.Syntax", "src/Seq.Mail", "src/Seq.Apps.Testing")) {
28+
foreach ($src in Get-ChildItem src/*) {
4329
Push-Location $src
4430

45-
echo "build: Packaging library in $src"
46-
31+
Write-Output "build: Packaging project in $src"
32+
4733
if ($suffix) {
48-
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix
34+
& dotnet pack -c Release -o ../../artifacts --version-suffix=$suffix
4935
} else {
50-
& dotnet pack -c Release -o ..\..\artifacts
36+
& dotnet pack -c Release -o ../../artifacts
5137
}
52-
if($LASTEXITCODE -ne 0) { throw "Build failed" }
38+
if($LASTEXITCODE -ne 0) { throw "Packaging failed" }
5339

5440
Pop-Location
5541
}
5642

57-
foreach ($test in ls test/*.Tests) {
43+
Write-Output "build: Checking complete solution builds"
44+
& dotnet build
45+
if($LASTEXITCODE -ne 0) { throw "Solution build failed" }
46+
47+
foreach ($test in Get-ChildItem test/*.Tests) {
5848
Push-Location $test
5949

60-
echo "build: Testing project in $test"
50+
Write-Output "build: Testing project in $test"
6151

6252
& dotnet test -c Release
6353
if($LASTEXITCODE -ne 0) { throw "Testing failed" }
6454

6555
Pop-Location
6656
}
6757

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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

appveyor.yml

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

seq-app-mail.sln

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +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
1917
Directory.Build.props = Directory.Build.props
18+
Build.ps1 = Build.ps1
2019
EndProjectSection
2120
EndProject
2221
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "asset", "asset", "{AC60371C-2888-45BB-9770-2A690DEA80FA}"
@@ -46,6 +45,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Seq.Mail.TestHarness", "har
4645
EndProject
4746
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}"
4847
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
4955
Global
5056
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5157
Debug|Any CPU = Debug|Any CPU
@@ -102,6 +108,7 @@ Global
102108
{7E46171B-8E2F-42EB-8C10-526578F9BED0} = {91E482DE-E1E7-4CE1-9511-C0AF07F3648A}
103109
{53B48FC5-E76D-4442-9259-DB57CDB53232} = {E684AE47-A861-44F3-A648-A512652ED9C5}
104110
{D124E851-B1CE-4DAD-8C1A-45697701D190} = {91E482DE-E1E7-4CE1-9511-C0AF07F3648A}
111+
{6D4A81AD-7209-4848-AFF5-232E4E3FDF41} = {A5CC96EF-1E35-4836-9EE6-11F114D3E41D}
105112
EndGlobalSection
106113
GlobalSection(ExtensibilityGlobals) = postSolution
107114
SolutionGuid = {EB6672D6-318E-493E-8B60-77F5A7A90E66}

0 commit comments

Comments
 (0)