Skip to content

Commit bf78a5b

Browse files
committed
chore(scripts): update release process config
1 parent 33e95f5 commit bf78a5b

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

_config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,5 @@ kramdown:
4848
ssl_certificate: false
4949

5050
timezone: Asia/Shanghai
51+
52+
release: 33e95f52f35ec7a481508c3ebfab4b02cf4217e1

scripts/update_release.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import subprocess
2+
from ruamel.yaml import YAML
3+
import os
4+
5+
def get_latest_commit_hash():
6+
try:
7+
result = subprocess.run(['git', 'log', '-1', '--pretty=format:%H'], capture_output=True, text=True)
8+
return result.stdout.strip()
9+
except Exception as e:
10+
print(f"Error getting latest commit hash: {e}")
11+
return None
12+
13+
def update_release_config(commit_hash):
14+
config_path = '_config.yml'
15+
yaml = YAML()
16+
yaml.preserve_quotes = True
17+
yaml.indent(mapping=2, sequence=4, offset=2)
18+
19+
try:
20+
with open(config_path, 'r') as file:
21+
config = yaml.load(file)
22+
23+
if 'release' in config:
24+
config['release'] = commit_hash
25+
with open(config_path, 'w') as file:
26+
yaml.dump(config, file)
27+
print(f"Updated release to {commit_hash} in _config.yml")
28+
else:
29+
print("Could not find release in _config.yml")
30+
except Exception as e:
31+
print(f"Error updating _config.yml: {e}")
32+
33+
def main():
34+
commit_hash = get_latest_commit_hash()
35+
if commit_hash:
36+
update_release_config(commit_hash)
37+
38+
if __name__ == "__main__":
39+
main()

0 commit comments

Comments
 (0)