|
13 | 13 | #from PIL import Image
|
14 | 14 | import git
|
15 | 15 | import ctypes as ct
|
| 16 | +import requests |
| 17 | +import webbrowser |
| 18 | +from tkinter import messagebox |
16 | 19 |
|
17 | 20 | class SourceSDK():
|
18 | 21 | selected_folder : string
|
@@ -627,6 +630,42 @@ def move_files(source_folder, destination_folder):
|
627 | 630 | shutil.move(source_file, destination_file)
|
628 | 631 |
|
629 | 632 |
|
| 633 | +def get_latest_release_version(repo_owner, repo_name): |
| 634 | + url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/releases/latest" |
| 635 | + response = requests.get(url) |
| 636 | + if response.status_code == 200: |
| 637 | + data = response.json() |
| 638 | + return data['tag_name'] |
| 639 | + else: |
| 640 | + return None |
| 641 | + |
| 642 | +def check_software_version(local_version, github_version): |
| 643 | + if local_version == github_version: |
| 644 | + print("You have the latest version installed.") |
| 645 | + else: |
| 646 | + print(f"There is a newer version ({github_version}) available on GitHub.") |
| 647 | + |
| 648 | +# Replace these with your GitHub repository owner and name |
| 649 | +repo_owner = "ChocoScaff" |
| 650 | +repo_name = "SourceSDK-" |
| 651 | + |
| 652 | +# Replace this with the version of your local software |
| 653 | +local_version = "0.0.1" |
| 654 | + |
| 655 | +github_version = get_latest_release_version(repo_owner, repo_name) |
| 656 | + |
| 657 | +if github_version: |
| 658 | + check_software_version(local_version, github_version) |
| 659 | +else: |
| 660 | + print("Failed to fetch the latest version from GitHub.") |
| 661 | + download = messagebox.askyesno("New Version Available", f"There is a newer version ({github_version}) available on GitHub. Do you want to download it?") |
| 662 | + if download: |
| 663 | + webbrowser.open(f"https://github.com/{repo_owner}/{repo_name}/releases/latest") |
| 664 | + else: |
| 665 | + messagebox.showinfo("Version Check", "You chose not to download the new version.") |
| 666 | + |
| 667 | +# Replace these with your GitHub repository owner and name |
| 668 | + |
630 | 669 | sdk = SourceSDK()
|
631 | 670 |
|
632 | 671 | # Create the main window
|
|
0 commit comments