diff --git a/.gitattributes b/.gitattributes index 7a3df5e..4b1de17 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/.github/workflows/dependabot-cake.yml b/.github/workflows/dependabot-cake.yml new file mode 100644 index 0000000..7813869 --- /dev/null +++ b/.github/workflows/dependabot-cake.yml @@ -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 diff --git a/.gitignore b/.gitignore index f52b37c..9ed1307 100644 --- a/.gitignore +++ b/.gitignore @@ -24,5 +24,6 @@ Thumbs.db *.nupkg **/packages/* -#Ignore files created by ReSharper -_ReSharper*/ +#cake +.cake/ +/artifacts/* diff --git a/Directory.Build.props b/Directory.Build.props index 4d6a32b..2c3ecd9 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,9 @@  + + latest + + diff --git a/build.cake b/build.cake new file mode 100644 index 0000000..522eec9 --- /dev/null +++ b/build.cake @@ -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("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); diff --git a/build.cmd b/build.cmd new file mode 100644 index 0000000..d060b75 --- /dev/null +++ b/build.cmd @@ -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 %* diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..21821d2 --- /dev/null +++ b/build.ps1 @@ -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 } diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..31be886 --- /dev/null +++ b/build.sh @@ -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 "$@" diff --git a/cake.config b/cake.config new file mode 100644 index 0000000..513b1e8 --- /dev/null +++ b/cake.config @@ -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 diff --git a/global.json b/global.json new file mode 100644 index 0000000..5f35d39 --- /dev/null +++ b/global.json @@ -0,0 +1,7 @@ +{ + "sdk": { + "allowPrerelease": false, + "version": "5.0.100", + "rollForward": "latestFeature" + } +}