Skip to content

Commit 8d23441

Browse files
committed
feat: 添加版本自动同步功能
- 在 build job 中添加脚本 - 从 pyproject.toml 读取版本号 - 自动更新 server.json 中的两处版本号
1 parent 11182f7 commit 8d23441

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,33 @@ jobs:
3939
- name: Install dependencies
4040
run: |
4141
python -m pip install --upgrade pip
42-
pip install build twine
42+
pip install build twine toml
43+
- name: Sync version to server.json
44+
run: |
45+
python -c "
46+
import toml
47+
import json
48+
import re
49+
50+
# 从 pyproject.toml 读取版本
51+
with open('pyproject.toml', 'r') as f:
52+
pyproject = toml.load(f)
53+
version = pyproject['project']['version']
54+
print(f'Version from pyproject.toml: {version}')
55+
56+
# 更新 server.json
57+
with open('server.json', 'r') as f:
58+
server = json.load(f)
59+
60+
server['version'] = version
61+
server['packages'][0]['version'] = version
62+
63+
with open('server.json', 'w') as f:
64+
json.dump(server, f, indent=2)
65+
f.write('\n')
66+
67+
print(f'Updated server.json to version {version}')
68+
"
4369
- name: Build package
4470
run: python -m build
4571
- name: Check distribution

0 commit comments

Comments
 (0)