-
Notifications
You must be signed in to change notification settings - Fork 75
113 lines (102 loc) · 3.7 KB
/
documentation.yml
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
# Build and deploy DocC to GitHub pages. Based off of @karwa's work here:
# https://github.com/karwa/swift-url/blob/main/.github/workflows/docs.yml
name: Documentation
on:
release:
types:
- published
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Package
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Download Swift 5.5.1
run: wget -q https://download.swift.org/swift-5.5.1-release/ubuntu2004/swift-5.5.1-RELEASE/swift-5.5.1-RELEASE-ubuntu20.04.tar.gz
- name: Extract Swift 5.5.1
run: tar xzf swift-5.5.1-RELEASE-ubuntu20.04.tar.gz
- name: Add Swift toolchain to PATH
run: |
echo "$GITHUB_WORKSPACE/swift-5.5.1-RELEASE-ubuntu20.04/usr/bin" >> $GITHUB_PATH
- name: Checkout swift-docc
uses: actions/checkout@v2
with:
repository: apple/swift-docc
ref: main
path: swift-docc
- name: Cache DocC
id: cache-docc
uses: actions/cache@v2
with:
key: swift-url-docc-build
path: swift-docc/.build
- name: Build swift-docc
if: ${{ !steps.cache-docc.outputs.cache-hit }}
run: |
cd swift-docc; swift build --product docc -c release; cd ..
- name: Checkout swift-docc-render
uses: actions/checkout@v2
with:
repository: apple/swift-docc-render
ref: main
path: swift-docc-render
- name: Build swift-docc-render
run: |
cd swift-docc-render; npm install && npm run build; cd ..
- name: Checkout gh-pages Branch
uses: actions/checkout@v2
with:
ref: gh-pages
path: docs-out
- name: Build documentation
run: >
rm -rf docs-out/.git;
rm -rf docs-out/main;
for tag in $(echo "main"; git tag);
do
echo "⏳ Generating documentation for "$tag" release.";
if [ -d "docs-out/$tag" ]
then
echo "✅ Documentation for "$tag" already exists.";
else
git checkout .;
git checkout "$tag";
mkdir -p Sources/Parsing/Documentation.docc;
export DOCC_HTML_DIR="$(pwd)/swift-docc-render/dist";
rm -rf .build/symbol-graphs;
mkdir -p .build/symbol-graphs;
swift build \
--target Parsing \
-Xswiftc \
-emit-symbol-graph \
-Xswiftc \
-emit-symbol-graph-dir \
-Xswiftc \
.build/symbol-graphs \
&& swift-docc/.build/release/docc convert Sources/Parsing/Documentation.docc \
--fallback-display-name Parsing \
--fallback-bundle-identifier co.pointfree.Parsing \
--fallback-bundle-version 0.0.0 \
--additional-symbol-graph-dir \
.build/symbol-graphs \
--transform-for-static-hosting \
--hosting-base-path /swift-parsing/"$tag" \
--output-path docs-out/"$tag" \
&& echo "✅ Documentation generated for "$tag" release." \
|| echo "⚠️ Documentation skipped for "$tag".";
fi;
done
- name: Fix permissions
run: 'sudo chown --recursive $USER docs-out'
- name: Publish documentation to GitHub Pages
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: docs-out
single-commit: true