Skip to content

Commit c0ea9d9

Browse files
committed
Dogfood in build and generate release notes
1 parent aaf37c5 commit c0ea9d9

File tree

2 files changed

+161
-151
lines changed

2 files changed

+161
-151
lines changed

build.cake

Lines changed: 68 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#tool "nuget:?package=GitVersion.CommandLine"
21
#tool "nuget:?package=NUnit.ConsoleRunner"
2+
#tool "nuget:?package=GitReleaseNotes"
33

44
var target = Argument("target", "Default");
55
var configuration = Argument("configuration", "Release");
@@ -15,26 +15,60 @@ bool IsTagged = (BuildSystem.AppVeyor.Environment.Repository.Tag.IsTag &&
1515
bool IsMainGitVersionRepo = StringComparer.OrdinalIgnoreCase.Equals("gittools/gitversion", BuildSystem.AppVeyor.Environment.Repository.Name);
1616
bool IsPullRequest = BuildSystem.AppVeyor.Environment.PullRequest.IsPullRequest;
1717

18-
Setup(context =>
18+
void Build()
19+
{
20+
if(IsRunningOnUnix())
21+
{
22+
XBuild("./src/GitVersion.sln", new XBuildSettings()
23+
.SetConfiguration(configuration)
24+
.WithProperty("POSIX", "True")
25+
.SetVerbosity(Verbosity.Verbose)
26+
);
27+
}
28+
else
29+
{
30+
MSBuild("./src/GitVersion.sln", new MSBuildSettings()
31+
.SetConfiguration(configuration)
32+
.SetPlatformTarget(PlatformTarget.MSIL)
33+
.WithProperty("Windows", "True")
34+
.UseToolVersion(MSBuildToolVersion.VS2015)
35+
.SetVerbosity(Verbosity.Minimal)
36+
.SetNodeReuse(false));
37+
}
38+
}
39+
40+
Task("DogfoodBuild")
41+
.IsDependentOn("NuGet-Package-Restore")
42+
.Does(() =>
43+
{
44+
Build();
45+
});
46+
47+
Task("Version")
48+
.IsDependentOn("DogfoodBuild")
49+
.Does(() =>
1950
{
2051
if(!BuildSystem.IsLocalBuild)
2152
{
22-
GitVersion(new GitVersionSettings{
53+
GitVersion(new GitVersionSettings
54+
{
2355
UpdateAssemblyInfo = true,
2456
LogFilePath = "console",
25-
OutputType = GitVersionOutput.BuildServer
57+
OutputType = GitVersionOutput.BuildServer,
58+
ToolPath = @"src\GitVersionExe\bin\Release\GitVersion.exe"
2659
});
2760

28-
version = context.EnvironmentVariable("GitVersion_MajorMinorPatch");
29-
nugetVersion = context.EnvironmentVariable("GitVersion_NuGetVersion");
30-
preReleaseTag = context.EnvironmentVariable("GitVersion_PreReleaseTag");
31-
semVersion = context.EnvironmentVariable("GitVersion_LegacySemVerPadded");
61+
version = EnvironmentVariable("GitVersion_MajorMinorPatch");
62+
nugetVersion = EnvironmentVariable("GitVersion_NuGetVersion");
63+
preReleaseTag = EnvironmentVariable("GitVersion_PreReleaseTag");
64+
semVersion = EnvironmentVariable("GitVersion_LegacySemVerPadded");
3265
milestone = string.Concat("v", version);
3366
}
3467

3568
GitVersion assertedVersions = GitVersion(new GitVersionSettings
3669
{
37-
OutputType = GitVersionOutput.Json
70+
OutputType = GitVersionOutput.Json,
71+
ToolPath = @"src\GitVersionExe\bin\Release\GitVersion.exe"
3872
});
3973

4074
version = assertedVersions.MajorMinorPatch;
@@ -51,27 +85,11 @@ Task("NuGet-Package-Restore")
5185
});
5286

5387
Task("Build")
88+
.IsDependentOn("Version")
5489
.IsDependentOn("NuGet-Package-Restore")
5590
.Does(() =>
5691
{
57-
if(IsRunningOnUnix())
58-
{
59-
XBuild("./Source/Gep13.Cake.Sample.WebApplication.sln", new XBuildSettings()
60-
.SetConfiguration(configuration)
61-
.WithProperty("POSIX", "True")
62-
.SetVerbosity(Verbosity.Verbose)
63-
);
64-
}
65-
else
66-
{
67-
MSBuild("./src/GitVersion.sln", new MSBuildSettings()
68-
.SetConfiguration(configuration)
69-
.SetPlatformTarget(PlatformTarget.MSIL)
70-
.WithProperty("Windows", "True")
71-
.UseToolVersion(MSBuildToolVersion.VS2015)
72-
.SetVerbosity(Verbosity.Minimal)
73-
.SetNodeReuse(false));
74-
}
92+
Build();
7593
});
7694

7795
Task("Run-NUnit-Tests")
@@ -85,150 +103,48 @@ Task("Zip-Files")
85103
.IsDependentOn("Run-NUnit-Tests")
86104
.Does(() =>
87105
{
88-
var files = GetFiles("./build/NuGetCommandLineBuild/Tools/*.*");
89-
90-
Zip("./", "GitVersion_" + nugetVersion + ".zip", files);
91-
92-
files = GetFiles("./build/GitVersionTfsTaskBuild/GitVersionTask/*.*");
93-
94-
Zip("./", "GitVersionTfsBuildTask_" + nugetVersion + ".zip", files);
95-
});
96-
97-
Task("Create-NuGet-Packages")
98-
.Does(() =>
99-
{
100-
101-
});
102-
103-
Task("Create-Chocolatey-Packages")
104-
.Does(() =>
105-
{
106-
106+
Zip("./build/NuGetCommandLineBuild/Tools/", "GitVersion_" + nugetVersion + ".zip");
107107
});
108108

109109
Task("Create-Release-Notes")
110110
.Does(() =>
111111
{
112-
//GitReleaseManagerCreate(parameters.GitHub.UserName, parameters.GitHub.Password, "cake-build", "cake", new GitReleaseManagerCreateSettings {
113-
// Milestone = parameters.Version.Milestone,
114-
// Name = parameters.Version.Milestone,
115-
// Prerelease = true,
116-
// TargetCommitish = "main"
117-
//});
112+
var releaseNotesExitCode = StartProcess(
113+
@"tools\GitReleaseNotes\tools\gitreleasenotes.exe",
114+
new ProcessSettings { Arguments = ". /o artifacts/releasenotes.md" });
115+
if (string.IsNullOrEmpty(System.IO.File.ReadAllText("./artifacts/releasenotes.md")))
116+
System.IO.File.WriteAllText("./build/releasenotes.md", "No issues closed since last release");
117+
118+
if (releaseNotesExitCode != 0) throw new Exception("Failed to generate release notes");
118119
});
119120

120121
Task("Package")
121-
.IsDependentOn("Zip-Files")
122-
.IsDependentOn("Create-NuGet-Packages")
123-
.IsDependentOn("Create-Chocolatey-Packages");
122+
.IsDependentOn("Zip-Files");
124123

125124
Task("Upload-AppVeyor-Artifacts")
126125
.IsDependentOn("Package")
127126
.WithCriteria(() => BuildSystem.AppVeyor.IsRunningOnAppVeyor)
128127
.Does(() =>
129128
{
129+
System.IO.File.WriteAllLines(outputDir + "artifacts", new[]{
130+
"NuGetExeBuild:GitVersion.Portable." + nugetVersion +".nupkg",
131+
"NuGetCommandLineBuild:GitVersion.CommandLine." + nugetVersion +".nupkg",
132+
"NuGetRefBuild:GitVersion." + nugetVersion +".nupkg",
133+
"NuGetTaskBuild:GitVersionTask." + nugetVersion +".nupkg",
134+
"NuGetExeBuild:GitVersion.Portable." + nugetVersion +".nupkg",
135+
"zip:GitVersion_" + nugetVersion + ".zip",
136+
"releaseNotes:releasenotes.md"
137+
});
138+
130139
AppVeyor.UploadArtifact("build/NuGetExeBuild/GitVersion.Portable." + nugetVersion +".nupkg");
131140
AppVeyor.UploadArtifact("build/NuGetCommandLineBuild/GitVersion.CommandLine." + nugetVersion +".nupkg");
132141
AppVeyor.UploadArtifact("build/NuGetRefBuild/GitVersion." + nugetVersion +".nupkg");
133142
AppVeyor.UploadArtifact("build/NuGetTaskBuild/GitVersionTask." + nugetVersion +".nupkg");
134143
AppVeyor.UploadArtifact("build/GitVersionTfsTaskBuild/gittools.gitversion-" + semVersion + ".vsix");
135-
AppVeyor.UploadArtifact("GitVersion_" + nugetVersion + ".zip");
136-
AppVeyor.UploadArtifact("GitVersionTfsBuildTask_" + nugetVersion + ".zip");
137-
});
138-
139-
Task("Publish-MyGet")
140-
.IsDependentOn("Package")
141-
.WithCriteria(() => !BuildSystem.IsLocalBuild)
142-
.WithCriteria(() => !IsPullRequest)
143-
.WithCriteria(() => IsMainGitVersionRepo)
144-
.Does(() =>
145-
{
146-
147-
})
148-
.OnError(exception =>
149-
{
150-
Information("Publish-MyGet Task failed, but continuing with next Task...");
151-
publishingError = true;
152-
});
153-
154-
Task("Publish-NuGet")
155-
.IsDependentOn("Package")
156-
.WithCriteria(() => !BuildSystem.IsLocalBuild)
157-
.WithCriteria(() => !IsPullRequest)
158-
.WithCriteria(() => IsMainGitVersionRepo)
159-
.WithCriteria(() => IsTagged)
160-
.Does(() =>
161-
{
162-
163-
})
164-
.OnError(exception =>
165-
{
166-
Information("Publish-NuGet Task failed, but continuing with next Task...");
167-
publishingError = true;
168-
});
169-
170-
Task("Publish-Chocolatey")
171-
.IsDependentOn("Package")
172-
.WithCriteria(() => !BuildSystem.IsLocalBuild)
173-
.WithCriteria(() => !IsPullRequest)
174-
.WithCriteria(() => IsMainGitVersionRepo)
175-
.WithCriteria(() => IsTagged)
176-
.Does(() =>
177-
{
178-
179-
})
180-
.OnError(exception =>
181-
{
182-
Information("Publish-Chocolatey Task failed, but continuing with next Task...");
183-
publishingError = true;
184-
});
185-
186-
Task("Publish-Gem")
187-
.IsDependentOn("Package")
188-
.WithCriteria(() => !BuildSystem.IsLocalBuild)
189-
.WithCriteria(() => !IsPullRequest)
190-
.WithCriteria(() => IsMainGitVersionRepo)
191-
.WithCriteria(() => IsTagged)
192-
.Does(() =>
193-
{
194-
195-
})
196-
.OnError(exception =>
197-
{
198-
Information("Publish-Gem Task failed, but continuing with next Task...");
199-
publishingError = true;
200-
});
201-
202-
Task("Publish-GitHub-Release")
203-
.IsDependentOn("Package")
204-
.WithCriteria(() => !BuildSystem.IsLocalBuild)
205-
.WithCriteria(() => !IsPullRequest)
206-
.WithCriteria(() => IsMainGitVersionRepo)
207-
.WithCriteria(() => IsTagged)
208-
.Does(() =>
209-
{
210-
211-
})
212-
.OnError(exception =>
213-
{
214-
Information("Publish-GitHub-Release Task failed, but continuing with next Task...");
215-
publishingError = true;
144+
AppVeyor.UploadArtifact("build/GitVersion_" + nugetVersion + ".zip");
145+
AppVeyor.UploadArtifact("build/GitVersionTfsBuildTask_" + nugetVersion + ".zip");
216146
});
217147

218-
Task("AppVeyor")
219-
.IsDependentOn("Upload-AppVeyor-Artifacts")
220-
.IsDependentOn("Publish-MyGet")
221-
.IsDependentOn("Publish-NuGet")
222-
.IsDependentOn("Publish-Chocolatey")
223-
.IsDependentOn("Publish-Gem")
224-
.IsDependentOn("Publish-GitHub-Release")
225-
.Finally(() =>
226-
{
227-
if(publishingError)
228-
{
229-
throw new Exception("An error occurred during the publishing of Cake. All publishing tasks have been attempted.");
230-
}
231-
});
232148

233149
Task("Travis")
234150
.IsDependentOn("Run-NUnit-Tests");
@@ -237,6 +153,7 @@ Task("ReleaseNotes")
237153
.IsDependentOn("Create-Release-Notes");
238154

239155
Task("Default")
240-
.IsDependentOn("Package");
156+
.IsDependentOn("Package")
157+
.IsDependentOn("Upload-AppVeyor-Artifacts");
241158

242159
RunTarget(target);

deploy.cake

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
2+
Task("Publish-MyGet")
3+
.IsDependentOn("Package")
4+
.WithCriteria(() => !BuildSystem.IsLocalBuild)
5+
.WithCriteria(() => !IsPullRequest)
6+
.WithCriteria(() => IsMainGitVersionRepo)
7+
.Does(() =>
8+
{
9+
10+
})
11+
.OnError(exception =>
12+
{
13+
Information("Publish-MyGet Task failed, but continuing with next Task...");
14+
publishingError = true;
15+
});
16+
17+
Task("Publish-NuGet")
18+
.IsDependentOn("Package")
19+
.WithCriteria(() => !BuildSystem.IsLocalBuild)
20+
.WithCriteria(() => !IsPullRequest)
21+
.WithCriteria(() => IsMainGitVersionRepo)
22+
.WithCriteria(() => IsTagged)
23+
.Does(() =>
24+
{
25+
26+
})
27+
.OnError(exception =>
28+
{
29+
Information("Publish-NuGet Task failed, but continuing with next Task...");
30+
publishingError = true;
31+
});
32+
33+
Task("Publish-Chocolatey")
34+
.IsDependentOn("Package")
35+
.WithCriteria(() => !BuildSystem.IsLocalBuild)
36+
.WithCriteria(() => !IsPullRequest)
37+
.WithCriteria(() => IsMainGitVersionRepo)
38+
.WithCriteria(() => IsTagged)
39+
.Does(() =>
40+
{
41+
42+
})
43+
.OnError(exception =>
44+
{
45+
Information("Publish-Chocolatey Task failed, but continuing with next Task...");
46+
publishingError = true;
47+
});
48+
49+
Task("Publish-Gem")
50+
.IsDependentOn("Package")
51+
.WithCriteria(() => !BuildSystem.IsLocalBuild)
52+
.WithCriteria(() => !IsPullRequest)
53+
.WithCriteria(() => IsMainGitVersionRepo)
54+
.WithCriteria(() => IsTagged)
55+
.Does(() =>
56+
{
57+
58+
})
59+
.OnError(exception =>
60+
{
61+
Information("Publish-Gem Task failed, but continuing with next Task...");
62+
publishingError = true;
63+
});
64+
65+
Task("Publish-GitHub-Release")
66+
.IsDependentOn("Package")
67+
.WithCriteria(() => !BuildSystem.IsLocalBuild)
68+
.WithCriteria(() => !IsPullRequest)
69+
.WithCriteria(() => IsMainGitVersionRepo)
70+
.WithCriteria(() => IsTagged)
71+
.Does(() =>
72+
{
73+
74+
})
75+
.OnError(exception =>
76+
{
77+
Information("Publish-GitHub-Release Task failed, but continuing with next Task...");
78+
publishingError = true;
79+
});
80+
81+
Task("Deploy")
82+
.IsDependentOn("Publish-MyGet")
83+
.IsDependentOn("Publish-NuGet")
84+
.IsDependentOn("Publish-Chocolatey")
85+
.IsDependentOn("Publish-Gem")
86+
.IsDependentOn("Publish-GitHub-Release")
87+
.Finally(() =>
88+
{
89+
if(publishingError)
90+
{
91+
throw new Exception("An error occurred during the publishing of Cake. All publishing tasks have been attempted.");
92+
}
93+
});

0 commit comments

Comments
 (0)