forked from cake-contrib/Cake.Recipe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
recipe.cake
88 lines (76 loc) · 3.13 KB
/
recipe.cake
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#addin nuget:?package=Cake.FileHelpers&version=3.2.0
#load "./includes.cake"
public class BuildMetaData
{
public static string Date { get; } = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss");
public static string Version { get; } = "DogFood";
public static string CakeVersion { get; } = typeof(ICakeContext).Assembly.GetName().Version.ToString();
}
Environment.SetVariableNames();
var standardNotificationMessage = "Version {0} of {1} has just been released, this will be available here https://www.nuget.org/packages/{1}, once package indexing is complete.";
BuildParameters.SetParameters(context: Context,
buildSystem: BuildSystem,
sourceDirectoryPath: "./Source",
title: "Cake.Recipe",
repositoryOwner: "cake-contrib",
repositoryName: "Cake.Recipe",
appVeyorAccountName: "cakecontrib",
shouldRunInspectCode: false,
shouldRunCoveralls: false,
shouldRunCodecov: false,
shouldRunDotNetCorePack: true,
twitterMessage: standardNotificationMessage);
BuildParameters.PrintParameters(Context);
ToolSettings.SetToolSettings(context: Context);
BuildParameters.Tasks.CleanTask
.IsDependentOn("Generate-Version-File");
Task("Generate-Version-File")
.Does<BuildVersion>((context, buildVersion) => {
var buildMetaDataCodeGen = TransformText(@"
public class BuildMetaData
{
public static string Date { get; } = ""<%date%>"";
public static string Version { get; } = ""<%version%>"";
public static string CakeVersion { get; } = ""<%cakeversion%>"";
}",
"<%",
"%>"
)
.WithToken("date", BuildMetaData.Date)
.WithToken("version", buildVersion.SemVersion)
.WithToken("cakeversion", BuildMetaData.CakeVersion)
.ToString();
System.IO.File.WriteAllText(
"./Source/Cake.Recipe/Content/version.cake",
buildMetaDataCodeGen
);
});
Task("Run-Local-Integration-Tests")
.IsDependentOn("Default")
.Does<BuildVersion>((context, buildVersion) => {
CakeExecuteScript("./test.cake",
new CakeSettings {
Arguments = new Dictionary<string, string>{
{ "recipe-version", buildVersion.SemVersion },
{ "verbosity", Context.Log.Verbosity.ToString("F") }
}});
});
Task("Set-CakeVersion-InBuild")
.IsDependeeOf("DotNetCore-Build")
.Does<DotNetCoreMSBuildSettings>((context, msBuildSettings) =>
{
var cakeVersion = FileReadLines(File("./Source/Cake.Recipe/cake-version.yml"))
.Where(x => x.StartsWith("TargetCakeVersion:"))
.FirstOrDefault();
if(string.IsNullOrEmpty(cakeVersion))
{
cakeVersion = "NotSet";
}
else
{
cakeVersion = cakeVersion.Substring(18).Trim();
}
Information("Settings CakeVersion in build to: {0}", cakeVersion);
msBuildSettings.WithProperty("CakeVersion", cakeVersion);
});
Build.RunDotNetCore();