forked from hect0x7/JMComic-Crawler-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.py
More file actions
45 lines (31 loc) · 861 Bytes
/
Copy pathrelease.py
File metadata and controls
45 lines (31 loc) · 861 Bytes
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
import os
import sys
import re
def add_output(k, v):
cmd = f'echo "{k}={v}" >> $GITHUB_OUTPUT'
print(cmd, os.system(cmd))
def parse_body(body):
if ';' not in body:
return body
parts = body.split(";")
points = []
for i, e in enumerate(parts):
e: str = e.strip()
if e == '':
continue
points.append(f'{i + 1}. {e}')
return '\n'.join(points)
def get_tag_and_body():
msg = sys.argv[1]
print(f'msg: {msg}')
p = re.compile('(.*?): ?(.*)')
match = p.search(msg)
assert match is not None, f'commit message format is wrong: {msg}'
tag, body = match[1], match[2]
return body, tag
def main():
body, tag = get_tag_and_body()
add_output('tag', tag)
with open('release_body.txt', 'w', encoding='utf-8') as f:
f.write(parse_body(body))
main()