Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Jul 24, 2022
1 parent a61d9f8 commit 44fb556
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ jobs:
uses: actions/setup-python@v1
with:
python-version: 3.7

- name: out version
run:
python run_tags_add.py
# 构建和发布
- name: Install pypa/build
run: >-
Expand Down
41 changes: 41 additions & 0 deletions run_output_version.py
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()

0 comments on commit 44fb556

Please sign in to comment.