-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
57 lines (48 loc) · 1.52 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
var target = Argument("target", "Pack");
var project = "dotnet-pr";
var version = GetBuildVersion("2.0.0");
var outputDir = $"./builds/{project}";
Task("Test")
.Does(() => {
var settings = new DotNetCoreTestSettings
{
Configuration = "Release",
ArgumentCustomization = args=>args.Append($"--logger console;verbosity=detailed")
};
DotNetCoreTest("./source/dotnet-pr.tests/dotnet-pr.tests.csproj", settings);
});
Task("Pack")
.IsDependentOn("Test")
.Does(() => {
var publishSettings = new DotNetCorePackSettings{
OutputDirectory = outputDir,
Configuration = "Release"
};
publishSettings.MSBuildSettings = new DotNetCoreMSBuildSettings()
.WithProperty("Version", new[] { version });
DotNetCorePack($"./source/{project}/{project}.csproj", publishSettings);
});
Task("Publish")
.IsDependentOn("Pack")
.Does(() => {
var settings = new DotNetCoreNuGetPushSettings
{
Source = "https://api.nuget.org/v3/index.json",
ApiKey = EnvironmentVariable("NUGET_API_KEY")
};
DotNetCoreNuGetPush($"{outputDir}/{project}.{version}.nupkg", settings);
});
private string GetBuildVersion(string productVersion)
{
var now = DateTime.Now.ToString("yyyyMMddHHmmss");
var shipit = Argument("shipit", "0") != "0";
if(shipit)
{
return $"{productVersion}";
}
else
{
return $"{productVersion}-beta{now}";
}
}
RunTarget(target);