Skip to content

Commit 6552f64

Browse files
committed
docs: add a script for automatic documentation deploy
1 parent 54d86f6 commit 6552f64

1 file changed

Lines changed: 306 additions & 0 deletions

File tree

.github/workflows/docs.yml

Lines changed: 306 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,306 @@
1+
name: Deploy DocC Documentation
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: write
12+
pages: write
13+
id-token: write
14+
actions: read
15+
16+
concurrency:
17+
group: pages-${{ github.head_ref }}
18+
cancel-in-progress: false
19+
20+
jobs:
21+
build-and-deploy:
22+
runs-on: macos-14
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Xcode
28+
uses: maxim-lobanov/setup-xcode@v1
29+
with:
30+
xcode-version: latest-stable
31+
32+
- name: Setup Build Directories
33+
run: |
34+
mkdir -p .build/symbol-graphs
35+
mkdir -p docs
36+
37+
- name: Build ValidatorCore Symbol Graphs
38+
run: |
39+
PRODUCT="ValidatorCore"
40+
PLATFORMS=("iOS" "watchOS" "tvOS" "visionOS" "macOS")
41+
42+
for PLATFORM in "${PLATFORMS[@]}"; do
43+
echo "Building ${PRODUCT} for ${PLATFORM}"
44+
SYMBOL_DIR=".build/symbol-graphs/${PRODUCT}/${PLATFORM}"
45+
mkdir -p "${SYMBOL_DIR}"
46+
47+
xcodebuild build \
48+
-scheme "${PRODUCT}" \
49+
-destination "generic/platform=${PLATFORM}" \
50+
-derivedDataPath .deriveddata \
51+
DOCC_EXTRACT_EXTENSION_SYMBOLS=YES \
52+
OTHER_SWIFT_FLAGS="-Xfrontend -emit-symbol-graph -Xfrontend -emit-symbol-graph-dir -Xfrontend ${SYMBOL_DIR} -Xfrontend -emit-extension-block-symbols" \
53+
2>&1 | grep -v "note:" | grep -v "warning:" || true
54+
done
55+
56+
- name: Build ValidatorUI Symbol Graphs
57+
run: |
58+
PRODUCT="ValidatorUI"
59+
PLATFORMS=("iOS" "watchOS" "tvOS" "visionOS" "macOS")
60+
61+
for PLATFORM in "${PLATFORMS[@]}"; do
62+
echo "Building ${PRODUCT} for ${PLATFORM}"
63+
SYMBOL_DIR=".build/symbol-graphs/${PRODUCT}/${PLATFORM}"
64+
mkdir -p "${SYMBOL_DIR}"
65+
66+
xcodebuild build \
67+
-scheme "${PRODUCT}" \
68+
-destination "generic/platform=${PLATFORM}" \
69+
-derivedDataPath .deriveddata \
70+
DOCC_EXTRACT_EXTENSION_SYMBOLS=YES \
71+
OTHER_SWIFT_FLAGS="-Xfrontend -emit-symbol-graph -Xfrontend -emit-symbol-graph-dir -Xfrontend ${SYMBOL_DIR} -Xfrontend -emit-extension-block-symbols" \
72+
2>&1 | grep -v "note:" | grep -v "warning:" || true
73+
done
74+
75+
- name: Generate ValidatorCore Documentation
76+
run: |
77+
PRODUCT="ValidatorCore"
78+
DOCC_PATH="Sources/ValidatorCore/Validator.docc"
79+
80+
if [ -d "${DOCC_PATH}" ]; then
81+
$(xcrun --find docc) convert "${DOCC_PATH}" \
82+
--fallback-display-name "${PRODUCT}" \
83+
--fallback-bundle-identifier "dev.validator.${PRODUCT}" \
84+
--fallback-bundle-version 1.0.0 \
85+
--output-dir "${PRODUCT}.doccarchive" \
86+
--additional-symbol-graph-dir ".build/symbol-graphs/${PRODUCT}"
87+
else
88+
echo "Warning: ${DOCC_PATH} not found, generating from code comments only"
89+
$(xcrun --find docc) convert \
90+
--fallback-display-name "${PRODUCT}" \
91+
--fallback-bundle-identifier "dev.validator.${PRODUCT}" \
92+
--fallback-bundle-version 1.0.0 \
93+
--output-dir "${PRODUCT}.doccarchive" \
94+
--additional-symbol-graph-dir ".build/symbol-graphs/${PRODUCT}"
95+
fi
96+
97+
$(xcrun --find docc) process-archive transform-for-static-hosting \
98+
"${PRODUCT}.doccarchive" \
99+
--output-path "docs/${PRODUCT}" \
100+
--hosting-base-path ""
101+
102+
- name: Generate ValidatorUI Documentation
103+
run: |
104+
PRODUCT="ValidatorUI"
105+
DOCC_PATH="Sources/ValidatorUI/ValidatorUI.docc"
106+
107+
if [ -d "${DOCC_PATH}" ]; then
108+
$(xcrun --find docc) convert "${DOCC_PATH}" \
109+
--fallback-display-name "${PRODUCT}" \
110+
--fallback-bundle-identifier "dev.validator.${PRODUCT}" \
111+
--fallback-bundle-version 1.0.0 \
112+
--output-dir "${PRODUCT}.doccarchive" \
113+
--additional-symbol-graph-dir ".build/symbol-graphs/${PRODUCT}"
114+
else
115+
echo "Warning: ${DOCC_PATH} not found, generating from code comments only"
116+
$(xcrun --find docc) convert \
117+
--fallback-display-name "${PRODUCT}" \
118+
--fallback-bundle-identifier "dev.validator.${PRODUCT}" \
119+
--fallback-bundle-version 1.0.0 \
120+
--output-dir "${PRODUCT}.doccarchive" \
121+
--additional-symbol-graph-dir ".build/symbol-graphs/${PRODUCT}"
122+
fi
123+
124+
$(xcrun --find docc) process-archive transform-for-static-hosting \
125+
"${PRODUCT}.doccarchive" \
126+
--output-path "docs/${PRODUCT}" \
127+
--hosting-base-path ""
128+
129+
- name: Create Index Page
130+
run: |
131+
cat > docs/index.html << 'EOF'
132+
<!DOCTYPE html>
133+
<html lang="en">
134+
<head>
135+
<meta charset="UTF-8">
136+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
137+
<title>Validator Documentation</title>
138+
<style>
139+
* {
140+
margin: 0;
141+
padding: 0;
142+
box-sizing: border-box;
143+
}
144+
body {
145+
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
146+
background: #f5f5f7;
147+
min-height: 100vh;
148+
display: flex;
149+
align-items: center;
150+
justify-content: center;
151+
padding: 40px 20px;
152+
color: #1d1d1f;
153+
}
154+
.container {
155+
max-width: 980px;
156+
width: 100%;
157+
}
158+
header {
159+
text-align: center;
160+
margin-bottom: 60px;
161+
}
162+
h1 {
163+
font-size: 56px;
164+
font-weight: 600;
165+
letter-spacing: -0.005em;
166+
line-height: 1.07143;
167+
margin-bottom: 8px;
168+
color: #1d1d1f;
169+
}
170+
.subtitle {
171+
font-size: 28px;
172+
font-weight: 400;
173+
line-height: 1.14286;
174+
color: #6e6e73;
175+
}
176+
.docs-grid {
177+
display: grid;
178+
grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
179+
gap: 24px;
180+
margin-bottom: 40px;
181+
}
182+
.doc-card {
183+
background: white;
184+
border-radius: 18px;
185+
padding: 40px;
186+
box-shadow: 0 4px 12px rgba(0,0,0,0.08);
187+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
188+
text-decoration: none;
189+
display: block;
190+
border: 1px solid rgba(0,0,0,0.06);
191+
}
192+
.doc-card:hover {
193+
transform: translateY(-4px);
194+
box-shadow: 0 12px 24px rgba(0,0,0,0.12);
195+
}
196+
.doc-card h2 {
197+
font-size: 32px;
198+
font-weight: 600;
199+
margin-bottom: 12px;
200+
color: #1d1d1f;
201+
letter-spacing: -0.003em;
202+
}
203+
.doc-card p {
204+
font-size: 17px;
205+
line-height: 1.47059;
206+
color: #6e6e73;
207+
margin-bottom: 20px;
208+
}
209+
.doc-card .link {
210+
font-size: 17px;
211+
color: #0071e3;
212+
font-weight: 400;
213+
display: inline-flex;
214+
align-items: center;
215+
}
216+
.doc-card .link::after {
217+
content: '→';
218+
margin-left: 8px;
219+
transition: transform 0.3s ease;
220+
}
221+
.doc-card:hover .link::after {
222+
transform: translateX(4px);
223+
}
224+
.module-badge {
225+
display: inline-block;
226+
background: #f5f5f7;
227+
color: #6e6e73;
228+
padding: 4px 12px;
229+
border-radius: 12px;
230+
font-size: 12px;
231+
font-weight: 600;
232+
letter-spacing: 0.5px;
233+
text-transform: uppercase;
234+
margin-bottom: 16px;
235+
}
236+
footer {
237+
text-align: center;
238+
padding-top: 40px;
239+
border-top: 1px solid rgba(0,0,0,0.08);
240+
margin-top: 40px;
241+
}
242+
footer p {
243+
font-size: 14px;
244+
color: #86868b;
245+
}
246+
@media (max-width: 768px) {
247+
h1 {
248+
font-size: 40px;
249+
}
250+
.subtitle {
251+
font-size: 21px;
252+
}
253+
.docs-grid {
254+
grid-template-columns: 1fr;
255+
}
256+
.doc-card {
257+
padding: 32px;
258+
}
259+
}
260+
</style>
261+
</head>
262+
<body>
263+
<div class="container">
264+
<header>
265+
<h1>Validator</h1>
266+
<p class="subtitle">Comprehensive documentation for Swift validation framework</p>
267+
</header>
268+
269+
<div class="docs-grid">
270+
<a href="ValidatorCore/documentation/validatorcore/" class="doc-card">
271+
<span class="module-badge">Core Module</span>
272+
<h2>ValidatorCore</h2>
273+
<p>Core validation functionality and rules for Swift applications. Contains base types, protocols, and validator implementations.</p>
274+
<span class="link">View documentation</span>
275+
</a>
276+
277+
<a href="ValidatorUI/documentation/validatorui/" class="doc-card">
278+
<span class="module-badge">UI Module</span>
279+
<h2>ValidatorUI</h2>
280+
<p>UI components and helpers for building validation interfaces. Ready-to-use solutions for SwiftUI and UIKit.</p>
281+
<span class="link">View documentation</span>
282+
</a>
283+
</div>
284+
285+
<footer>
286+
<p>Generated with Swift DocC</p>
287+
</footer>
288+
</div>
289+
</body>
290+
</html>
291+
EOF
292+
293+
- name: Deploy to gh-pages
294+
uses: peaceiris/actions-gh-pages@v3
295+
with:
296+
github_token: ${{ secrets.GITHUB_TOKEN }}
297+
publish_dir: ./docs
298+
publish_branch: gh-pages
299+
force_orphan: true
300+
301+
- name: Cleanup
302+
if: always()
303+
run: |
304+
rm -rf .deriveddata
305+
rm -rf .build
306+
rm -rf *.doccarchive

0 commit comments

Comments
 (0)