From 87c974f1248a8f8b63de388c7cdc44a4c01190ce Mon Sep 17 00:00:00 2001 From: KeksNino Date: Sun, 19 Oct 2025 15:58:16 +0200 Subject: [PATCH] add build_info.json to workflow for win updater --- .github/workflows/dev.yml | 6 +++++- core/interface/gui.py | 7 ++++++- core/utils/config/config.py | 5 ++--- core/utils/config/settings.py | 4 +--- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index f709e95..e2c3779 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -66,8 +66,12 @@ jobs: pip install -r requirements.txt pip install pyinstaller + - name: Inject commit hash into code + run: | + echo "version = '${GITHUB_SHA}'" > build_info.json + - name: Build executable with PyInstaller - run: pyinstaller --onefile --windowed --name ${{ env.APP_NAME }} main.py + run: pyinstaller --onefile --windowed --add-data "build_info.json:." --name ${{ env.APP_NAME }} main.py - name: Make executable (Unix) if: runner.os != 'Windows' diff --git a/core/interface/gui.py b/core/interface/gui.py index d206c3d..5fae629 100644 --- a/core/interface/gui.py +++ b/core/interface/gui.py @@ -28,6 +28,7 @@ import os import subprocess import time import sys +import json from core.utils.config.settings import save_settings from core.utils.general.wrappers import run_thread from core.utils.data.state import state @@ -53,13 +54,17 @@ def download_update(latest_version): raise FileNotFoundError(f"Executable not found") subprocess.Popen([filename], shell=True) time.sleep(0.5) - save_settings(version=latest_version) sys.exit(0) class MainWindow(QtWidgets.QMainWindow, QWidget): def __init__(self): super().__init__() + build_info_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "build_info.json") + with open(build_info_path, "r") as f: + build_info = json.load(f) + state.version = build_info.get("version", "dev") + # Check for updates on Windows if state.ignore_updates is False: if platform.system() == "Windows": diff --git a/core/utils/config/config.py b/core/utils/config/config.py index c816d3e..7da80cf 100644 --- a/core/utils/config/config.py +++ b/core/utils/config/config.py @@ -6,8 +6,8 @@ from core.utils.data.state import state def create_config(): config = configparser.ConfigParser() - config["General"] = {"debug": True, "api_url": f"{state.api_url}", "aria2_threads": f"{state.aria2_threads}", "download_path": f"{state.download_path}", f"speed_limit": f"{state.speed_limit}", - "version": f"{state.version}", "ignore_updates": f"{state.ignore_updates}"} + config["General"] = {"debug": True, "api_url": f"{state.api_url}", "aria2_threads": f"{state.aria2_threads}", "download_path": f"{state.download_path}", f"speed_limit": f"{state.speed_limit}", + "ignore_updates": f"{state.ignore_updates}"} if platform.system() == "Windows": config_dir = os.environ.get("APPDATA", os.path.expanduser("~\\AppData\\Roaming")) @@ -42,5 +42,4 @@ def read_config(): state.aria2_threads = config.getint("General", "aria2_threads") state.download_path = config.get("General", "download_path") state.speed_limit = config.getint("General", "speed_limit") - state.version = config.get("General", "version") state.ignore_updates = config.getboolean("General", "ignore_updates") diff --git a/core/utils/config/settings.py b/core/utils/config/settings.py index 6f6f1e7..25bb68a 100644 --- a/core/utils/config/settings.py +++ b/core/utils/config/settings.py @@ -13,7 +13,7 @@ def restart_aria2c(): atexit.unregister(kill_aria2server) atexit.register(kill_aria2server) -def save_settings(thread_count=None, close=lambda: None, apiurl=None, download_path=None, speed_limit=None, version=None): +def save_settings(thread_count=None, close=lambda: None, apiurl=None, download_path=None, speed_limit=None): if thread_count is not None: state.aria2_threads = thread_count if apiurl is not None: @@ -22,8 +22,6 @@ def save_settings(thread_count=None, close=lambda: None, apiurl=None, download_p state.download_path = download_path if speed_limit is not None: state.speed_limit = speed_limit - if version is not None: - state.version = version create_config() restart_aria2c()