-
-
Notifications
You must be signed in to change notification settings - Fork 18
141 lines (139 loc) · 4.4 KB
/
doc.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
name: Documentation
on:
workflow_dispatch:
release:
types: [published]
push:
branches:
- master
paths:
- apischema/**
- benchmark/**
- docs/**
- examples/**
- mkdocs.yml
- pyproject.toml
pull_request:
paths:
- apischema/**
- benchmark/**
- docs/**
- examples/**
- mkdocs.yml
jobs:
run_benchmark:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('tests/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install apischema
run: pip install -e .
- name: Install requirements
run: pip install -r benchmark/requirements.txt
- name: Run benchmark
run: python benchmark/main.py
- uses: actions/upload-artifact@v3
with:
name: benchmark_table
path: examples/benchmark_table.md
- uses: actions/upload-artifact@v3
with:
name: benchmark_chart_light
path: docs/benchmark_chart_light.svg
- uses: actions/upload-artifact@v3
with:
name: benchmark_chart_dark
path: docs/benchmark_chart_dark.svg
upload_doc:
needs: [run_benchmark]
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('tests/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.12'
- uses: actions/download-artifact@v3
with:
name: benchmark_table
path: examples
- uses: actions/download-artifact@v3
with:
name: benchmark_chart_light
path: docs
- uses: actions/download-artifact@v3
with:
name: benchmark_chart_dark
path: docs
- name: Install requirements
run: pip install -r docs/requirements.txt
- name: Build documentation
run: mkdocs build
- uses: actions/upload-artifact@v3
with:
name: documentation
path: site/**
publish_doc:
needs: [run_benchmark]
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'release'
steps:
- uses: actions/[email protected]
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('tests/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
# TODO bump to 3.12 when mike will support it
python-version: '3.11'
- uses: actions/download-artifact@v3
with:
name: benchmark_table
path: examples
- uses: actions/download-artifact@v3
with:
name: benchmark_chart_light
path: docs
- uses: actions/download-artifact@v3
with:
name: benchmark_chart_dark
path: docs
- name: Install requirements
run: pip install -r docs/requirements.txt
- name: Setup git
run: |
git config user.name github-actions
git config user.email [email protected]
git fetch origin gh-pages --depth=1
- name: Set environment variable
run: |
echo "version=$(cat pyproject.toml | grep "version =" | cut -d' ' -f3 | cut -d'"' -f2 | cut -d. -f-2)" >> $GITHUB_ENV
echo "revision=$(cat pyproject.toml | grep "version =" | cut -d' ' -f3 | cut -d'"' -f2 | cut -d. -f3)" >> $GITHUB_ENV
echo "latest=$(mike list latest -j | jq .version -r)" >> $GITHUB_ENV
- name: Publish dev documentation
if: github.event_name == 'push' && env.version != env.latest
run: mike deploy -p $version dev -t "dev" -u
- name: Publish latest documentation
if: github.event_name == 'release' && env.revision == '0'
run: |
mike retitle latest "$latest"
mike deploy -p $version latest -t "$version (latest)" -u
- name: Publish patch documentation
if: github.event_name == 'release' && env.revision != '0'
run: mike deploy -p $version