-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
github-actions
committed
Jul 24, 2022
1 parent
a61d9f8
commit 44fb556
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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() |