forked from krac/NGitLab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
133 lines (113 loc) · 3.68 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
#tool "nuget:?package=NUnit.ConsoleRunner"
#tool "nuget:?package=GitReleaseNotes"
#tool "nuget:?package=GitVersion.CommandLine&prerelease"
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
string version = null;
string nugetVersion = null;
string preReleaseTag = null;
string semVersion = null;
Task("Version")
.Does(() =>
{
GitVersion(new GitVersionSettings
{
UpdateAssemblyInfo = AppVeyor.IsRunningOnAppVeyor,
LogFilePath = "console",
OutputType = GitVersionOutput.BuildServer
});
GitVersion assertedVersions = GitVersion(new GitVersionSettings
{
OutputType = GitVersionOutput.Json
});
Information("New Version:" + assertedVersions.NuGetVersion);
version = assertedVersions.MajorMinorPatch;
nugetVersion = assertedVersions.NuGetVersion;
preReleaseTag = assertedVersions.PreReleaseTag;
semVersion = assertedVersions.LegacySemVerPadded;
});
Task("NuGet-Package-Restore")
.Does(() =>
{
NuGetRestore("./NGitLab/NGitLab.sln");
});
Task("Build")
.IsDependentOn("Version")
.IsDependentOn("NuGet-Package-Restore")
.Does(() =>
{
var msBuildSettings = new MSBuildSettings()
.SetConfiguration(configuration)
.SetPlatformTarget(PlatformTarget.MSIL)
.WithProperty("Windows", "True")
.UseToolVersion(MSBuildToolVersion.VS2015)
.SetVerbosity(Verbosity.Minimal)
.SetNodeReuse(false);
if (BuildSystem.AppVeyor.IsRunningOnAppVeyor)
{
msBuildSettings = msBuildSettings
.WithProperty("GitVersion_NuGetVersion", nugetVersion)
.WithProperty("GitVersion_SemVer", semVersion)
.WithProperty("GitVersion_MajorMinorPatch", version)
.WithProperty("GitVersion_PreReleaseTag", preReleaseTag);
}
MSBuild("./NGitLab/NGitLab.sln", msBuildSettings);
});
Task("Run-NUnit-Tests")
.IsDependentOn("Build")
.Does(() =>
{
var settings = new NUnit3Settings
{
Where = "cat != Server_Required"
};
NUnit3(new [] {
"NGitLab/NGitLab.Tests/bin/" + configuration + "/NGitLab.Tests.dll" },
settings);
if (AppVeyor.IsRunningOnAppVeyor)
{
Information("Uploading test results");
AppVeyor.UploadTestResults("TestResult.xml", AppVeyorTestResultsType.NUnit3);
}
});
Task("Check-Build-Folder-Exists")
.IsDependentOn("Run-NUnit-Tests")
.Does(() =>
{
EnsureDirectoryExists("./build");
});
Task("Create-Release-Notes")
.IsDependentOn("Check-Build-Folder-Exists")
.Does(() =>
{
var releaseNotesExitCode = StartProcess(@"tools\GitReleaseNotes\tools\gitreleasenotes.exe",
new ProcessSettings
{
Arguments = ". /o ./build/releasenotes.md"
});
if (string.IsNullOrEmpty(System.IO.File.ReadAllText("./build/releasenotes.md")))
System.IO.File.WriteAllText("./build/releasenotes.md", "No issues closed since last release");
if (releaseNotesExitCode != 0) throw new Exception("Failed to generate release notes");
});
Task("Create-NuGet-Packages")
.IsDependentOn("Create-Release-Notes")
.Does(() =>
{
NuGetPack("./NGitLab.nuspec", new NuGetPackSettings {
Version = semVersion,
OutputDirectory = "./build",
Symbols = false,
NoPackageAnalysis = true
});
});
Task("Upload-AppVeyor-Artifacts")
.IsDependentOn("Create-NuGet-Packages")
.WithCriteria(() => AppVeyor.IsRunningOnAppVeyor)
.Does(() =>
{
AppVeyor.UploadArtifact("build/releasenotes.md");
AppVeyor.UploadArtifact("build/NGitLab." + nugetVersion +".nupkg");
});
Task("Default")
.IsDependentOn("Upload-AppVeyor-Artifacts");
RunTarget(target);