Skip to content

Commit fce9620

Browse files
committed
Working on build tooling
1 parent 72d1870 commit fce9620

File tree

6 files changed

+149
-3
lines changed

6 files changed

+149
-3
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ bld/
2323
[Bb]in/
2424
[Oo]bj/
2525
[Ll]og/
26-
[Bb]uild/
26+
[Oo]utput/
27+
[Tt]est[Rr]esults/
2728

2829
# Visual Studio 2015 cache/options directory
2930
.vs/

NetlifySharp.sln

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{9D82AABF
99
EndProject
1010
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Files", "Files.shproj", "{C3D497EA-3113-4ED0-8806-94B20FC235DD}"
1111
EndProject
12-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetlifySharp.Generator", "src\NetlifySharp.Generator\NetlifySharp.Generator.csproj", "{0DF66273-6B1F-476E-A9AD-ED83B7494F0F}"
12+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetlifySharp.Generator", "src\NetlifySharp.Generator\NetlifySharp.Generator.csproj", "{0DF66273-6B1F-476E-A9AD-ED83B7494F0F}"
1313
EndProject
14-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetlifySharp", "src\NetlifySharp\NetlifySharp.csproj", "{41AF07B8-6EE0-4D1A-9E23-F42689059B9C}"
14+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetlifySharp", "src\NetlifySharp\NetlifySharp.csproj", "{41AF07B8-6EE0-4D1A-9E23-F42689059B9C}"
15+
EndProject
16+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{F66FF7CA-79C6-495B-A073-C83B22AFFE51}"
17+
EndProject
18+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetlifySharp.Build", "build\NetlifySharp.Build\NetlifySharp.Build.csproj", "{073ADC33-A84E-470B-8220-89F8FCCD1FC1}"
1519
EndProject
1620
Global
1721
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -27,13 +31,18 @@ Global
2731
{41AF07B8-6EE0-4D1A-9E23-F42689059B9C}.Debug|Any CPU.Build.0 = Debug|Any CPU
2832
{41AF07B8-6EE0-4D1A-9E23-F42689059B9C}.Release|Any CPU.ActiveCfg = Release|Any CPU
2933
{41AF07B8-6EE0-4D1A-9E23-F42689059B9C}.Release|Any CPU.Build.0 = Release|Any CPU
34+
{073ADC33-A84E-470B-8220-89F8FCCD1FC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35+
{073ADC33-A84E-470B-8220-89F8FCCD1FC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
36+
{073ADC33-A84E-470B-8220-89F8FCCD1FC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
37+
{073ADC33-A84E-470B-8220-89F8FCCD1FC1}.Release|Any CPU.Build.0 = Release|Any CPU
3038
EndGlobalSection
3139
GlobalSection(SolutionProperties) = preSolution
3240
HideSolutionNode = FALSE
3341
EndGlobalSection
3442
GlobalSection(NestedProjects) = preSolution
3543
{0DF66273-6B1F-476E-A9AD-ED83B7494F0F} = {1D456B5E-2874-446C-8CFD-5134FC11ACAF}
3644
{41AF07B8-6EE0-4D1A-9E23-F42689059B9C} = {1D456B5E-2874-446C-8CFD-5134FC11ACAF}
45+
{073ADC33-A84E-470B-8220-89F8FCCD1FC1} = {F66FF7CA-79C6-495B-A073-C83B22AFFE51}
3746
EndGlobalSection
3847
GlobalSection(ExtensibilityGlobals) = postSolution
3948
SolutionGuid = {17A4CA1C-8EEE-4D62-A5F2-06B88FEF22CB}

ReleaseNotes.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 1.1.0
2+
3+
- Added a `NetlifyClient` constructor that does not require an `HttpClient`.
4+
- Added client methods to all model types as appropriate.
5+
16
# 1.0.0
27

38
- Complete rewrite using NSwag to generate entire Open API specification.

build.cmd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@echo off
2+
cd "build\NetlifySharp.Build"
3+
dotnet run -- %*
4+
set exitcode=%errorlevel%
5+
cd %~dp0
6+
exit /b %exitcode%
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp3.0</TargetFramework>
6+
<DefaultItemExcludes>$(DefaultItemExcludes);output\**;temp\**;reportgenerator.exe;nuget.exe</DefaultItemExcludes>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Statiq.App" Version="1.0.0-alpha.18" />
11+
</ItemGroup>
12+
</Project>
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Statiq.App;
7+
using Statiq.Common;
8+
using Statiq.Core;
9+
10+
namespace NetlifySharp.Build
11+
{
12+
public class Program
13+
{
14+
// Pipeline names
15+
public const string Build = nameof(Build);
16+
public const string Test = nameof(Test);
17+
public const string Docs = nameof(Docs);
18+
public const string Pack = nameof(Pack);
19+
public const string Publish = nameof(Publish);
20+
21+
public static async Task<int> Main(string[] args) => await Bootstrapper
22+
.CreateDefault(args, DefaultsToAdd.All & ~DefaultsToAdd.Commands)
23+
24+
// Configure build settings for the correct version
25+
.ConfigureSettings(x =>
26+
{
27+
string version = File.ReadAllLines("../../ReleaseNotes.md")[0].TrimStart('#').Trim();
28+
if (x.ContainsKey("BUILD_BUILDNUMBER"))
29+
{
30+
version += "-build-" + x["BUILD_BUILDNUMBER"];
31+
}
32+
x["BuildVersion"] = version;
33+
x["BuildProperties"] = $"-p:Version={version} -p:AssemblyVersion={version} -p:FileVersion={version}";
34+
})
35+
36+
// Add build commands to the CLI
37+
.AddBuildCommand("build", "Builds all projects.", nameof(Build))
38+
.AddBuildCommand("test", "Builds and tests all projects.", nameof(Test))
39+
.AddBuildCommand("docs", "Previews the documentation.", nameof(Docs))
40+
.AddBuildCommand("pack", "Packs the packages.", nameof(Pack))
41+
.AddBuildCommand("publish", "Publishes the packages and documentation site.", nameof(Publish))
42+
43+
// Add pipelines
44+
.BuildPipeline(Build, pipeline => pipeline
45+
.ManuallyExecute()
46+
.WithProcessModules(
47+
new ReadFiles("../../../src/*/*.csproj"),
48+
new StartProcess(
49+
"dotnet",
50+
Config.FromDocument((doc, ctx) => $"build \"{doc.Source.FullPath}\" {ctx.Settings.GetString("BuildProperties")}"))
51+
.WithSequentialExecution()
52+
.LogOutput()))
53+
54+
.BuildPipeline(Test, pipeline => pipeline
55+
.ManuallyExecute()
56+
.WithDependencies(Build)
57+
.WithProcessModules(
58+
new ReadFiles("../../../tests/*/*.csproj"),
59+
new StartProcess(
60+
"dotnet",
61+
Config.FromDocument((doc, ctx) =>
62+
{
63+
StringBuilder builder = new StringBuilder($"test --no-build --no-restore \"{doc.Source.FullPath}\" {ctx.Settings.GetString("BuildProperties")} /p:CollectCoverage=true");
64+
if (ctx.Settings.ContainsKey("BUILD_BUILDNUMBER"))
65+
{
66+
// We're in Azure Pipelines so add the test logger
67+
builder.Append(" --test-adapter-path:. --logger:AzurePipelines");
68+
}
69+
return builder.ToString();
70+
}))
71+
.WithSequentialExecution()
72+
.LogOutput()))
73+
74+
.BuildPipeline(Pack, pipeline => pipeline
75+
.ManuallyExecute()
76+
.WithDependencies(Test)
77+
.WithProcessModules(
78+
new StartProcess(
79+
"dotnet",
80+
Config.FromContext(ctx => $"pack ../../src/NetlifySharp/NetlifySharp.csproj --no-build --no-restore -o \"{ctx.FileSystem.GetOutputDirectory("packages").Path}\" {ctx.Settings.GetString("BuildProperties")}"))
81+
.LogOutput(),
82+
new ReadFiles(Config.FromContext(ctx => $"{ctx.FileSystem.GetOutputDirectory("packages").Path}/*.nupkg")),
83+
new ExecuteIf(Config.FromContext(ctx => ctx.Settings.ContainsKey("DAVIDGLICK_CERTPASS") && ctx.FileSystem.GetRootFile("../../digicert-davidglick.pfx").Exists))
84+
{
85+
new StartProcess(
86+
"nuget",
87+
Config.FromDocument((doc, ctx) =>
88+
{
89+
string certPath = ctx.FileSystem.GetRootFile("../../digicert-davidglick.pfx").Path.FullPath;
90+
string password = ctx.Settings.GetString("DAVIDGLICK_CERTPASS");
91+
return $"sign \"{doc.Source.FullPath}\" -CertificatePath \"{certPath}\" -CertificatePassword \"{password}\" -Timestamper \"http://timestamp.digicert.com\" -NonInteractive";
92+
}))
93+
.LogOutput()
94+
}))
95+
96+
// TODO: Generate zip
97+
// TODO: Generate GitHub release
98+
// TODO: Run docs generator with deployment
99+
.BuildPipeline(Publish, pipeline => pipeline
100+
.ManuallyExecute()
101+
.WithDependencies(Pack)
102+
.WithProcessModules(
103+
new ReadFiles(Config.FromContext(ctx => $"{ctx.FileSystem.GetOutputDirectory("packages").Path}/*.nupkg")),
104+
new StartProcess(
105+
"dotnet",
106+
Config.FromDocument((doc, ctx) => $"nuget push --api-key {ctx.Settings.GetString("NUGET_KEY")} --source \"https://api.nuget.org/v3/index.json\" \"{doc.Source.FullPath}\" "))
107+
.WithSequentialExecution()
108+
.LogOutput()))
109+
110+
// Run the app
111+
.RunAsync();
112+
}
113+
}

0 commit comments

Comments
 (0)