-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.cake
97 lines (84 loc) · 2.61 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
var target = Argument("target", "Default");
var package = "DependencyCheck.Runner.Tool";
var apiKey = EnvironmentVariable("NUGET_API_KEY") ?? "abcdef0123456789";
var buildNumber = EnvironmentVariable("APPVEYOR_BUILD_NUMBER") ?? "1";
var version = EnvironmentVariable("APPVEYOR_REPO_TAG_NAME") ?? "3.2.1";
var toolVersion = version;
Setup(context =>
{
if (!DirectoryExists("nuget"))
{
CreateDirectory("nuget");
}
});
Task("Clean")
.Does(() =>
{
CleanDirectory("nuget");
});
Task("Pack")
.Does(() =>
{
var nuGetPackSettings = new NuGetPackSettings
{
Id = package,
Version = version,
Title = package,
Authors = new[] { "Burak İnce" },
Owners = new[] { "Burak İnce", "cake-contrib" },
Description = "Nuget tool package for OWASP Dependency Check",
Summary = "Contains the runner with version " + toolVersion,
ProjectUrl = new Uri("https://github.com/burakince/DependencyCheck.Runner.Tool"),
LicenseUrl = new Uri("https://github.com/burakince/DependencyCheck.Runner.Tool/blob/master/LICENSE"),
RequireLicenseAcceptance = false,
Symbols = false,
NoPackageAnalysis = true,
Files = new []
{
new NuSpecContent
{
Source = string.Format(@"**", package), Target = "tools"
}
},
BasePath = "./runner",
OutputDirectory = "./nuget"
};
NuGetPack(nuGetPackSettings);
});
Task("Update-Appveyor-Build-Version")
.Does(() =>
{
if (AppVeyor.IsRunningOnAppVeyor)
{
AppVeyor.UpdateBuildVersion(version + string.Concat("+", buildNumber));
}
else
{
Information("Not running on AppVeyor");
}
});
Task("Publish")
.Does(() =>
{
if (string.IsNullOrEmpty(apiKey))
{
throw new InvalidOperationException("Could not resolve Nuget API key.");
};
var packagePath = "./nuget/" + package + "." + version + ".nupkg";
Information("Publishing: {0}", packagePath);
NuGetPush(packagePath, new NuGetPushSettings
{
Source = "https://www.nuget.org/api/v2/package",
ApiKey = apiKey
});
});
Task("Build")
.IsDependentOn("Clean")
.IsDependentOn("Pack")
.IsDependentOn("Update-Appveyor-Build-Version");
Task("AppVeyor")
.IsDependentOn("Build")
.IsDependentOn("Publish");
Task("Default")
.IsDependentOn("Build");
RunTarget(target);