Skip to content

Commit 92044c2

Browse files
authored
Merge pull request #68 from nblumhardt/universal-build
Switch to GitHub Actions build
2 parents cdd393b + 02c5204 commit 92044c2

File tree

7 files changed

+105
-46
lines changed

7 files changed

+105
-46
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+130))" >> $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
40+

Build.ps1

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,78 @@
1-
echo "build: Build started"
1+
Write-Output "build: Build started"
22

33
Push-Location $PSScriptRoot
44

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

1015
& dotnet restore --no-cache
1116

12-
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
13-
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
14-
$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
19+
20+
Write-Output "build: Package version prefix is $versionPrefix"
1521

16-
echo "build: Version suffix is $suffix"
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"]
1725

18-
foreach ($src in ls src/*) {
26+
Write-Output "build: Package version suffix is $suffix"
27+
28+
foreach ($src in Get-ChildItem src/*) {
1929
Push-Location $src
2030

21-
echo "build: Packaging project in $src"
31+
Write-Output "build: Packaging project in $src"
2232

2333
if ($suffix) {
24-
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix
34+
& dotnet publish -c Release -o ./obj/publish --version-suffix=$suffix
35+
& dotnet pack -c Release -o ../../artifacts --no-build --version-suffix=$suffix
2536
} else {
26-
& dotnet pack -c Release -o ..\..\artifacts
37+
& dotnet publish -c Release -o ./obj/publish
38+
& dotnet pack -c Release -o ../../artifacts --no-build
2739
}
28-
29-
if($LASTEXITCODE -ne 0) { exit 1 }
40+
if($LASTEXITCODE -ne 0) { throw "Packaging failed" }
3041

3142
Pop-Location
3243
}
3344

34-
foreach ($test in ls test/*.PerformanceTests) {
45+
Write-Output "build: Checking complete solution builds"
46+
& dotnet build
47+
if($LASTEXITCODE -ne 0) { throw "Solution build failed" }
48+
49+
foreach ($test in Get-ChildItem test/*.Tests) {
3550
Push-Location $test
3651

37-
echo "build: Building performance test project in $test"
52+
Write-Output "build: Testing project in $test"
3853

39-
& dotnet build -c Release
40-
if($LASTEXITCODE -ne 0) { exit 2 }
54+
& dotnet test -c Release
55+
if($LASTEXITCODE -ne 0) { throw "Testing failed" }
4156

4257
Pop-Location
4358
}
4459

45-
foreach ($test in ls test/*.Tests) {
46-
Push-Location $test
60+
Pop-Location
4761

48-
echo "build: Testing project in $test"
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+
}
4972

50-
& dotnet test -c Release
51-
if($LASTEXITCODE -ne 0) { exit 3 }
73+
if (!($suffix)) {
74+
Write-Output "build: Creating release for version $versionPrefix"
5275

53-
Pop-Location
76+
iex "gh release create v$versionPrefix --title v$versionPrefix --generate-notes $(get-item ./artifacts/*.nupkg) $(get-item ./artifacts/*.snupkg)"
77+
}
5478
}
55-
56-
Pop-Location

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>9.0.0</VersionPrefix>
4+
</PropertyGroup>
5+
</Project>

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Seq.Extensions.Logging [![Build status](https://ci.appveyor.com/api/projects/status/h7r1hv3cpd6e2ou3?svg=true)](https://ci.appveyor.com/project/datalust/seq-extensions-logging) [![NuGet Pre Release](https://img.shields.io/nuget/vpre/Seq.Extensions.Logging.svg)](https://nuget.org/packages/Seq.Extensions.Logging)
1+
# Seq.Extensions.Logging [![NuGet Pre Release](https://img.shields.io/nuget/vpre/Seq.Extensions.Logging.svg)](https://nuget.org/packages/Seq.Extensions.Logging)
22

33
[Seq](https://datalust.co/seq) is a flexible self-hosted back-end for the ASP.NET Core logging subsystem (_Microsoft.Extensions.Logging_). Log events generated by the framework and application code are sent over HTTP to a Seq server, where the structured data associated with each event is used for powerful filtering, correlation, and analysis.
44

@@ -181,5 +181,5 @@ you're targeting `net8.0`, target a 8.* version of _Seq.Extensions.Logging_ for
181181

182182
### Credits
183183

184-
This package is based on a subset of the powerful [Serilog](https://serilog.net) library. Not all of the options supported by the Serilog and Seq client libraries are present in
185-
the _Seq.Extensions.Logging_ package.
184+
This package is based on a subset of [Serilog](https://serilog.net). Not all of the options supported by the Serilog and Seq client
185+
libraries are present in the _Seq.Extensions.Logging_ package.

appveyor.yml

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

seq-extensions-logging.sln

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0069BFD6-B0E
66
EndProject
77
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "global", "global", "{B0D573D8-1AE2-4C5C-817A-95815067452E}"
88
ProjectSection(SolutionItems) = preProject
9-
appveyor.yml = appveyor.yml
10-
Build.ps1 = Build.ps1
119
LICENSE = LICENSE
1210
README.md = README.md
1311
global.json = global.json
1412
.gitattributes = .gitattributes
1513
.gitignore = .gitignore
14+
Directory.Build.props = Directory.Build.props
15+
Build.ps1 = Build.ps1
1616
EndProjectSection
1717
EndProject
1818
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{D54DE844-AC36-4872-928F-5F573D41ACAE}"
@@ -27,6 +27,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebExample", "example\WebEx
2727
EndProject
2828
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleExample", "example\ConsoleExample\ConsoleExample.csproj", "{3C7C4F1B-7BB1-48F6-BC9E-0A81F632458B}"
2929
EndProject
30+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{98FB80CE-7AEF-4FA3-88D0-9812529BC15F}"
31+
EndProject
32+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{8BCBFBF7-24E1-491A-956E-1AC7E1183270}"
33+
ProjectSection(SolutionItems) = preProject
34+
.github\workflows\ci.yml = .github\workflows\ci.yml
35+
EndProjectSection
36+
EndProject
3037
Global
3138
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3239
Debug|Any CPU = Debug|Any CPU
@@ -58,6 +65,7 @@ Global
5865
{64A3F2C5-D71E-44A6-8DC7-99474765B32E} = {D54DE844-AC36-4872-928F-5F573D41ACAE}
5966
{FC44EC1F-AD83-4522-99B4-4B309B8CC78A} = {1C72E771-7C72-4A30-A408-5CE66E792ADF}
6067
{3C7C4F1B-7BB1-48F6-BC9E-0A81F632458B} = {1C72E771-7C72-4A30-A408-5CE66E792ADF}
68+
{8BCBFBF7-24E1-491A-956E-1AC7E1183270} = {98FB80CE-7AEF-4FA3-88D0-9812529BC15F}
6169
EndGlobalSection
6270
GlobalSection(ExtensibilityGlobals) = postSolution
6371
SolutionGuid = {A6DD7789-D2A5-43A4-A4FE-E138166E15C7}

src/Seq.Extensions.Logging/Seq.Extensions.Logging.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
<PropertyGroup>
44
<Description>Add centralized structured log collection to ASP.NET Core apps with one line of code.</Description>
5-
<VersionPrefix>9.0.0</VersionPrefix>
65
<Authors>Datalust and Contributors</Authors>
76
<TargetFrameworks>netstandard2.0;net8.0;net9.0</TargetFrameworks>
87
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

0 commit comments

Comments
 (0)