forked from TestStack/TestStack.BDDfy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
85 lines (70 loc) · 2.55 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
#tool "nuget:?package=GitReleaseNotes"
var target = Argument("target", "Default");
var bddfyProj = "./src/TestStack.BDDfy/project.json";
var outputDir = "./artifacts/";
Task("Clean")
.Does(() => {
if (DirectoryExists(outputDir))
{
DeleteDirectory(outputDir, recursive:true);
}
});
Task("Restore")
.Does(() => {
DotNetCoreRestore("src");
});
GitVersion versionInfo = null;
Task("Version")
.Does(() => {
GitVersion(new GitVersionSettings{
UpdateAssemblyInfo = true,
OutputType = GitVersionOutput.BuildServer
});
versionInfo = GitVersion(new GitVersionSettings{ OutputType = GitVersionOutput.Json });
// Update project.json
var updatedProjectJson = System.IO.File.ReadAllText(bddfyProj)
.Replace("1.0.0-*", versionInfo.NuGetVersion);
System.IO.File.WriteAllText(bddfyProj, updatedProjectJson);
});
Task("Build")
.IsDependentOn("Clean")
.IsDependentOn("Version")
.IsDependentOn("Restore")
.Does(() => {
MSBuild("./src/TestStack.BDDfy.sln");
});
Task("Test")
.IsDependentOn("Build")
.Does(() => {
DotNetCoreTest("./src/TestStack.BDDfy.Tests");
DotNetCoreTest("./src/Samples/TestStack.BDDfy.Samples");
});
Task("Package")
.IsDependentOn("Test")
.Does(() => {
var settings = new DotNetCorePackSettings
{
OutputDirectory = outputDir,
NoBuild = true
};
DotNetCorePack(bddfyProj, settings);
var releaseNotesExitCode = StartProcess(
@"tools\GitReleaseNotes\tools\gitreleasenotes.exe",
new ProcessSettings { Arguments = ". /o artifacts/releasenotes.md" });
if (string.IsNullOrEmpty(System.IO.File.ReadAllText("./artifacts/releasenotes.md")))
System.IO.File.WriteAllText("./artifacts/releasenotes.md", "No issues closed since last release");
if (releaseNotesExitCode != 0) throw new Exception("Failed to generate release notes");
System.IO.File.WriteAllLines(outputDir + "artifacts", new[]{
"nuget:TestStack.BDDfy." + versionInfo.NuGetVersion + ".nupkg",
"nugetSymbols:TestStack.BDDfy." + versionInfo.NuGetVersion + ".symbols.nupkg",
"releaseNotes:releasenotes.md"
});
if (AppVeyor.IsRunningOnAppVeyor)
{
foreach (var file in GetFiles(outputDir + "**/*"))
AppVeyor.UploadArtifact(file.FullPath);
}
});
Task("Default")
.IsDependentOn("Package");
RunTarget(target);