forked from red-gate/ngit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
86 lines (73 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
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
// Repository-specific variables for build tasks
var solution = "./ngit.sln";
var buildNumber = EnvironmentVariable("build_number") ?? "0.0.5";
var artifactsDir = "./artifacts";
var projectToPublish = "./NGit/NGit.csproj";
var feedzKey = EnvironmentVariable("NUGET_FEEDZ_API_KEY");
// Shared build tasks that hopefully should be copy-pastable
Information($"Running on TeamCity: {TeamCity.IsRunningOnTeamCity}");
Information($"Building: {buildNumber}");
Task("Clean")
.Does(() =>
{
CleanDirectory(artifactsDir);
});
Task("Restore")
.IsDependentOn("Clean")
.Does(() => {
DotNetCoreRestore();
});
Task("Test")
.IsDependentOn("Build")
.Does(() => {
// DotNetCoreTest(solution);
});
Task("Build")
.IsDependentOn("Restore")
.Does(() => {
DotNetCoreBuild(solution, new DotNetCoreBuildSettings
{
NoIncremental = true,
Configuration = configuration,
ArgumentCustomization = args => args.Append($"/p:Version={buildNumber}")
});
});
Task("Publish")
.IsDependentOn("Test")
.Does(() => {
DotNetCorePublish(projectToPublish, new DotNetCorePublishSettings
{
Configuration = configuration,
OutputDirectory = artifactsDir
});
});
Task("Pack-NuGet")
.IsDependentOn("Publish")
.Does(() => {
NuGetPack("./NGit.nuspec", new NuGetPackSettings {
OutputDirectory = artifactsDir,
Verbosity = NuGetVerbosity.Detailed,
Properties = {
{"version", buildNumber},
{"csharpcodeVersionFromPackagesConfig", "1.2.0"}
}
});
});
Task("Push-NuGet")
.IsDependentOn("Pack-NuGet")
.Does(() => {
if (!String.IsNullOrEmpty (feedzKey)) {
Information("Have a feedz key so pushing package");
DotNetCoreNuGetPush($"./{artifactsDir}/Gearset.NGit.{buildNumber}.nupkg", new DotNetCoreNuGetPushSettings {
Source = "https://f.feedz.io/gearsethq/gearset-ngit/nuget",
ApiKey = feedzKey
});
} else {
Information("No Feedz key so skipping package push");
}
});
Task("Default")
.IsDependentOn("Push-NuGet");
RunTarget(target);