From b44cea99eb3d981dc81105b82b2885c6f6d4b08d Mon Sep 17 00:00:00 2001 From: Nikita Beloglazov <77229847+NikitaBeloglazov@users.noreply.github.com> Date: Fri, 29 Sep 2023 02:33:22 +0300 Subject: [PATCH] Add pypi auto-publish try v2 --- tags_marker.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tags_marker.py diff --git a/tags_marker.py b/tags_marker.py new file mode 100644 index 0000000..cbc68a3 --- /dev/null +++ b/tags_marker.py @@ -0,0 +1,42 @@ +import subprocess +import os + +os.system("ls -a") +tag = subprocess.check_output("git describe --tags", shell=True, encoding="UTF-8") + +print("[TAG MARKER] git response: " + tag) +tag = tag.replace("\n", "").replace("v", "") +if tag.find("-") > 1: + tag = tag[0:tag.find("-")] +print("[TAG MARKER] FOUND TAG: " + tag) + +print("[TAG MARKER] MARKING VERSION IN pyproject.toml") +# Open the file for reading and writing (the 'r+' mode provides both read and write access) +with open('pyproject.toml', 'r+') as file: + # Reading the contents of a file + content = file.read() + # Replace the desired part of the text using the replace method + new_content = content.replace('!!{PLACEHOLDER}!!', tag) + # Move the file pointer to the beginning (0) to overwrite + file.seek(0) + # Write the changed content back to the file + file.write(new_content) + # Trim the file if the new content is shorter than the old one to remove the remaining data + file.truncate() +print("[TAG MARKER] DONE") + +print("[TAG MARKER] MARKING VERSION IN src/clipman/__version__.py") +with open('src/clipman/__version__.py', 'r+') as file: + # Reading the contents of a file + content = file.read() + # Replace the desired part of the text using the replace method + new_content = content.replace('!!{PLACEHOLDER}!!', tag) + # Move the file pointer to the beginning (0) to overwrite + file.seek(0) + # Write the changed content back to the file + file.write(new_content) + # Trim the file if the new content is shorter than the old one to remove the remaining data + file.truncate() +print("[TAG MARKER] DONE") + +print("[TAG MARKER] Work finished")