-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.cake
More file actions
112 lines (96 loc) · 2.82 KB
/
build.cake
File metadata and controls
112 lines (96 loc) · 2.82 KB
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
103
104
105
106
107
108
109
110
111
112
#load "./scripts/version.cake"
#tool "nuget:?package=xunit.runner.console&version=2.2.0"
var target = Argument<string>("target", "Default");
var config = Argument<string>("configuration", "Release");
var version = new BuildVersion("0.1.0", "local");
var projects = new DirectoryPath[] {
"./src/Dotbot", "./src/Dotbot.Slack"
};
var isRunningOnAppVeyor = BuildSystem.AppVeyor.IsRunningOnAppVeyor;
var isPullRequest = BuildSystem.AppVeyor.Environment.PullRequest.IsPullRequest;
Setup(context =>
{
// Calculate semantic version.
version = GetVersion(context);
// Output some information.
Information("Version: {0}", version.GetSemanticVersion());
Information("Pull Request: {0}", isPullRequest);
});
Task("Clean")
.Does(() =>
{
CleanDirectory("./.artifacts");
});
Task("Restore")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetCoreRestore("./src/Dotbot.sln", new DotNetCoreRestoreSettings
{
Verbose = false,
Sources = new [] { "https://api.nuget.org/v3/index.json" }
});
});
Task("Build")
.IsDependentOn("Clean")
.IsDependentOn("Restore")
.Does(() =>
{
DotNetCoreBuild("./src/Dotbot.sln", new DotNetCoreBuildSettings
{
Configuration = config,
ArgumentCustomization = args => args.Append("/p:Version={0}", version.GetSemanticVersion())
});
});
Task("Run-Tests")
.IsDependentOn("Build")
.Does(() =>
{
DotNetCoreTest("./src/Dotbot.Tests/Dotbot.Tests.csproj");
});
Task("Pack")
.IsDependentOn("Run-Tests")
.Does(() =>
{
foreach(var project in projects)
{
Information("\nPacking {0}...", project.FullPath);
DotNetCorePack(project.FullPath, new DotNetCorePackSettings
{
Configuration = config,
OutputDirectory = "./.artifacts",
VersionSuffix = version.Suffix,
NoBuild = true,
Verbose = false,
ArgumentCustomization = args => args
.Append("/p:Version={0}", version.GetSemanticVersion())
.Append("--include-symbols --include-source")
});
}
});
Task("Publish")
.WithCriteria(isRunningOnAppVeyor && !isPullRequest)
.IsDependentOn("Pack")
.Does(() =>
{
var apiKey = EnvironmentVariable("DOTBOT_NUGET_API_KEY");
if(string.IsNullOrWhiteSpace(apiKey))
{
throw new CakeException("NuGet API key was not provided.");
}
// Get the file paths.
var packageVersion = version.GetSemanticVersion();
var files = GetFiles("./.artifacts/*." + packageVersion + ".nupkg");
foreach(var file in files)
{
NuGetPush(file, new NuGetPushSettings() {
Source = "https://nuget.org/api/v2/package",
ApiKey = apiKey
});
}
});
Task("Default")
.IsDependentOn("Pack");
Task("AppVeyor")
.IsDependentOn("Publish");
RunTarget(target);