Compare commits

..

3 commits

Author SHA1 Message Date
87f661f2a6 test
Some checks failed
Build and Publish Release / Build Windows (push) Failing after 46s
Build and Publish Release / Build Linux (push) Successful in 3m57s
Build and Publish Release / Upload Assets to Release (push) Has been skipped
2026-05-04 20:37:06 +05:00
a3a944b9c8 build test
Some checks failed
Build and Publish Release / Build Windows (push) Failing after 46s
Build and Publish Release / Upload Assets to Release (push) Has been cancelled
Build and Publish Release / Build Linux (push) Has been cancelled
2026-05-04 20:19:08 +05:00
ab82ba74e2 test on local image
Some checks failed
Build and Publish Release / Build Linux (release) Has been cancelled
Build and Publish Release / Build Windows (release) Has been cancelled
Build and Publish Release / Upload Assets to Release (release) Has been cancelled
Build and Publish Release / Build Windows (push) Failing after 2m15s
Build and Publish Release / Build Linux (push) Successful in 6m37s
Build and Publish Release / Upload Assets to Release (push) Has been skipped
2026-05-04 19:59:56 +05:00
2 changed files with 34 additions and 79 deletions

View file

@ -1,6 +1,7 @@
name: Build and Publish Release name: Build and Publish Release
on: on:
push:
release: release:
types: [published] types: [published]
@ -8,23 +9,20 @@ jobs:
build-linux: build-linux:
name: Build Linux name: Build Linux
runs-on: ubuntu-latest runs-on: ubuntu-latest
container:
image: git.borderban.ru/borderban/ci-images/py-builder:latest
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up Python - name: Cache pip
uses: actions/setup-python@v5 uses: actions/cache@v3
with: with:
python-version: '3.11' path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
- name: Install system dependencies (Tkinter)
run: apt-get update && apt-get install -y python3-tk
- name: Install Python dependencies - name: Install Python dependencies
run: | run: pip install -r requirements.txt
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: Build Linux executable - name: Build Linux executable
run: pyinstaller --onefile --windowed --name factorio-mod-sync-linux main.py run: pyinstaller --onefile --windowed --name factorio-mod-sync-linux main.py
@ -39,22 +37,20 @@ jobs:
name: Build Windows name: Build Windows
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: tobix/pywine:3.11 image: git.borderban.ru/borderban/ci-images/py-builder:latest
steps: steps:
- name: Install Node.js and Git (required for Actions)
run: apt-get update && apt-get install -y nodejs git
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install Python dependencies (Windows) - name: Install Python dependencies (Windows)
# Используем новый гарантированный путь из нашего Dockerfile (C:\python311)
run: | run: |
wine python -m pip install --upgrade pip xvfb-run wine "C:\python311\python.exe" -m pip install -r requirements.txt
wine pip install -r requirements.txt
wine pip install pyinstaller
- name: Build Windows executable - name: Build Windows executable
run: wine pyinstaller --onefile --windowed --name factorio-mod-sync-windows.exe main.py # Теперь PyInstaller вызывается через гарантированно существующий экзешник
run: |
xvfb-run wine "C:\python311\python.exe" -m PyInstaller --onefile --windowed --name factorio-mod-sync-windows main.py
- name: Upload Windows artifact - name: Upload Windows artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
@ -66,7 +62,7 @@ jobs:
name: Upload Assets to Release name: Upload Assets to Release
needs: [build-linux, build-windows] needs: [build-linux, build-windows]
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: always() && (needs.build-linux.result == 'success' || needs.build-windows.result == 'success') if: github.event_name == 'release' || github.event_name == 'push'
steps: steps:
- name: Download all artifacts - name: Download all artifacts
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3

79
main.py
View file

@ -11,31 +11,11 @@ import threading
import subprocess import subprocess
import re import re
APP_VERSION = "v1.1.6"
UPDATE_API_URL = "https://git.borderban.ru/api/v1/repos/BorderBan/client-py/releases/latest" UPDATE_API_URL = "https://git.borderban.ru/api/v1/repos/BorderBan/client-py/releases/latest"
SERVER_URL = "https://server1.borderban.ru/mods/" SERVER_URL = "https://server1.borderban.ru/mods/"
CONFIG_FILE = Path.home() / ".factorio_sync_config.json" CONFIG_FILE = Path.home() / ".factorio_sync_config.json"
def load_app_config():
if CONFIG_FILE.exists():
try:
return json.loads(CONFIG_FILE.read_text())
except Exception:
pass
return {}
def save_app_config(new_data):
config = load_app_config()
config.update(new_data)
try:
CONFIG_FILE.write_text(json.dumps(config))
except Exception as e:
print(f"Ошибка сохранения конфига: {e}")
if not getattr(sys, 'frozen', False):
APP_VERSION = "Dev"
else:
APP_VERSION = load_app_config().get("app_version", "Неизвестная версия")
def get_mod_base_name(filename): def get_mod_base_name(filename):
# Пытаемся отсечь версию мода (обычно ИмяМода_1.0.0.zip) # Пытаемся отсечь версию мода (обычно ИмяМода_1.0.0.zip)
match = re.match(r"^(.+)_(\d+\.\d+\.\d+)\.zip$", filename) match = re.match(r"^(.+)_(\d+\.\d+\.\d+)\.zip$", filename)
@ -82,10 +62,12 @@ def check_and_update(root):
release_data = response.json() release_data = response.json()
latest_version = release_data.get("tag_name") latest_version = release_data.get("tag_name")
if not latest_version: # Проверяем, нужна ли загрузка
if not latest_version or latest_version == APP_VERSION:
update_win.destroy() update_win.destroy()
return return
# Определяем имя нужного ассета в зависимости от ОС
system = platform.system().lower() system = platform.system().lower()
asset_name = None asset_name = None
if system == "windows": if system == "windows":
@ -97,34 +79,12 @@ def check_and_update(root):
update_win.destroy() update_win.destroy()
return return
target_asset = next((asset for asset in release_data.get("assets", []) if asset.get("name") == asset_name), None) download_url = next((asset.get("browser_download_url") for asset in release_data.get("assets", []) if asset.get("name") == asset_name), None)
if not target_asset:
update_win.destroy()
return
download_url = target_asset.get("browser_download_url")
if not download_url: if not download_url:
update_win.destroy() update_win.destroy()
return return
remote_size = target_asset.get("size", 0)
local_size = os.path.getsize(exe_path)
# Если размер файла совпадает с размером из релиза, считаем, что мы уже на этой версии
if remote_size and local_size == remote_size:
if load_app_config().get("app_version") != latest_version:
save_app_config({"app_version": latest_version})
global APP_VERSION
APP_VERSION = latest_version
update_win.destroy()
return
# На крайний случай проверяем сохраненную версию, если размер не удалось получить
if not remote_size and load_app_config().get("app_version") == latest_version:
update_win.destroy()
return
# Обновляем текст на окне, если обновление найдено # Обновляем текст на окне, если обновление найдено
update_label.config(text=f"Обнаружена новая версия ({latest_version}).\nЗагрузка обновления...\nПожалуйста, подождите.") update_label.config(text=f"Обнаружена новая версия ({latest_version}).\nЗагрузка обновления...\nПожалуйста, подождите.")
update_win.update() update_win.update()
@ -144,9 +104,6 @@ def check_and_update(root):
os.replace(exe_path, old_exe_path) os.replace(exe_path, old_exe_path)
os.replace(new_exe_path, exe_path) os.replace(new_exe_path, exe_path)
# Сохраняем новую версию в конфиг перед перезапуском
save_app_config({"app_version": latest_version})
# Перезапускаем новую версию и выходим из текущей # Перезапускаем новую версию и выходим из текущей
subprocess.Popen([exe_path] + sys.argv[1:]) subprocess.Popen([exe_path] + sys.argv[1:])
sys.exit(0) sys.exit(0)
@ -162,23 +119,25 @@ class SyncApp:
self.root.title(f"Factorio Mod Sync {APP_VERSION}") self.root.title(f"Factorio Mod Sync {APP_VERSION}")
self.root.geometry("500x350") self.root.geometry("500x350")
self.config = load_app_config() self.config = self.load_config()
if "mods_path" not in self.config:
self.config["mods_path"] = ""
if "game_path" not in self.config:
self.config["game_path"] = ""
self.setup_ui() self.setup_ui()
def load_config(self):
if CONFIG_FILE.exists():
data = json.loads(CONFIG_FILE.read_text())
return {
"mods_path": data.get("mods_path", ""),
"game_path": data.get("game_path", "")
}
return {"mods_path": "", "game_path": ""}
def save_config(self, mods_path=None, game_path=None): def save_config(self, mods_path=None, game_path=None):
data_to_save = {} config = self.load_config()
if mods_path is not None: if mods_path is not None:
data_to_save["mods_path"] = mods_path config["mods_path"] = mods_path
self.config["mods_path"] = mods_path
if game_path is not None: if game_path is not None:
data_to_save["game_path"] = game_path config["game_path"] = game_path
self.config["game_path"] = game_path CONFIG_FILE.write_text(json.dumps(config))
save_app_config(data_to_save)
def setup_ui(self): def setup_ui(self):
# Выбор пути # Выбор пути