Skip to content

Commit ab5bb15

Browse files
authored
Merge pull request #172 from nblumhardt/actions-build
Switch build to Actions
2 parents 5839480 + 95e0cc6 commit ab5bb15

File tree

11 files changed

+149
-88
lines changed

11 files changed

+149
-88
lines changed

.github/.DS_Store

8 KB
Binary file not shown.

.github/workflows/ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
# The build must run on Windows so that .NET Framework targets can be built and tested.
19+
runs-on: windows-latest
20+
21+
permissions:
22+
contents: write
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Setup
27+
uses: actions/setup-dotnet@v4
28+
with:
29+
dotnet-version: 9.0.x
30+
- name: Compute build number
31+
shell: bash
32+
run: |
33+
echo "CI_BUILD_NUMBER=$(($CI_BUILD_NUMBER_BASE+2300))" >> $GITHUB_ENV
34+
- name: Build and Publish
35+
env:
36+
DOTNET_CLI_TELEMETRY_OPTOUT: true
37+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
38+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
shell: pwsh
40+
run: |
41+
./Build.ps1

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,5 @@ _Pvt_Extensions
234234

235235
# FAKE - F# Make
236236
.fake/
237+
238+
.DS_Store/

Build.ps1

Lines changed: 62 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,79 @@
1-
echo "build: Build started"
1+
Write-Output "build: Tool versions follow"
2+
3+
dotnet --version
4+
dotnet --list-sdks
5+
6+
Write-Output "build: Build started"
27

38
Push-Location $PSScriptRoot
9+
try {
10+
if(Test-Path .\artifacts) {
11+
Write-Output "build: Cleaning ./artifacts"
12+
Remove-Item ./artifacts -Force -Recurse
13+
}
414

5-
if(Test-Path .\artifacts) {
6-
echo "build: Cleaning .\artifacts"
7-
Remove-Item .\artifacts -Force -Recurse
8-
}
15+
& dotnet restore --no-cache
916

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

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"]
15-
$commitHash = $(git rev-parse --short HEAD)
16-
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
20+
Write-Output "build: Package version prefix is $versionPrefix"
1721

18-
echo "build: Package version suffix is $suffix"
19-
echo "build: Build version suffix is $buildSuffix"
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+
$commitHash = $(git rev-parse --short HEAD)
26+
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
2027

21-
foreach ($src in ls src/*) {
22-
Push-Location $src
28+
Write-Output "build: Package version suffix is $suffix"
29+
Write-Output "build: Build version suffix is $buildSuffix"
2330

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

26-
& dotnet build -c Release --version-suffix=$buildSuffix -p:EnableSourceLink=true
27-
if ($suffix) {
28-
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix --no-build
29-
} else {
30-
& dotnet pack -c Release -o ..\..\artifacts --no-build
34+
foreach ($src in Get-ChildItem src/*) {
35+
Push-Location $src
36+
37+
Write-Output "build: Packaging project in $src"
38+
39+
if ($suffix) {
40+
& dotnet pack -c Release --no-build --no-restore -o ../../artifacts --version-suffix=$suffix
41+
} else {
42+
& dotnet pack -c Release --no-build --no-restore -o ../../artifacts
43+
}
44+
if($LASTEXITCODE -ne 0) { throw "Packaging failed" }
45+
46+
Pop-Location
3147
}
32-
if($LASTEXITCODE -ne 0) { throw "build failed" }
3348

34-
Pop-Location
35-
}
49+
foreach ($test in Get-ChildItem test/*.Tests) {
50+
Push-Location $test
51+
52+
Write-Output "build: Testing project in $test"
53+
54+
& dotnet test -c Release --no-build --no-restore
55+
if($LASTEXITCODE -ne 0) { throw "Testing failed" }
56+
57+
Pop-Location
58+
}
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).
3663

37-
foreach ($test in ls test/*.Tests) {
38-
Push-Location $test
64+
Write-Output "build: Publishing NuGet packages"
3965

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

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

74+
iex "gh release create v$versionPrefix --title v$versionPrefix --generate-notes $(get-item ./artifacts/*.nupkg) $(get-item ./artifacts/*.snupkg)"
75+
}
76+
}
77+
} finally {
4578
Pop-Location
4679
}
47-
48-
Pop-Location

Directory.Build.props

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project>
2+
<!-- Properties in this file are expected to be identical for all Serilog organization projects. If
3+
a property value is project-specific, please record it in the CSPROJ file instead. -->
4+
<Import Project="$(MSBuildThisFileDirectory)Directory.Version.props" />
5+
<PropertyGroup>
6+
<LangVersion>latest</LangVersion>
7+
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
8+
<!-- The condition is required to support BenchmarkDotNet -->
9+
<SignAssembly Condition="Exists('$(MSBuildThisFileDirectory)assets/Serilog.snk')">true</SignAssembly>
10+
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)assets/Serilog.snk</AssemblyOriginatorKeyFile>
11+
<CheckEolTargetFramework>false</CheckEolTargetFramework>
12+
<Nullable>enable</Nullable>
13+
<ImplicitUsings>enable</ImplicitUsings>
14+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
15+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
16+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
17+
<IncludeSymbols>true</IncludeSymbols>
18+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
19+
</PropertyGroup>
20+
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
21+
<Reference Include="System" />
22+
<Reference Include="System.Core" />
23+
<Reference Include="Microsoft.CSharp" />
24+
</ItemGroup>
25+
</Project>

Directory.Version.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>6.1.0</VersionPrefix>
4+
</PropertyGroup>
5+
</Project>

appveyor.yml

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

build.sh

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

serilog-sinks-console.sln

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ VisualStudioVersion = 15.0.26430.12
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{037440DE-440B-4129-9F7A-09B42D00397E}"
77
EndProject
8-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{E9D1B5E1-DEB9-4A04-8BAB-24EC7240ADAF}"
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{E9D1B5E1-DEB9-4A04-8BAB-24EC7240ADAF}"
99
ProjectSection(SolutionItems) = preProject
1010
.gitattributes = .gitattributes
1111
.gitignore = .gitignore
12-
appveyor.yml = appveyor.yml
1312
Build.ps1 = Build.ps1
1413
CHANGES.md = CHANGES.md
1514
LICENSE = LICENSE
@@ -29,6 +28,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleDemo", "sample\Conso
2928
EndProject
3029
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SyncWritesDemo", "sample\SyncWritesDemo\SyncWritesDemo.csproj", "{633AE0AD-C9D4-440D-874A-C0F4632DB75F}"
3130
EndProject
31+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{91B268E6-3BCF-49B4-A04D-8467AE23410A}"
32+
ProjectSection(SolutionItems) = preProject
33+
.github\ISSUE_TEMPLATE.md = .github\ISSUE_TEMPLATE.md
34+
.github\PULL_REQUEST_TEMPLATE.md = .github\PULL_REQUEST_TEMPLATE.md
35+
EndProjectSection
36+
EndProject
37+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{F4C015DE-80BA-4D63-9D3D-D687999B4960}"
38+
ProjectSection(SolutionItems) = preProject
39+
.github\workflows\ci.yml = .github\workflows\ci.yml
40+
EndProjectSection
41+
EndProject
3242
Global
3343
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3444
Debug|Any CPU = Debug|Any CPU
@@ -60,6 +70,7 @@ Global
6070
{1D56534C-4009-42C2-A573-789CAE6B8AA9} = {7D0692CD-F95D-4BF9-8C63-B4A1C078DF23}
6171
{DBF4907A-63A2-4895-8DEF-59F90C20380B} = {CF817664-4CEC-4B6A-9C57-A0D687757D82}
6272
{633AE0AD-C9D4-440D-874A-C0F4632DB75F} = {CF817664-4CEC-4B6A-9C57-A0D687757D82}
73+
{F4C015DE-80BA-4D63-9D3D-D687999B4960} = {91B268E6-3BCF-49B4-A04D-8467AE23410A}
6374
EndGlobalSection
6475
GlobalSection(ExtensibilityGlobals) = postSolution
6576
SolutionGuid = {43C32ED4-D39A-4E27-AE99-7BB8C883833C}

src/Serilog.Sinks.Console/Serilog.Sinks.Console.csproj

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<Description>A Serilog sink that writes log events to the console/terminal.</Description>
4-
<VersionPrefix>6.1.0</VersionPrefix>
54
<Authors>Serilog Contributors</Authors>
65
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net462;net471</TargetFrameworks>
76
<TargetFrameworks>$(TargetFrameworks);netstandard2.0;net6.0;net8.0</TargetFrameworks>
8-
<Nullable>enable</Nullable>
9-
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
10-
<SignAssembly>true</SignAssembly>
11-
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
127
<PackageTags>serilog;console;terminal</PackageTags>
138
<PackageIcon>icon.png</PackageIcon>
149
<PackageProjectUrl>https://github.com/serilog/serilog-sinks-console</PackageProjectUrl>
1510
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
16-
<RepositoryUrl>https://github.com/serilog/serilog-sinks-console</RepositoryUrl>
17-
<RepositoryType>git</RepositoryType>
18-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
19-
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
2011
<RootNamespace>Serilog</RootNamespace>
21-
<LangVersion>latest</LangVersion>
2212
<PackageReadmeFile>README.md</PackageReadmeFile>
2313
</PropertyGroup>
2414

0 commit comments

Comments
 (0)