Skip to content

Commit 17adbed

Browse files
Add build scripts
1 parent de17feb commit 17adbed

File tree

9 files changed

+260
-0
lines changed

9 files changed

+260
-0
lines changed

.config/dotnet-tools.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"cake.tool": {
6+
"version": "1.1.0",
7+
"commands": [
8+
"dotnet-cake"
9+
]
10+
},
11+
"minver-cli": {
12+
"version": "2.5.0",
13+
"commands": [
14+
"minver"
15+
]
16+
}
17+
}
18+
}

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "nuget"
4+
directory: "/src"
5+
schedule:
6+
interval: "daily"
7+
target-branch: "master"
8+
ignore:
9+
- dependency-name: "Serilog"
10+
- package-ecosystem: "github-actions"
11+
directory: "/"
12+
schedule:
13+
interval: "daily"
14+
target-branch: "master"

.github/workflows/ci.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
- develop
6+
- "feature/**"
7+
- "release/**"
8+
- "hotfix/**"
9+
tags:
10+
- "*.*.*"
11+
paths-ignore:
12+
- "README.md"
13+
14+
pull_request:
15+
16+
workflow_dispatch:
17+
18+
env:
19+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
20+
DOTNET_CLI_TELEMETRY_OPTOUT: true
21+
DOTNET_NOLOGO: true
22+
23+
jobs:
24+
build:
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
job:
29+
- os: ubuntu-20.04
30+
build: ./build.sh
31+
push: true
32+
- os: windows-2019
33+
build: ./build.cmd
34+
- os: macos-11
35+
build: ./build.sh
36+
name: ${{ matrix.job.os }}
37+
runs-on: ${{ matrix.job.os }}
38+
steps:
39+
- name: Setup netcoreapp3.1
40+
uses: actions/[email protected]
41+
with:
42+
dotnet-version: "3.1.412"
43+
- name: Setup net5.0
44+
uses: actions/[email protected]
45+
with:
46+
dotnet-version: "5.0.400"
47+
- name: Run dotnet --info
48+
run: dotnet --info
49+
- uses: actions/[email protected]
50+
with:
51+
fetch-depth: 0
52+
- name: Build
53+
run: ${{ matrix.job.build }} --verbosity=diagnostic --target=pack
54+
- name: Publish artifacts
55+
if: matrix.job.push && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))
56+
uses: actions/[email protected]
57+
with:
58+
if-no-files-found: warn
59+
name: package
60+
path: artifacts/nuget/**/*
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
on:
2+
schedule:
3+
# every Sunday at 6am
4+
- cron: '0 6 * * SUN'
5+
6+
workflow_dispatch:
7+
8+
jobs:
9+
dependabot-cake:
10+
runs-on: ubuntu-18.04
11+
steps:
12+
- name: check/update cake dependencies
13+
uses: augustoproiete-actions/nils-org--dependabot-cake-action@v1

build.cake

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#addin "nuget:?package=Cake.MinVer&version=1.0.1"
2+
#addin "nuget:?package=Cake.Args&version=1.0.1"
3+
4+
var target = ArgumentOrDefault<string>("target") ?? "pack";
5+
var buildVersion = MinVer(s => s.WithTagPrefix("v").WithDefaultPreReleasePhase("preview"));
6+
7+
Task("clean")
8+
.Does(() =>
9+
{
10+
CleanDirectories("./artifacts/**");
11+
CleanDirectories("./**/^{bin,obj}");
12+
});
13+
14+
Task("restore")
15+
.IsDependentOn("clean")
16+
.Does(() =>
17+
{
18+
DotNetCoreRestore("./serilog-enrichers-globallogcontext.sln", new DotNetCoreRestoreSettings
19+
{
20+
LockedMode = true,
21+
});
22+
});
23+
24+
Task("build")
25+
.IsDependentOn("restore")
26+
.DoesForEach(new[] { "Debug", "Release" }, (configuration) =>
27+
{
28+
DotNetCoreBuild("./serilog-enrichers-globallogcontext.sln", new DotNetCoreBuildSettings
29+
{
30+
Configuration = configuration,
31+
NoRestore = true,
32+
NoIncremental = false,
33+
MSBuildSettings = new DotNetCoreMSBuildSettings()
34+
.WithProperty("Version", buildVersion.Version)
35+
.WithProperty("AssemblyVersion", buildVersion.AssemblyVersion)
36+
.WithProperty("FileVersion", buildVersion.FileVersion)
37+
.WithProperty("ContinuousIntegrationBuild", BuildSystem.IsLocalBuild ? "false" : "true")
38+
});
39+
});
40+
41+
Task("test")
42+
.IsDependentOn("build")
43+
.Does(() =>
44+
{
45+
var settings = new DotNetCoreTestSettings
46+
{
47+
Configuration = "Release",
48+
NoRestore = true,
49+
NoBuild = true,
50+
};
51+
52+
var projectFiles = GetFiles("./test/**/*.csproj");
53+
foreach (var file in projectFiles)
54+
{
55+
DotNetCoreTest(file.FullPath, settings);
56+
}
57+
});
58+
59+
Task("pack")
60+
.IsDependentOn("test")
61+
.Does(() =>
62+
{
63+
var releaseNotes = $"https://github.com/augustoproiete/serilog-enrichers-globallogcontext/releases/tag/v{buildVersion.Version}";
64+
65+
DotNetCorePack("./src/Serilog.Enrichers.GlobalLogContext/Serilog.Enrichers.GlobalLogContext.csproj", new DotNetCorePackSettings
66+
{
67+
Configuration = "Release",
68+
NoRestore = true,
69+
NoBuild = true,
70+
OutputDirectory = "./artifacts/nuget",
71+
MSBuildSettings = new DotNetCoreMSBuildSettings()
72+
.WithProperty("Version", buildVersion.Version)
73+
.WithProperty("PackageReleaseNotes", releaseNotes)
74+
});
75+
});
76+
77+
Task("push")
78+
.IsDependentOn("pack")
79+
.Does(context =>
80+
{
81+
var url = context.EnvironmentVariable("NUGET_URL");
82+
if (string.IsNullOrWhiteSpace(url))
83+
{
84+
context.Information("No NuGet URL specified. Skipping publishing of NuGet packages");
85+
return;
86+
}
87+
88+
var apiKey = context.EnvironmentVariable("NUGET_API_KEY");
89+
if (string.IsNullOrWhiteSpace(apiKey))
90+
{
91+
context.Information("No NuGet API key specified. Skipping publishing of NuGet packages");
92+
return;
93+
}
94+
95+
var nugetPushSettings = new DotNetCoreNuGetPushSettings
96+
{
97+
Source = url,
98+
ApiKey = apiKey,
99+
};
100+
101+
foreach (var nugetPackageFile in GetFiles("./artifacts/nuget/*.nupkg"))
102+
{
103+
DotNetCoreNuGetPush(nugetPackageFile.FullPath, nugetPushSettings);
104+
}
105+
});
106+
107+
RunTarget(target);

build.cmd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@echo on
2+
@cd %~dp0
3+
4+
set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
5+
set DOTNET_CLI_TELEMETRY_OPTOUT=1
6+
set DOTNET_NOLOGO=1
7+
8+
dotnet tool restore
9+
@if %ERRORLEVEL% neq 0 goto :eof
10+
11+
dotnet cake %*

build.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
$ErrorActionPreference = 'Stop'
2+
3+
Set-Location -LiteralPath $PSScriptRoot
4+
5+
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = '1'
6+
$env:DOTNET_CLI_TELEMETRY_OPTOUT = '1'
7+
$env:DOTNET_NOLOGO = '1'
8+
9+
dotnet tool restore
10+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
11+
12+
dotnet cake @args
13+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

build.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
set -euox pipefail
3+
4+
cd "$(dirname "${BASH_SOURCE[0]}")"
5+
6+
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
7+
export DOTNET_CLI_TELEMETRY_OPTOUT=1
8+
export DOTNET_NOLOGO=1
9+
10+
dotnet tool restore
11+
12+
dotnet cake "$@"

cake.config

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[Nuget]
2+
Source=https://api.nuget.org/v3/index.json
3+
UseInProcessClient=true
4+
LoadDependencies=false
5+
6+
[Paths]
7+
Tools=./.cake
8+
Addins=./.cake/addins
9+
Modules=./.cake/modules
10+
11+
[Settings]
12+
SkipVerification=false

0 commit comments

Comments
 (0)