-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.cake
102 lines (85 loc) · 3.07 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
101
102
#addin Cake.Git
///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
///////////////////////////////////////////////////////////////////////////////
var output=Argument<string>("output", "Output");
var version=Argument<string>("version", "0.0.4");
var target = Argument<string>("target", "Default");
var release = Argument<bool>("release", true);
var nugetApiKey = Argument<string>("nugetApiKey", null);
var currentBranch = Argument<string>("currentBranch", GitBranchCurrent("./").FriendlyName);
var configuration=release?"Release":"Debug";
///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
///////////////////////////////////////////////////////////////////////////////
Setup(ctx =>
{
// Executed BEFORE the first task.
Information("Running tasks...");
});
Teardown(ctx =>
{
// Executed AFTER the last task.
Information("Finished running tasks.");
});
///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////
Task("UpdateVersion").DoesForEach(GetFiles("**/Uragano.*.csproj"),(file)=>{
XmlPoke(file,"/Project/PropertyGroup/Version",version);
XmlPoke(file,"/Project/PropertyGroup/GeneratePackageOnBuild","false");
XmlPoke(file,"/Project/PropertyGroup/Description","A simple, high performance RPC library.");
XmlPoke(file,"/Project/PropertyGroup/PackageProjectUrl","https://github.com/1100100/Uragano");
XmlPoke(file,"/Project/PropertyGroup/PackageTags","Uragano,RPC,DotNetty,Microservice,MessagePack,DynamicProxy,dotnetcore,service-discovery,polly,circuit-breaker,consul,zookeeper,dependency-injection");
XmlPoke(file,"/Project/PropertyGroup/PackageIconUrl","https://raw.githubusercontent.com/1100100/Uragano/master/icon.png");
XmlPoke(file,"/Project/PropertyGroup/Authors","Owen");
XmlPoke(file,"/Project/PropertyGroup/PackageLicenseExpression","MIT");
});
Task("Restore").Does(()=>{
DotNetCoreRestore();
});
Task("Build").Does(()=>{
DotNetCoreBuild("Uragano.sln",new DotNetCoreBuildSettings{
Configuration=configuration
});
});
Task("CleanPackage").Does(()=>{
if(DirectoryExists(output))
{
DeleteDirectory(output,true);
}
});
Task("Pack")
.IsDependentOn("CleanPackage")
.IsDependentOn("UpdateVersion")
.DoesForEach(GetFiles("**/Uragano.*.csproj"),(file)=>{
DotNetCorePack(file.ToString(),new DotNetCorePackSettings{
OutputDirectory=output,
Configuration=configuration
});
});
Task("Push")
.IsDependentOn("Pack")
.Does(()=>{
var nuGetPushSettings= new NuGetPushSettings {
Source="https://www.nuget.org/api/v2/package",
ApiKey=nugetApiKey
};
if(currentBranch=="master")
{
foreach (var package in GetFiles("Output/*.nupkg"))
{
NuGetPush(package,nuGetPushSettings);
}
}
else
{
Information("Non-master build. Not publishing to NuGet. Current branch: " + currentBranch);
}
});
Task("Default")
.IsDependentOn("Restore")
.IsDependentOn("Build")
.Does(() => {
});
RunTarget(target);