-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBuildLifetime.cs
52 lines (43 loc) · 2.47 KB
/
BuildLifetime.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using Cake.Common;
using Cake.Common.Diagnostics;
using Cake.Common.IO;
using Cake.Common.Tools.GitVersion;
using Cake.Core;
using Cake.Frosting;
using Cake.GitVersioning;
namespace Build
{
public sealed class BuildLifetime : FrostingLifetime<BuildContext>
{
public override void Setup(BuildContext context, ISetupContext info)
{
var gitVersion = context.GitVersion();
context.GitVersion = context.GitVersioningGetVersion();
context.Branch = gitVersion.BranchName;
context.Commit = gitVersion.Sha;
context.IsPublicRelease = context.Branch == "master";
context.Information("Branch: {0}", context.Branch);
if (context.IsPublicRelease)
{
context.Information("Building a {0} release.", "public");
}
else
{
context.Information("Building a {0}release.", "pre-");
}
context.Information($"nuget.exe ({context.Tools.Resolve("nuget.exe")}) {(context.FileExists(context.Tools.Resolve("nuget.exe")) ? "was found" : "is missing")}.");
context.Information($"dotnet.exe ({context.Tools.Resolve("dotnet.exe")}) {(context.FileExists(context.Tools.Resolve("dotnet.exe")) ? "was found" : "is missing")}.");
context.Information($"CodeCoverage.exe ({context.Tools.Resolve("CodeCoverage.exe")}) {(context.FileExists(context.Tools.Resolve("CodeCoverage.exe")) ? "was found" : "is missing")}.");
context.Information($"NUGETORG_APIKEY was{(string.IsNullOrEmpty(context.EnvironmentVariable("NUGETORG_APIKEY")) ? " not" : "")} set.");
context.Information($"CODECOV_TOKEN was{(string.IsNullOrEmpty(context.EnvironmentVariable("CODECOV_TOKEN")) ? " not" : "")} set.");
context.Information($"ApiCredentials__Email was{(string.IsNullOrEmpty(context.EnvironmentVariable("ApiCredentials__Email")) ? " not" : "")} set.");
context.Information($"ApiCredentials__Password was{(string.IsNullOrEmpty(context.EnvironmentVariable("ApiCredentials__Password")) ? " not" : "")} set.");
context.Information("reportsFolder: {0}", context.ReportsFolder.FullPath);
context.Information("coberturaResultFile: {0}", context.CoberturaResultFile.FullPath);
context.Information("dotnet tool: {0}", context.Tools.Resolve("dotnet.exe"));
}
public override void Teardown(BuildContext context, ITeardownContext info)
{
}
}
}