Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit 3873a23

Browse files
just use simpleexec to build the docs
1 parent 7a1f3da commit 3873a23

File tree

3 files changed

+55
-39
lines changed

3 files changed

+55
-39
lines changed

Dockerfile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ARG TRAVIS_PULL_REQUEST
66
ARG TRAVIS_BRANCH
77
ARG MYGET_API_KEY
88

9-
RUN apk add nodejs --no-cache git
9+
RUN apk add nodejs yarn --no-cache
1010

1111
WORKDIR /src
1212

@@ -20,6 +20,10 @@ RUN dotnet restore --runtime=alpine.3.7-x64
2020

2121
COPY ./src .
2222

23+
WORKDIR /docs
24+
25+
COPY ./docs/package.json ./docs/yarn.lock ./
26+
2327
WORKDIR /build
2428

2529
COPY ./build/build.csproj .
@@ -28,12 +32,6 @@ RUN dotnet restore
2832

2933
COPY ./build .
3034

31-
WORKDIR /docs
32-
33-
COPY ./docs/* ./
34-
35-
RUN dotnet restore
36-
3735
WORKDIR /
3836

3937
RUN TRAVIS_BUILD_NUMBER=$TRAVIS_BUILD_NUMBER \

build/Program.cs

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using System;
22
using System.IO;
3+
using System.Linq;
4+
using System.Runtime.InteropServices;
5+
using System.Threading.Tasks;
36
using static Bullseye.Targets;
47
using static SimpleExec.Command;
58

@@ -29,16 +32,45 @@ public static void Main(string[] args)
2932
Directory.Delete(ArtifactsDir, true);
3033
}
3134
});
32-
35+
3336
Target(
3437
GenerateDocumentation,
35-
() => Run("dotnet", "build docs/docs.csproj --verbosity normal"));
38+
() =>
39+
{
40+
var srcDirectory = new DirectoryInfo("./src");
41+
42+
var schemaFiles = srcDirectory.GetFiles("*.schema.json", SearchOption.AllDirectories);
43+
44+
var schemaDirectories = schemaFiles
45+
.Select(schemaFile => schemaFile.DirectoryName)
46+
.Distinct()
47+
.Select(schemaDirectory =>
48+
schemaDirectory.Replace(Path.DirectorySeparatorChar,
49+
'/')); // normalize paths; yarn/node can handle forward slashes
50+
51+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
52+
{
53+
Run("cmd", "/c yarn", "docs");
54+
}
55+
else
56+
{
57+
Run("yarn", string.Empty, "docs");
58+
}
59+
60+
foreach (var schemaDirectory in schemaDirectories)
61+
{
62+
Run(
63+
"node",
64+
$"node_modules/@adobe/jsonschema2md/cli.js -n --input {schemaDirectory} --out {schemaDirectory} --schema-out=-",
65+
"docs");
66+
}
67+
});
3668

3769
Target(
38-
Build,
70+
Build,
3971
DependsOn(GenerateDocumentation),
4072
() => Run(
41-
"dotnet",
73+
"dotnet",
4274
$"build src/SqlStreamStore.HAL.sln -c Release /p:BuildMetadata={buildMetadata}"));
4375

4476
Target(
@@ -50,24 +82,25 @@ public static void Main(string[] args)
5082

5183
Target(
5284
Pack,
53-
DependsOn(Build),
85+
DependsOn(Build),
5486
() => Run(
5587
"dotnet",
5688
$"pack src/SqlStreamStore.HAL -c Release -o ../../{ArtifactsDir} --no-build"));
5789

5890
Target(
59-
Publish,
60-
DependsOn(Pack),
61-
() => {
91+
Publish,
92+
DependsOn(Pack),
93+
() =>
94+
{
6295
var packagesToPush = Directory.GetFiles(ArtifactsDir, "*.nupkg", SearchOption.TopDirectoryOnly);
6396
Console.WriteLine($"Found packages to publish: {string.Join("; ", packagesToPush)}");
64-
97+
6598
if (string.IsNullOrWhiteSpace(apiKey))
6699
{
67100
Console.WriteLine("MyGet API key not available. Packages will not be pushed.");
68101
return;
69102
}
70-
103+
71104
foreach (var packageToPush in packagesToPush)
72105
{
73106
Run(
@@ -83,15 +116,15 @@ public static void Main(string[] args)
83116

84117
private static string GetBranch()
85118
=> (Environment.GetEnvironmentVariable("TRAVIS_PULL_REQUEST")?.ToLower() == "false"
86-
? null
87-
: $"pr-{Environment.GetEnvironmentVariable("TRAVIS_PULL_REQUEST")}")
88-
?? Environment.GetEnvironmentVariable("TRAVIS_BRANCH")
89-
?? "none";
119+
? null
120+
: $"pr-{Environment.GetEnvironmentVariable("TRAVIS_PULL_REQUEST")}")
121+
?? Environment.GetEnvironmentVariable("TRAVIS_BRANCH")
122+
?? "none";
90123

91-
private static string GetCommitHash()
124+
private static string GetCommitHash()
92125
=> Environment.GetEnvironmentVariable("TRAVIS_PULL_REQUEST_SHA")
93-
?? Environment.GetEnvironmentVariable("TRAVIS_COMMIT")
94-
?? "none";
126+
?? Environment.GetEnvironmentVariable("TRAVIS_COMMIT")
127+
?? "none";
95128

96129
private static string GetBuildNumber()
97130
=> (Environment.GetEnvironmentVariable("TRAVIS_BUILD_NUMBER") ?? "0").PadLeft(5, '0');

docs/docs.csproj

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)