-
Notifications
You must be signed in to change notification settings - Fork 11
149 lines (133 loc) · 4.38 KB
/
build-docs.yml
File metadata and controls
149 lines (133 loc) · 4.38 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
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
name: Build Documentation
on:
push:
branches:
- master
- main
paths:
- 'docs/**'
- '.github/versions.json'
- 'projects/**'
pull_request:
paths:
- 'docs/**'
- '.github/versions.json'
- 'projects/**'
workflow_dispatch:
jobs:
validate-versions:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
cd docs/source
pip install -r requirements.txt
- name: Validate version configuration
run: |
cd docs/source
python utils/version_utils.py --validate
build-docs:
needs: validate-versions
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
cd docs/source
pip install -r requirements.txt
- name: Setup Google Chrome for headless PDF
uses: browser-actions/setup-chrome@v1
- name: Install fonts and locale support
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
fonts-noto-cjk fonts-wqy-zenhei fonts-wqy-microhei \
fonts-arphic-uming fonts-arphic-ukai \
locales
# 生成中英文locale
sudo locale-gen zh_CN.UTF-8
sudo locale-gen zh_CN.GBK
sudo locale-gen en_US.UTF-8
sudo locale-gen en_GB.UTF-8
sudo fc-cache -f -v || true
- name: Verify locale support
run: |
echo "=== 验证locale支持 ==="
echo "可用的locale列表:"
locale -a | grep -E "(zh|en)" || echo "警告: 未找到中英文locale"
echo "当前LANG: $LANG"
echo "当前LC_ALL: $LC_ALL"
echo "=== 测试中文locale ==="
export LANG=zh_CN.UTF-8
export LC_ALL=zh_CN.UTF-8
echo "中文LANG: $LANG"
echo "中文LC_ALL: $LC_ALL"
python3 -c "import locale; print('中文Python locale:', locale.getlocale())"
echo "=== 测试英文locale ==="
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
echo "英文LANG: $LANG"
echo "英文LC_ALL: $LC_ALL"
python3 -c "import locale; print('英文Python locale:', locale.getlocale())"
- name: List version configurations
run: |
cd docs/source
echo "=== 版本配置列表 ==="
python utils/version_utils.py --list
- name: Build all versions
env:
CHROME_PATH: ${{ env.CHROME_PATH }}
run: |
cd docs/source
echo "=== 构建环境信息 ==="
echo "LANG: $LANG"
echo "LC_ALL: $LC_ALL"
echo "LC_CTYPE: $LC_CTYPE"
echo "可用的locale:"
locale -a | grep -E "(zh|en)" | head -10
python3 -c "import locale; print('Python locale:', locale.getlocale())"
echo "=== 开始构建 ==="
echo "注意: 构建管理器将分别为中英文设置正确的locale环境变量"
# 不设置全局locale,让构建管理器自己控制
python build_manager.py --clean
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: docs-build
path: docs/source/source_build/html
retention-days: 30
deploy-docs:
needs: build-docs
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
steps:
- name: Download documentation artifacts
uses: actions/download-artifact@v4
with:
name: docs-build
path: docs/source/source_build/html
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/source/source_build/html
force_orphan: true
user_name: 'github-actions[bot]'
user_email: '41898282+github-actions[bot]@users.noreply.github.com'