-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
98 lines (78 loc) · 2.49 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
#tool "nuget:?package=GitVersion.CommandLine"
using System.Text.RegularExpressions;
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var pushPackages = Argument("PushPackages", "false") == "true";
bool isPrerelease = false;
GitVersion versionInfo = null;
var artifactDirectory = "./artifacts";
var nuspecFile = "/Cofoundry.Templates.nuspec";
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
CleanDirectory(artifactDirectory);
});
Task("Get-Version")
.IsDependentOn("Clean")
.Does(() =>
{
versionInfo = GitVersion(new GitVersionSettings{
UpdateAssemblyInfo = false
});
Information("Building version {0} of Cofoundry Templates.", versionInfo.InformationalVersion);
isPrerelease = versionInfo.PreReleaseNumber.HasValue;
});
Task("Copy")
.IsDependentOn("Get-Version")
.Does(() =>
{
CopyFile("./src" + nuspecFile, artifactDirectory + nuspecFile);
});
Task("Pack")
.IsDependentOn("Copy")
.Does(() =>
{
var settings = new NuGetPackSettings
{
OutputDirectory = "./artifacts/",
Version = versionInfo.NuGetVersion
};
NuGetPack(artifactDirectory + nuspecFile, settings);
});
Task("PushNuGetPackage")
.IsDependentOn("Pack")
.Does(() =>
{
var nugets = GetFiles(artifactDirectory + "/*.nupkg");
if (pushPackages)
{
Information("Pushing packages");
if (isPrerelease)
{
NuGetPush(nugets, new NuGetPushSettings {
Source = "https://www.myget.org/F/cofoundry/api/v2/package",
ApiKey = EnvironmentVariable("MYGET_API_KEY")
});
}
else
{
NuGetPush(nugets, new NuGetPushSettings {
Source = "https://nuget.org/",
ApiKey = EnvironmentVariable("NUGET_API_KEY")
});
}
}
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default").IsDependentOn("PushNuGetPackage");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);