33 Star 151 Fork 38

duolabmeng/pyefun

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
run_output_version.py 1004 Bytes
一键复制 编辑 原始数据 按行查看 历史
github-actions 提交于 2022-07-25 01:51 . ok
# -*- 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()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/duolabmeng666/pyefun.git
[email protected]:duolabmeng666/pyefun.git
duolabmeng666
pyefun
pyefun
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385