/
Build.cs
53 lines (43 loc) · 1.83 KB
/
Build.cs
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
return BuildRunner.Execute(args, build =>
{
var codegen = "fsdgenfsd";
var gitLogin = new GitLoginInfo("FacilityApiBot", Environment.GetEnvironmentVariable("BUILD_BOT_PASSWORD") ?? "");
var dotNetBuildSettings = new DotNetBuildSettings
{
NuGetApiKey = Environment.GetEnvironmentVariable("NUGET_API_KEY"),
DocsSettings = new DotNetDocsSettings
{
GitLogin = gitLogin,
GitAuthor = new GitAuthorInfo("FacilityApiBot", "facilityapi@gmail.com"),
SourceCodeUrl = "https://github.com/FacilityApi/Facility/tree/master/src",
ProjectHasDocs = name => !name.StartsWith("fsdgen", StringComparison.Ordinal),
},
PackageSettings = new DotNetPackageSettings
{
GitLogin = gitLogin,
PushTagOnPublish = x => $"nuget.{x.Version}",
},
};
build.AddDotNetTargets(dotNetBuildSettings);
build.Target("codegen")
.DependsOn("build")
.Describe("Generates code from the FSD")
.Does(() => CodeGen(verify: false));
build.Target("verify-codegen")
.DependsOn("build")
.Describe("Ensures the generated code is up-to-date")
.Does(() => CodeGen(verify: true));
build.Target("test")
.DependsOn("verify-codegen");
void CodeGen(bool verify)
{
var configuration = dotNetBuildSettings.GetConfiguration();
var verifyOption = verify ? "--verify" : null;
RunCodeGen("example/ExampleApi.fsd", "example/output", verifyOption);
RunCodeGen("example/ExampleApi.fsd.md", "example/output", "--verify");
RunCodeGen("example/ExampleApi.fsd", "example/output/ExampleApi-nowidgets.fsd", "--excludeTag", "widgets", verifyOption);
RunCodeGen("example/ExampleApi.fsd.md", "example/output/ExampleApi-nowidgets.fsd", "--excludeTag", "widgets", "--verify");
void RunCodeGen(params string?[] args) =>
RunDotNet(new[] { "run", "--no-build", "--project", $"src/{codegen}", "-f", "net6.0", "-c", configuration, "--", "--newline", "lf" }.Concat(args));
}
});