forked from shouldly/shouldly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
108 lines (89 loc) · 3.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#tool "nuget:?package=GitReleaseNotes"
#tool nuget:?package=GitVersion.CommandLine
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var shouldlyProj = "./src/Shouldly/Shouldly.csproj";
var outputDir = "./artifacts/";
var isAppVeyor = BuildSystem.IsRunningOnAppVeyor;
var isWindows = IsRunningOnWindows();
Task("Clean")
.Does(() => {
if (DirectoryExists(outputDir))
{
DeleteDirectory(outputDir, recursive:true);
}
});
Task("Restore")
.Does(() => {
DotNetCoreRestore("./src/Shouldly.sln", new DotNetCoreRestoreSettings{
Verbosity = DotNetCoreVerbosity.Minimal,
});
});
GitVersion versionInfo = null;
DotNetCoreMSBuildSettings msBuildSettings = null;
Task("Version")
.Does(() => {
GitVersion(new GitVersionSettings{
UpdateAssemblyInfo = false,
OutputType = GitVersionOutput.BuildServer
});
versionInfo = GitVersion(new GitVersionSettings{ OutputType = GitVersionOutput.Json });
msBuildSettings = new DotNetCoreMSBuildSettings()
.WithProperty("Version", versionInfo.NuGetVersion)
.WithProperty("AssemblyVersion", versionInfo.AssemblySemVer)
.WithProperty("FileVersion", versionInfo.AssemblySemVer);
});
Task("Build")
.IsDependentOn("Clean")
.IsDependentOn("Version")
.IsDependentOn("Restore")
.Does(() => {
DotNetCoreBuild("./src/Shouldly.sln", new DotNetCoreBuildSettings()
{
Configuration = configuration,
MSBuildSettings = msBuildSettings
});
});
Task("Test")
.IsDependentOn("Build")
.Does(() => {
DotNetCoreTool("./src/Shouldly.Tests/Shouldly.Tests.csproj", "xunit", "-configuration Debug");
});
Task("Package")
.IsDependentOn("Test")
.WithCriteria(() => isWindows)
.Does(() => {
DotNetCorePack(shouldlyProj, new DotNetCorePackSettings
{
Configuration = configuration,
OutputDirectory = outputDir,
MSBuildSettings = msBuildSettings
});
// TODO not sure why this isn't working
// GitReleaseNotes("outputDir/releasenotes.md", new GitReleaseNotesSettings {
// WorkingDirectory = ".",
// AllTags = false
// });
var gitReleaseNotesTool = Context.Tools.Resolve("GitReleaseNotes.exe");
var releaseNotesExitCode =
StartProcess(gitReleaseNotesTool,
new ProcessSettings { Arguments = ". /OutputFile artifacts/releasenotes.md", RedirectStandardOutput = true },
out var redirectedOutput);
Information(string.Join("\n", redirectedOutput));
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) Error("Failed to generate release notes");
System.IO.File.WriteAllLines(outputDir + "artifacts", new[]{
"nuget:Shouldly." + versionInfo.NuGetVersion + ".nupkg",
"releaseNotes:releasenotes.md"
});
if (isAppVeyor)
{
Information("Uploading artifacts to AppVeyor.");
foreach (var file in GetFiles(outputDir + "**/*"))
AppVeyor.UploadArtifact(file.FullPath);
}
});
Task("Default")
.IsDependentOn("Package");
RunTarget(target);