Skip to content

Commit

Permalink
Add pypi auto-publish try v2
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaBeloglazov committed Sep 28, 2023
1 parent a4a2e77 commit b44cea9
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tags_marker.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit b44cea9

Please sign in to comment.