This repository has been archived by the owner on Apr 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.cake
137 lines (119 loc) · 4.1 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var projectName = "seek.automation.stub";
var projectDescription = "A library to allow stubbing of services while building integration or pact automated tests.";
var nugetDir = Directory("publish");
var releaseNotes = ParseReleaseNotes("ReleaseNotes.md");
var buildNumber = EnvironmentVariable("BUILD_NUMBER") ?? "0";
var appVeyorBuildNumber = EnvironmentVariable("APPVEYOR_BUILD_NUMBER") ?? "0";
var version = string.Format("{0}.{1}", releaseNotes.Version, appVeyorBuildNumber);
Setup(context =>
{
CopyFileToDirectory("tools/nuget.exe", "tools/cake/");
if(DirectoryExists(nugetDir))
{
DeleteDirectory(nugetDir, recursive:true);
}
CreateDirectory(nugetDir);
NuGetInstall("xunit.runner.console", new NuGetInstallSettings {
ExcludeVersion = true,
OutputDirectory = "./tools"
});
}
);
Teardown(context =>
{
Information("Completed!");
}
);
Task("Clean")
.Does(() =>
{
CleanDirectories(string.Format("{0}/**/bin", projectName));
CleanDirectories(string.Format("{0}/**/obj", projectName));
}
);
Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
NuGetRestore(string.Format("{0}.sln", projectName));
}
);
Task("AssemblyInfo")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
CreateAssemblyInfo(string.Format("{0}/Properties/AssemblyInfo.cs", projectName), new AssemblyInfoSettings
{
Title = projectName,
Description = projectDescription,
Guid = "4dd5b14a-ef02-4ce0-9c33-52a4a4ea05f5",
Product = projectName,
Version = version,
FileVersion = version
});
});
Task("Build-Solution")
.IsDependentOn("AssemblyInfo")
.Does(() =>
{
MSBuild(string.Format("{0}.sln", projectName), new MSBuildSettings()
.UseToolVersion(MSBuildToolVersion.NET46)
.SetVerbosity(Verbosity.Minimal)
.SetConfiguration(configuration)
);
}
);
Task("Run-Unit-Tests")
.IsDependentOn("Build-Solution")
.Does(() =>
{
XUnit2(string.Format("{0}.tests/**/bin/{1}/*.Tests.dll", projectName, configuration));
}
);
Task("Create-Nuget-Package")
.IsDependentOn("Build-Solution")
.Does(() =>
{
var nuGetPackSettings = new NuGetPackSettings {
Id = projectName,
Version = version,
Title = "SEEK Pact Based Stub Library",
Authors = new[] {"Behdad Darougheh"},
Owners = new[] {"SEEK", "Behdad Darougheh"},
Description = projectDescription,
Summary = "Try stubbing the dependent services instead of mocking...you might like it.",
ProjectUrl = new Uri("https://github.com/seek-oss/seek.automation.stub"),
Copyright = "Copyright 2015",
ReleaseNotes = new [] {"Please see below, the notes for the last release:", Environment.NewLine , String.Join(Environment.NewLine, releaseNotes.Notes).ToString()},
Tags = new [] {"StubLib", "PactAutomation", "Integration", "Consumer Driven Contract"},
RequireLicenseAcceptance = false,
Files = new [] {
new NuSpecContent {Source = string.Format("bin/release/{0}.dll", projectName), Target = "lib/net45"},
},
BasePath = string.Format("{0}/", projectName),
OutputDirectory = nugetDir
};
NuGetPack(string.Format("{0}.nuspec", projectName), nuGetPackSettings);
}
);
Task("Publish-Nuget-Package")
.IsDependentOn("Create-Nuget-Package")
.Does(() =>
{
Information("Publishing to Nuget.org...");
var apiKey = EnvironmentVariable("NUGET_ORG_API_KEY");
if(string.IsNullOrEmpty(apiKey)) {
throw new InvalidOperationException("Could not resolve NUGET_ORG_API_KEY API key.");
}
// Push the package
NuGetPush(System.IO.Directory.GetFiles("publish")[0], new NuGetPushSettings {
Source = "https://www.nuget.org/api/v2/package",
ApiKey = apiKey
});
}
);
Task("Default")
.IsDependentOn("Run-Unit-Tests");
RunTarget(target);