-
Notifications
You must be signed in to change notification settings - Fork 1
124 lines (107 loc) · 3.45 KB
/
docs.yml
File metadata and controls
124 lines (107 loc) · 3.45 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Documentation
on:
push:
branches:
- rel/prod
release:
types: [published]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Restore dotnet tools
run: dotnet tool restore
- name: Build .NET project
run: dotnet build -c Release
- name: Find XML documentation
id: find-xml
run: |
XML_FILE=$(find src -name "Bogoware.Monads.xml" -path "*/bin/Release/*" | head -1)
DLL_FILE=$(find src -name "Bogoware.Monads.dll" -path "*/bin/Release/*" | grep -v "/ref/" | head -1)
echo "xml_file=$XML_FILE" >> "$GITHUB_OUTPUT"
echo "dll_file=$DLL_FILE" >> "$GITHUB_OUTPUT"
- name: Generate API documentation
env:
DLL_FILE: ${{ steps.find-xml.outputs.dll_file }}
run: |
mkdir -p website/src/content/docs/api
dotnet xmldoc2md "$DLL_FILE" -o website/src/content/docs/api --index-page-name index --github-pages
# Add Starlight frontmatter to generated files
for file in website/src/content/docs/api/*.md; do
if [ -f "$file" ]; then
filename=$(basename "$file" .md)
if [ "$filename" = "index" ]; then
title="API Reference"
position=1
else
position=99
# Extract title from H1 heading in the generated markdown
h1_line=$(grep -m1 "^# " "$file" || true)
if [ -n "$h1_line" ]; then
title="${h1_line#\# }"
title="${title//</<}"
title="${title//>/>}"
else
title="${filename#bogoware.monads.}"
fi
# Remove H1 — Starlight generates it from frontmatter title
grep -v "^# " "$file" > "$file.tmp" && mv "$file.tmp" "$file"
fi
temp_file=$(mktemp)
echo "---" > "$temp_file"
echo "title: \"$title\"" >> "$temp_file"
echo "sidebar:" >> "$temp_file"
echo " order: $position" >> "$temp_file"
echo "---" >> "$temp_file"
echo "" >> "$temp_file"
cat "$file" >> "$temp_file"
mv "$temp_file" "$file"
fi
done
- name: Sync changelog
run: node scripts/sync-readme.js
- name: Install dependencies
run: pnpm install
working-directory: website
- name: Build Starlight site
run: pnpm build
working-directory: website
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: website/dist
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4