-
Notifications
You must be signed in to change notification settings - Fork 32
196 lines (167 loc) · 5.5 KB
/
push.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
on:
push:
branches:
- main
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# allow write to manipulate cache
actions: write
jobs:
build_blueprint:
runs-on: ubuntu-latest
name: Build blueprint
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pip' # cache pip dependencies
- name: Update pip
run: |
pip install --upgrade pip
- name: Install blueprint apt dependencies
run: |
sudo apt-get update
sudo apt-get install -y graphviz libgraphviz-dev pdf2svg dvisvgm
- name: Install blueprint dependencies
run: |
cd blueprint && pip install -r requirements.txt
- name: Build blueprint and copy to `docs/blueprint`
run: |
make blueprint
mkdir -p docs
mv blueprint/web docs/
- name: Clear previously saved cache
uses: DareFox/[email protected]
with:
key: Blueprint-cache
mode: exact
continue-on-error: true
- name: Save blueprint for future use
uses: actions/cache/save@v4
with:
path: |
docs/web
key: Blueprint-cache
- name: Restore previous documentation, while we wait for the next one to be generated
uses: actions/cache/restore@v4
with:
path: |
docs/docs
key: Documentation-cache
continue-on-error: true
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload blueprint artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
# generate doc after blueprint (as it's quite a bit longer)
build_docs:
runs-on: ubuntu-latest
name: Build docs
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install elan
run: curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y --default-toolchain $(cat lean-toolchain)
- name: Build project
run: make LAKEBIN='~/.elan/bin/lake' build
- name: Cache mathlib docs
uses: actions/cache@v3
with:
path: |
.lake/build/doc/Init
.lake/build/doc/Lake
.lake/build/doc/Lean
.lake/build/doc/Std
.lake/build/doc/Mathlib
.lake/build/doc/declarations
!.lake/build/doc/declarations/declaration-data-PrimeNumberTheoremAnd*
key: MathlibDoc-${{ hashFiles('lake-manifest.json') }}
restore-keys: |
MathlibDoc-
- name: Build documentation
run: make LAKEBIN='~/.elan/bin/lake' doc
- name: Copy documentation to `docs/docs`
run: |
mkdir -p docs
cp -r .lake/build/doc docs/docs
- name: Clear previously saved cache
uses: DareFox/[email protected]
with:
key: Documentation-cache
mode: exact
continue-on-error: true
- name: Save documentation for future use
uses: actions/cache/save@v4
with:
path: |
docs/docs
key: Documentation-cache
#- name: Download blueprint artifacts
# uses: actions/download-artifact@v3
# with:
# path: blueprint_artifacts
#
#- name: Extract blueprint artifacts
# run: tar xvf blueprint_artifacts/github-pages/artifact.tar -C docs/
- name: Restore previously generated blueprint
uses: actions/cache/restore@v4
with:
path: |
docs/web
key: Blueprint-cache
continue-on-error: true
## cannot use upload-pages-artifact@v3 twice (it is used for the blueprint above)
## it fails because two identically named artifacts are uploaded
## (for github pages deployment to work, the artifact must be named 'github-pages')
## This could be fixed using upload-artifact's 'overwrite:true' option, but it is not implemented on upload-pages-artifact
## Copied the archive/upload action from upload-pages-artifact below.
## This should be replaced with
## - name: Upload docs & blueprint artifact
## uses: actions/upload-pages-artifact@v3
## with:
## path: docs
## name: github-pages
## overwrite: true
## when this is supported
- name: Archive artifact
shell: sh
run: |
echo ::group::Archive artifact
tar \
--dereference --hard-dereference \
--directory "$INPUT_PATH" \
-cvf "$RUNNER_TEMP/artifact.tar" \
--exclude=.git \
--exclude=.github \
--exclude=".[^/]*" \
.
echo ::endgroup::
env:
INPUT_PATH: docs
- name: Upload artifact
id: upload-artifact
uses: actions/upload-artifact@v4
with:
name: github-pages
path: ${{ runner.temp }}/artifact.tar
retention-days: 1
if-no-files-found: error
overwrite: true
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4