forked from duolabmeng6/pyefun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_output_version.py
41 lines (31 loc) · 1004 Bytes
/
run_output_version.py
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
# -*- coding: utf-8 -*-
import os
def view_all_environment_variables():
from icecream import ic
for item in os.environ:
name = item
value = os.environ[item]
ic(name, value)
# view_all_environment_variables()
tagName = os.environ.get('GITHUB_REF_NAME')
print("tagName:", tagName)
fileDir = os.path.dirname(__file__)
print("file dir:", fileDir)
versionFilePath = os.path.join(fileDir, "version.py")
print(f"edit file {versionFilePath} output: version = {tagName}")
# with open(versionFilePath, 'w') as f:
# f.write(f'version = "{tagName}"')
with open("pyefun/__init__.py", "r") as f:
lines = f.readlines()
# 找到版本号的行
for i, line in enumerate(lines):
if '__version__' in line:
# 找到版本号的行
version_line = i
break
# 替换版本号
lines[version_line] = f"__version__ = '{tagName}'\n"
# 写出文件
with open("pyefun/__init__.py", "w") as f:
f.writelines(lines)
exit()