Skip to content

Commit fa72a41

Browse files
committed
Working multi-versioning
1 parent 41b9b2c commit fa72a41

File tree

3 files changed

+31
-69
lines changed

3 files changed

+31
-69
lines changed

eng/build/Build.Website.cs

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System;
45
using System.Collections.Generic;
56
using System.IO;
67
using System.Linq;
@@ -18,34 +19,39 @@ readonly record struct VersionDescription(
1819
AbsolutePath Path,
1920
AbsolutePath StaticPath,
2021
string Name,
21-
bool IsSilk2
22+
AbsolutePath? Changelog = null
2223
);
2324

2425
// From oldest to newest. Last one is current.
26+
const bool IsCurrentVersionPreview = true;
2527
VersionDescription[] Versions =>
2628
[
2729
new(
2830
RootDirectory / "eng" / "submodules" / "silk.net-2.x" / "documentation",
2931
RootDirectory / "eng" / "submodules" / "silk.net-2.x" / "documentation" / "images",
30-
"v2",
31-
true
32+
"v2"
3233
),
3334
new(
3435
RootDirectory / "docs",
3536
RootDirectory / "sources" / "Website" / "static" / "img",
3637
"v3",
37-
false
38+
RootDirectory / "docs" / "CHANGELOG.md"
3839
),
3940
];
4041

4142
readonly record struct JsonVersion(
42-
string Label,
43-
[property: JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] string? Path
43+
[property: JsonPropertyName("label")] string Label,
44+
[property:
45+
JsonPropertyName("path"),
46+
JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)
47+
]
48+
string? Path
4449
);
4550

4651
void FullBuildWebsite()
4752
{
48-
// Copy the current docs directory to a temporary directory, as we'll be making a lot of changes to this.
53+
(RootDirectory / "sources" / "Website" / "node_modules").CreateOrCleanDirectory();
54+
Npm("i", RootDirectory / "sources" / "Website");
4955
(TemporaryDirectory / "docs").CreateOrCleanDirectory();
5056
(RootDirectory / "docs").Copy(
5157
TemporaryDirectory / "docs",
@@ -83,10 +89,12 @@ void FullBuildWebsite()
8389
}
8490

8591
jsonVersions[i == versions.Length - 1 ? "current" : version.Name] = new JsonVersion(
86-
Git($"describe --tags --abbrev=0", version.Path)
87-
.First(x => x.Type == OutputType.Std)
88-
.Text.Trim(),
89-
version.Name
92+
version.Changelog is { } changelog
93+
? GetVersionFromChangelog(changelog)
94+
: Git($"describe --tags --abbrev=0", version.Path)
95+
.First(x => x.Type == OutputType.Std)
96+
.Text.Trim(),
97+
i == versions.Length - 1 ? version.Name : null
9098
);
9199
}
92100

@@ -95,7 +103,10 @@ void FullBuildWebsite()
95103
RootDirectory / "sources" / "Website" / "silkversions.json",
96104
JsonSerializer.Serialize(jsonVersions)
97105
);
98-
Npm($"run build -- --out-dir {RootDirectory / "artifacts" / "docs"}");
106+
Npm(
107+
$"run build -- --out-dir {RootDirectory / "artifacts" / "docs" / "Silk.NET"}",
108+
RootDirectory / "sources" / "Website"
109+
);
99110
}
100111
finally
101112
{
@@ -114,4 +125,10 @@ void FullBuildWebsite()
114125
(TemporaryDirectory / "website").CreateOrCleanDirectory();
115126
}
116127
}
128+
129+
string GetVersionFromChangelog(AbsolutePath path)
130+
{
131+
GetVersionInfo(File.ReadAllText(path), out var ver, out var suffix, out _);
132+
return string.IsNullOrWhiteSpace(suffix) ? $"v{ver}" : $"v{ver}-{suffix}";
133+
}
117134
}

sources/Website/package-lock.json

Lines changed: 1 addition & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)