Skip to content

Commit

Permalink
add upload test
Browse files Browse the repository at this point in the history
  • Loading branch information
Linlang Lv (iSoftStone Information) committed Apr 19, 2024
1 parent bcbb3ac commit 95aec64
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/test_upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
run: |
pip install numpy
pip install cython
python scripts/publish.py
python setup.py bdist_wheel
- name: Build and publish
env:
Expand Down Expand Up @@ -82,4 +83,4 @@ jobs:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TESTPYPI_TOKEN }}
run: |
twine upload --repository-url https://test.pypi.org/legacy/ dist/pyqlib-*-manylinux*.whl
twine upload --repository-url https://test.pypi.org/legacy/ dist/pyqlib-*-manylinux*.whl
35 changes: 35 additions & 0 deletions scripts/publish.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import re


def read_file():
with open("qlib/__init__.py", "r", encoding="utf-8") as f:
content = f.read()
return content


def write_file(content: str):
with open("qlib/__init__.py", "w", encoding="utf-8") as f:
f.write(content)


def update_version(version_num: list):
if len(version_num) == 3:
new_version = f"{version_num[0]}.{version_num[1]}.{version_num[2]}.{1}"
if len(version_num) == 4:
new_version = f"{version_num[0]}.{version_num[1]}.{version_num[2]}.{int(version_num[3]) + 1}"
return new_version


def main():
content = read_file()
pattern = r"__version__ = \"(\d+(\.\d+)*(\.\d+)*)\""
match = re.search(pattern, content)
old_version = match.group(1)
old_version_num = old_version.split(".")
new_version = update_version(old_version_num)
new_content = content.replace(old_version, new_version)
write_file(new_content)


if __name__ == "__main__":
main()

0 comments on commit 95aec64

Please sign in to comment.