-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
100 lines (81 loc) · 2.43 KB
/
build.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
89
90
91
92
93
94
95
96
97
98
99
100
///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
///////////////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var packageversion = Argument("packageversion", "0.1");
///////////////////////////////////////////////////////////////////////////////
// Variables and Constants
///////////////////////////////////////////////////////////////////////////////
const string BuildArtifacts = "./BuildArtifacts";
///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////
Setup(context =>
{
packageversion = packageversion
.Replace("refs/tags/", "")
.TrimStart('v');
Information($"Using version: {packageversion}");
});
Task("Build")
.Does(() =>
{
DotNetClean("./src/Cake.grate/Cake.grate.csproj");
var settings = new DotNetBuildSettings
{
Configuration = "Release",
MSBuildSettings = new DotNetMSBuildSettings
{
Version = packageversion
}
};
DotNetBuild("./src/Cake.grate/Cake.grate.csproj", settings);
});
Task("Test")
.Does(() =>
{
DotNetTest("./src/Cake.grate.Tests/Cake.grate.Tests.csproj");
});
Task("Pack")
.Does(() =>
{
CleanDirectory(BuildArtifacts);
var settings = new DotNetPackSettings
{
Configuration = "Release",
OutputDirectory = BuildArtifacts,
NoBuild = true, //already built
IncludeSymbols = true,
MSBuildSettings = new DotNetMSBuildSettings
{
Version = packageversion
}
};
DotNetPack("./src/Cake.grate/Cake.grate.csproj", settings);
});
Task("Push")
.Does(() =>
{
var settings = new DotNetNuGetPushSettings
{
Source = "https://api.nuget.org/v3/index.json",
ApiKey = EnvironmentVariable<string>("NugetKey", "")
};
var packageFilePath = GetFiles($"{BuildArtifacts}/Cake.grate*.nupkg").Single();
DotNetNuGetPush(packageFilePath, settings);
});
Task("Build-And-Test")
.IsDependentOn("Build")
.IsDependentOn("Test");
Task("Deploy")
.IsDependentOn("Build-And-Test")
.IsDependentOn("Pack")
.IsDependentOn("Push");
Task("Default")
.Does(() =>
{
Information(@"The following tasks are available:
Build-And-Test: Builds the Addin and runs the Unit Tests
Deploy: Runs Build-And-Test and then packs and deploys the Nuget package");
});
RunTarget(target);