Skip to content

Commit

Permalink
Add Cake build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
augustoproiete committed Feb 14, 2021
1 parent 82c5535 commit b9d5796
Show file tree
Hide file tree
Showing 13 changed files with 203 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"isRoot": true,
"tools": {
"cake.tool": {
"version": "0.38.5",
"version": "1.0.0",
"commands": [
"dotnet-cake"
]
},
"minver-cli": {
"version": "2.3.1",
"version": "2.4.0",
"commands": [
"minver"
]
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
* text=auto

# Explicitly declare files that should always be converted to LF regardless of platform
*.sh text eol=lf
*.dotsettings text eol=lf
13 changes: 13 additions & 0 deletions .github/workflows/dependabot-cake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
on:
schedule:
# every Sunday at 6am
- cron: '0 6 * * SUN'

workflow_dispatch:

jobs:
dependabot-cake:
runs-on: ubuntu-latest
steps:
- name: check/update cake dependencies
uses: augustoproiete-actions/nils-org--dependabot-cake-action@v1
9 changes: 3 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ Thumbs.db
*.nupkg
**/packages/*

#Ignore files created by ReSharper
_ReSharper*/

#Ignore files created by NUnit
TestResult.xml
*.VisualState.xml
#cake
.cake/
/artifacts/*
6 changes: 6 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<Project>

<PropertyGroup>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<SourceRoot Include="$(MSBuildThisFileDirectory)/"/>
</ItemGroup>

</Project>
109 changes: 109 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#addin "nuget:?package=Cake.MinVer&version=1.0.0"
#addin "nuget:?package=Cake.Args&version=1.0.0"

var target = ArgumentOrDefault<string>("target") ?? "pack";
var buildVersion = MinVer(s => s.WithTagPrefix("v").WithDefaultPreReleasePhase("preview"));

Task("clean")
.Does(() =>
{
CleanDirectories("./artifacts/**");
CleanDirectories("./src/**/bin");
CleanDirectories("./src/**/obj");
CleanDirectories("./test/**/bin");
CleanDirectories("./test/**/obj");
});

Task("restore")
.IsDependentOn("clean")
.Does(() =>
{
DotNetCoreRestore("./serilog-enrichers-exceldna.sln", new DotNetCoreRestoreSettings
{
LockedMode = true,
});
});

Task("build")
.IsDependentOn("restore")
.DoesForEach(new[] { "Debug", "Release" }, (configuration) =>
{
MSBuild("./serilog-enrichers-exceldna.sln", settings => settings
.SetConfiguration(configuration)
.UseToolVersion(MSBuildToolVersion.VS2019)
.WithTarget("Rebuild")
.WithProperty("Version", buildVersion.Version)
.WithProperty("FileVersion", buildVersion.FileVersion)
.WithProperty("ContinuousIntegrationBuild", "true")
);
});

Task("test")
.IsDependentOn("build")
.Does(() =>
{
var settings = new DotNetCoreTestSettings
{
Configuration = "Release",
NoRestore = true,
NoBuild = true,
};

var projectFiles = GetFiles("./test/**/*.csproj");
foreach (var file in projectFiles)
{
DotNetCoreTest(file.FullPath, settings);
}
});

Task("pack")
.IsDependentOn("test")
.Does(() =>
{
var releaseNotes = $"https://github.com/augustoproiete/serilog-enrichers-exceldna/releases/tag/v{buildVersion.Version}";

DotNetCorePack("./src/Serilog.Enrichers.ExcelDna/Serilog.Enrichers.ExcelDna.csproj", new DotNetCorePackSettings
{
Configuration = "Release",
NoRestore = true,
NoBuild = true,
IncludeSymbols = true,
IncludeSource = true,
OutputDirectory = "./artifacts/nuget",
ArgumentCustomization = args =>
args.AppendQuoted($"-p:Version={buildVersion.Version}")
.AppendQuoted($"-p:PackageReleaseNotes={releaseNotes}")
});
});

Task("push")
.IsDependentOn("pack")
.Does(() =>
{
var url = EnvironmentVariable("NUGET_URL");
if (string.IsNullOrWhiteSpace(url))
{
Information("No NuGet URL specified. Skipping publishing of NuGet packages");
return;
}

var apiKey = EnvironmentVariable("NUGET_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey))
{
Information("No NuGet API key specified. Skipping publishing of NuGet packages");
return;
}

var nugetPushSettings = new DotNetCoreNuGetPushSettings
{
Source = url,
ApiKey = apiKey,
};

foreach (var nugetPackageFile in GetFiles("./artifacts/nuget/*.nupkg"))
{
DotNetCoreNuGetPush(nugetPackageFile.FullPath, nugetPushSettings);
}
});

RunTarget(target);
11 changes: 11 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@echo on
@cd %~dp0

set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
set DOTNET_CLI_TELEMETRY_OPTOUT=1
set DOTNET_NOLOGO=1

dotnet tool restore
@if %ERRORLEVEL% neq 0 goto :eof

dotnet cake %*
13 changes: 13 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$ErrorActionPreference = 'Stop'

Set-Location -LiteralPath $PSScriptRoot

$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = '1'
$env:DOTNET_CLI_TELEMETRY_OPTOUT = '1'
$env:DOTNET_NOLOGO = '1'

dotnet tool restore
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

dotnet cake @args
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
12 changes: 12 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -euox pipefail

cd "$(dirname "${BASH_SOURCE[0]}")"

export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_NOLOGO=1

dotnet tool restore

dotnet cake "$@"
12 changes: 12 additions & 0 deletions cake.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Nuget]
Source=https://api.nuget.org/v3/index.json
UseInProcessClient=true
LoadDependencies=false

[Paths]
Tools=./.cake
Addins=./.cake/addins
Modules=./.cake/modules

[Settings]
SkipVerification=false
7 changes: 7 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sdk": {
"allowPrerelease": false,
"version": "5.0.100",
"rollForward": "latestFeature"
}
}
13 changes: 13 additions & 0 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<disabledPackageSources>
<clear />
</disabledPackageSources>
<fallbackPackageFolders>
<clear />
</fallbackPackageFolders>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<PackageProjectUrl>https://github.com/augustoproiete/serilog-enrichers-exceldna</PackageProjectUrl>
<PackageReleaseNotes>https://github.com/augustoproiete/serilog-enrichers-exceldna/releases</PackageReleaseNotes>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/augustoproiete/serilog-enrichers-exceldna</RepositoryUrl>
<RepositoryUrl>https://github.com/augustoproiete/serilog-enrichers-exceldna.git</RepositoryUrl>
</PropertyGroup>

<PropertyGroup>
Expand Down

0 comments on commit b9d5796

Please sign in to comment.