mirror of
https://github.com/darkzoul5/YoutubePlaylistSync.git
synced 2026-07-03 04:23:59 +03:00
feat: add app version to about page
This commit is contained in:
@@ -107,6 +107,12 @@ jobs:
|
||||
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
||||
echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Write bundled version file
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
printf '%s\n' "${{ steps.version.outputs.version }}" > version.txt
|
||||
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.12"
|
||||
@@ -124,14 +130,14 @@ jobs:
|
||||
run: |
|
||||
$ErrorActionPreference = "Stop"
|
||||
$ws = "${{ github.workspace }}"
|
||||
pyinstaller --noconfirm --onefile --noconsole --name "ytpl-sync" --icon "$ws/assets/icon.ico" --add-data "$ws/assets/icon.png;assets" --distpath "dist/pyinstaller" --workpath "build/pyinstaller" --specpath "build/pyinstaller" --paths "src" "ytpl-sync-entry.py"
|
||||
pyinstaller --noconfirm --onefile --noconsole --name "ytpl-sync" --icon "$ws/assets/icon.ico" --add-data "$ws/assets/icon.png;assets" --add-data "$ws/version.txt;." --distpath "dist/pyinstaller" --workpath "build/pyinstaller" --specpath "build/pyinstaller" --paths "src" "ytpl-sync-entry.py"
|
||||
|
||||
- name: Build binary (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
pyinstaller --noconfirm --onefile --noconsole --name "ytpl-sync" --icon "${GITHUB_WORKSPACE}/assets/icon.png" --add-data "${GITHUB_WORKSPACE}/assets/icon.png:assets" --distpath "dist/pyinstaller" --workpath "build/pyinstaller" --specpath "build/pyinstaller" --paths "src" "ytpl-sync-entry.py"
|
||||
pyinstaller --noconfirm --onefile --noconsole --name "ytpl-sync" --icon "${GITHUB_WORKSPACE}/assets/icon.png" --add-data "${GITHUB_WORKSPACE}/assets/icon.png:assets" --add-data "${GITHUB_WORKSPACE}/version.txt:." --distpath "dist/pyinstaller" --workpath "build/pyinstaller" --specpath "build/pyinstaller" --paths "src" "ytpl-sync-entry.py"
|
||||
|
||||
- name: Stage package
|
||||
shell: bash
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _resource_base() -> Path:
|
||||
# PyInstaller sets sys._MEIPASS to the temp extraction dir.
|
||||
base = getattr(sys, "_MEIPASS", None)
|
||||
if base:
|
||||
return Path(str(base))
|
||||
return Path.cwd()
|
||||
|
||||
|
||||
def _read_text(path: Path) -> str | None:
|
||||
try:
|
||||
if path.exists():
|
||||
text = path.read_text(encoding="utf-8").strip()
|
||||
return text or None
|
||||
except Exception:
|
||||
pass
|
||||
return None
|
||||
def get_app_version() -> str:
|
||||
"""
|
||||
Returns the packaged app version.
|
||||
|
||||
In release builds this reads from `version.txt` bundled into the EXE.
|
||||
"""
|
||||
candidates = [
|
||||
Path("version.txt"),
|
||||
_resource_base() / "version.txt",
|
||||
]
|
||||
for candidate in candidates:
|
||||
text = _read_text(candidate)
|
||||
if text:
|
||||
return text
|
||||
|
||||
return "dev"
|
||||
@@ -2,6 +2,8 @@ from __future__ import annotations
|
||||
|
||||
from PySide6 import QtCore, QtGui, QtWidgets
|
||||
|
||||
from ...core.utils.version import get_app_version
|
||||
|
||||
|
||||
class AboutPage(QtWidgets.QWidget):
|
||||
def __init__(self, parent: QtWidgets.QWidget | None = None) -> None:
|
||||
@@ -79,6 +81,10 @@ class AboutPage(QtWidgets.QWidget):
|
||||
author = self._muted_label("Dark_Zoul")
|
||||
form.addRow("Author", author)
|
||||
|
||||
version_text = get_app_version()
|
||||
version = self._muted_label(f"v{version_text}" if version_text != "unknown" else version_text)
|
||||
form.addRow("Version", version)
|
||||
|
||||
repo_row = QtWidgets.QHBoxLayout()
|
||||
repo_row.setContentsMargins(0, 0, 0, 0)
|
||||
repo_row.setSpacing(10)
|
||||
|
||||
Reference in New Issue
Block a user