1
1
// Licensed to the .NET Foundation under one or more agreements.
2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
4
+ using System ;
4
5
using System . Collections . Generic ;
5
6
using System . IO ;
6
7
using System . Linq ;
@@ -18,34 +19,39 @@ readonly record struct VersionDescription(
18
19
AbsolutePath Path ,
19
20
AbsolutePath StaticPath ,
20
21
string Name ,
21
- bool IsSilk2
22
+ AbsolutePath ? Changelog = null
22
23
) ;
23
24
24
25
// From oldest to newest. Last one is current.
26
+ const bool IsCurrentVersionPreview = true ;
25
27
VersionDescription [ ] Versions =>
26
28
[
27
29
new (
28
30
RootDirectory / "eng" / "submodules" / "silk.net-2.x" / "documentation" ,
29
31
RootDirectory / "eng" / "submodules" / "silk.net-2.x" / "documentation" / "images" ,
30
- "v2" ,
31
- true
32
+ "v2"
32
33
) ,
33
34
new (
34
35
RootDirectory / "docs" ,
35
36
RootDirectory / "sources" / "Website" / "static" / "img" ,
36
37
"v3" ,
37
- false
38
+ RootDirectory / "docs" / "CHANGELOG.md"
38
39
) ,
39
40
] ;
40
41
41
42
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
44
49
) ;
45
50
46
51
void FullBuildWebsite ( )
47
52
{
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" ) ;
49
55
( TemporaryDirectory / "docs" ) . CreateOrCleanDirectory ( ) ;
50
56
( RootDirectory / "docs" ) . Copy (
51
57
TemporaryDirectory / "docs" ,
@@ -83,10 +89,12 @@ void FullBuildWebsite()
83
89
}
84
90
85
91
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
90
98
) ;
91
99
}
92
100
@@ -95,7 +103,10 @@ void FullBuildWebsite()
95
103
RootDirectory / "sources" / "Website" / "silkversions.json" ,
96
104
JsonSerializer . Serialize ( jsonVersions )
97
105
) ;
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
+ ) ;
99
110
}
100
111
finally
101
112
{
@@ -114,4 +125,10 @@ void FullBuildWebsite()
114
125
( TemporaryDirectory / "website" ) . CreateOrCleanDirectory ( ) ;
115
126
}
116
127
}
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
+ }
117
134
}
0 commit comments