Skip to content

Commit

Permalink
Update update.py (#1)
Browse files Browse the repository at this point in the history
* Update update.py

* Minecraft 1.21.40.25 (Preview)

* test

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
dreamguxiang and github-actions[bot] authored Oct 9, 2024
1 parent 3f058af commit 4ec5dbc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
11 changes: 11 additions & 0 deletions tooth.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"format_version": 2,
"tooth": "github.com/LiteLDev/mc-w10-versiondb-auto-update",
"version": "0.0.0",
"info": {
"name": "mc-w10-versiondb-auto-update",
"description": "mc-w10-versiondb-auto-update",
"author": "LiteLDev",
"tags": []
}
}
14 changes: 14 additions & 0 deletions update.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ def checkForUpdate(pfn, categoryId, releaseType):
commitMsg = "Minecraft " + gameVer
if releaseType == 2:
commitMsg += " (Preview)"

result = subprocess.run(["git", "describe", "--tags", "--abbrev=0"], capture_output=True, text=True)
latest_tag = result.stdout.strip()

if latest_tag.startswith('v'):
tag_number = int(latest_tag[1:]) + 1
else:
tag_number = 1


with open("versions.json.min", "w") as f:
json.dump(versions, f)
Expand All @@ -153,6 +162,11 @@ def checkForUpdate(pfn, categoryId, releaseType):
subprocess.run(["git", "-c", "user.name='github-actions[bot]'", "-c", "user.email='github-actions[bot]@users.noreply.github.com'", "commit", "-m", commitMsg])
subprocess.run(["git", "push", "origin"])

# Add the new tag
tag_name = f"v{tag_number}"
subprocess.run(["git", "tag", tag_name])
subprocess.run(["git", "push", "origin", tag_name])

if os.getenv("ENABLE_NOTIFICATION"):
try:
import notification
Expand Down
Loading

0 comments on commit 4ec5dbc

Please sign in to comment.