Skip to content

Commit

Permalink
Add Cake build script
Browse files Browse the repository at this point in the history
  • Loading branch information
augustoproiete committed Mar 18, 2021
1 parent beb0381 commit 4b038b9
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 2 deletions.
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-18.04
steps:
- name: check/update cake dependencies
uses: augustoproiete-actions/nils-org--dependabot-cake-action@v1
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ Thumbs.db
*.nupkg
**/packages/*

#Ignore files created by ReSharper
_ReSharper*/
#cake
.cake/
/artifacts/*
4 changes: 4 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<Project>

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

<ItemGroup>
<SourceRoot Include="$(MSBuildThisFileDirectory)/"/>
</ItemGroup>
Expand Down
109 changes: 109 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#tool "nuget:?package=NuGet.CommandLine&version=5.8.1"

#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("./packages/**");
CleanDirectories("./**/^{bin,obj}");
});

Task("restore")
.IsDependentOn("clean")
.Does(() =>
{
NuGetRestore("./exceldna-diagnostics-serilog.sln", new NuGetRestoreSettings
{
NoCache = true,
});
});

Task("build")
.IsDependentOn("restore")
.DoesForEach(new[] { "Debug", "Release" }, (configuration) =>
{
MSBuild("./exceldna-diagnostics-serilog.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/exceldna-diagnostics-serilog/releases/tag/v{buildVersion.Version}";

DotNetCorePack("./src/ExcelDna.Diagnostics.Serilog/ExcelDna.Diagnostics.Serilog.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"
}
}

0 comments on commit 4b038b9

Please sign in to comment.