feat(installer): add Inno Setup packaging to release
- add installer/AnabasisManager.iss for per-user install without admin rights - extend build.py to produce setup.exe via ISCC - publish setup.exe and checksums in release workflow
This commit is contained in:
@@ -38,6 +38,24 @@ jobs:
|
|||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install -r requirements.txt pyinstaller
|
pip install -r requirements.txt pyinstaller
|
||||||
|
|
||||||
|
- name: Ensure Inno Setup 6
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
if (Get-Command iscc.exe -ErrorAction SilentlyContinue) {
|
||||||
|
iscc.exe /? | Out-Null
|
||||||
|
Write-Host "Inno Setup compiler found in PATH."
|
||||||
|
} elseif (Test-Path "C:\Program Files (x86)\Inno Setup 6\ISCC.exe") {
|
||||||
|
"C:\Program Files (x86)\Inno Setup 6" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||||
|
& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" /? | Out-Null
|
||||||
|
Write-Host "Inno Setup compiler found in Program Files (x86)."
|
||||||
|
} elseif (Test-Path "C:\Program Files\Inno Setup 6\ISCC.exe") {
|
||||||
|
"C:\Program Files\Inno Setup 6" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||||
|
& "C:\Program Files\Inno Setup 6\ISCC.exe" /? | Out-Null
|
||||||
|
Write-Host "Inno Setup compiler found in Program Files."
|
||||||
|
} else {
|
||||||
|
throw "Inno Setup 6 is not installed on runner. Install Inno Setup and restart runner service."
|
||||||
|
}
|
||||||
|
|
||||||
- name: Extract app version
|
- name: Extract app version
|
||||||
id: extract_version
|
id: extract_version
|
||||||
shell: powershell
|
shell: powershell
|
||||||
@@ -95,15 +113,19 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
python build.py
|
python build.py
|
||||||
|
|
||||||
- name: Ensure archive exists
|
- name: Ensure artifacts exist
|
||||||
if: env.CONTINUE == 'true'
|
if: env.CONTINUE == 'true'
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
$version = "${{ steps.extract_version.outputs.version }}"
|
$version = "${{ steps.extract_version.outputs.version }}"
|
||||||
$archivePath = "dist/AnabasisManager-$version.zip"
|
$archivePath = "dist/AnabasisManager-$version.zip"
|
||||||
|
$installerPath = "dist/AnabasisManager-setup-$version.exe"
|
||||||
if (-not (Test-Path $archivePath)) {
|
if (-not (Test-Path $archivePath)) {
|
||||||
throw "Archive not found: $archivePath"
|
throw "Archive not found: $archivePath"
|
||||||
}
|
}
|
||||||
|
if (-not (Test-Path $installerPath)) {
|
||||||
|
throw "Installer not found: $installerPath"
|
||||||
|
}
|
||||||
|
|
||||||
- name: Generate SHA256 checksum
|
- name: Generate SHA256 checksum
|
||||||
if: env.CONTINUE == 'true'
|
if: env.CONTINUE == 'true'
|
||||||
@@ -111,11 +133,14 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
$version = "${{ steps.extract_version.outputs.version }}"
|
$version = "${{ steps.extract_version.outputs.version }}"
|
||||||
$archiveName = "AnabasisManager-$version.zip"
|
$archiveName = "AnabasisManager-$version.zip"
|
||||||
$archivePath = "dist/$archiveName"
|
$installerName = "AnabasisManager-setup-$version.exe"
|
||||||
$checksumPath = "dist/$archiveName.sha256"
|
foreach ($name in @($archiveName, $installerName)) {
|
||||||
$hash = (Get-FileHash -Path $archivePath -Algorithm SHA256).Hash.ToLower()
|
$path = "dist/$name"
|
||||||
"$hash $archiveName" | Set-Content -Path $checksumPath -Encoding UTF8
|
$checksumPath = "dist/$name.sha256"
|
||||||
|
$hash = (Get-FileHash -Path $path -Algorithm SHA256).Hash.ToLower()
|
||||||
|
"$hash $name" | Set-Content -Path $checksumPath -Encoding UTF8
|
||||||
Write-Host "Checksum created: $checksumPath"
|
Write-Host "Checksum created: $checksumPath"
|
||||||
|
}
|
||||||
|
|
||||||
- name: Configure git identity
|
- name: Configure git identity
|
||||||
if: env.CONTINUE == 'true'
|
if: env.CONTINUE == 'true'
|
||||||
@@ -152,3 +177,5 @@ jobs:
|
|||||||
files: |
|
files: |
|
||||||
dist/AnabasisManager-${{ steps.extract_version.outputs.version }}.zip
|
dist/AnabasisManager-${{ steps.extract_version.outputs.version }}.zip
|
||||||
dist/AnabasisManager-${{ steps.extract_version.outputs.version }}.zip.sha256
|
dist/AnabasisManager-${{ steps.extract_version.outputs.version }}.zip.sha256
|
||||||
|
dist/AnabasisManager-setup-${{ steps.extract_version.outputs.version }}.exe
|
||||||
|
dist/AnabasisManager-setup-${{ steps.extract_version.outputs.version }}.exe.sha256
|
||||||
|
|||||||
57
build.py
57
build.py
@@ -11,8 +11,10 @@ VERSION = APP_VERSION # Единая версия приложения
|
|||||||
MAIN_SCRIPT = "main.py"
|
MAIN_SCRIPT = "main.py"
|
||||||
UPDATER_SCRIPT = "updater_gui.py"
|
UPDATER_SCRIPT = "updater_gui.py"
|
||||||
ICON_PATH = "icon.ico"
|
ICON_PATH = "icon.ico"
|
||||||
|
INSTALLER_SCRIPT = os.path.join("installer", "AnabasisManager.iss")
|
||||||
DIST_DIR = os.path.join("dist", APP_NAME)
|
DIST_DIR = os.path.join("dist", APP_NAME)
|
||||||
ARCHIVE_NAME = f"{APP_NAME}-{VERSION}" # Формат Название-Версия
|
ARCHIVE_NAME = f"{APP_NAME}-{VERSION}" # Формат Название-Версия
|
||||||
|
INSTALLER_NAME = f"{APP_NAME}-setup-{VERSION}.exe"
|
||||||
SAFE_CLEAN_ROOT_FILES = {"main.py", "updater_gui.py", "requirements.txt", "build.py"}
|
SAFE_CLEAN_ROOT_FILES = {"main.py", "updater_gui.py", "requirements.txt", "build.py"}
|
||||||
REMOVE_LIST = [
|
REMOVE_LIST = [
|
||||||
"Qt6Pdf.dll", "Qt6PdfQuick.dll", "Qt6PdfWidgets.dll",
|
"Qt6Pdf.dll", "Qt6PdfQuick.dll", "Qt6PdfWidgets.dll",
|
||||||
@@ -137,6 +139,59 @@ def create_archive():
|
|||||||
print(f"[ERROR] Не удалось создать архив: {e}")
|
print(f"[ERROR] Не удалось создать архив: {e}")
|
||||||
|
|
||||||
|
|
||||||
|
def _find_iscc():
|
||||||
|
candidates = []
|
||||||
|
iscc_env = os.getenv("ISCC_PATH", "").strip()
|
||||||
|
if iscc_env:
|
||||||
|
candidates.append(iscc_env)
|
||||||
|
candidates.append(shutil.which("iscc"))
|
||||||
|
candidates.append(shutil.which("ISCC.exe"))
|
||||||
|
candidates.append(r"C:\Program Files (x86)\Inno Setup 6\ISCC.exe")
|
||||||
|
candidates.append(r"C:\Program Files\Inno Setup 6\ISCC.exe")
|
||||||
|
for candidate in candidates:
|
||||||
|
if candidate and os.path.exists(candidate):
|
||||||
|
return candidate
|
||||||
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
def build_installer():
|
||||||
|
print(f"\n--- 4. Создание установщика {INSTALLER_NAME} ---")
|
||||||
|
if os.name != "nt":
|
||||||
|
print("[INFO] Установщик Inno Setup создается только на Windows. Шаг пропущен.")
|
||||||
|
return
|
||||||
|
if not os.path.exists(INSTALLER_SCRIPT):
|
||||||
|
print(f"[ERROR] Не найден скрипт установщика: {INSTALLER_SCRIPT}")
|
||||||
|
sys.exit(1)
|
||||||
|
if not os.path.exists(DIST_DIR):
|
||||||
|
print(f"[ERROR] Не найдена папка сборки приложения: {DIST_DIR}")
|
||||||
|
sys.exit(1)
|
||||||
|
iscc_path = _find_iscc()
|
||||||
|
if not iscc_path:
|
||||||
|
print("[ERROR] Не найден Inno Setup Compiler (ISCC.exe).")
|
||||||
|
print("[ERROR] Установите Inno Setup 6 или задайте переменную окружения ISCC_PATH.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
icon_abs_path = os.path.abspath(ICON_PATH)
|
||||||
|
command = [
|
||||||
|
iscc_path,
|
||||||
|
f"/DMyAppVersion={VERSION}",
|
||||||
|
f"/DMySourceDir={os.path.abspath(DIST_DIR)}",
|
||||||
|
f"/DMyOutputDir={os.path.abspath('dist')}",
|
||||||
|
f"/DMyIconFile={icon_abs_path}",
|
||||||
|
os.path.abspath(INSTALLER_SCRIPT),
|
||||||
|
]
|
||||||
|
try:
|
||||||
|
subprocess.check_call(command)
|
||||||
|
installer_path = os.path.join("dist", INSTALLER_NAME)
|
||||||
|
if not os.path.exists(installer_path):
|
||||||
|
print(f"[ERROR] Установщик не создан: {installer_path}")
|
||||||
|
sys.exit(1)
|
||||||
|
print(f"[OK] Установщик создан: {installer_path}")
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print(f"[ERROR] Ошибка при создании установщика: {e}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
ensure_project_root()
|
ensure_project_root()
|
||||||
# Предварительная очистка
|
# Предварительная очистка
|
||||||
@@ -149,8 +204,10 @@ if __name__ == "__main__":
|
|||||||
run_cleanup()
|
run_cleanup()
|
||||||
write_version_marker()
|
write_version_marker()
|
||||||
create_archive()
|
create_archive()
|
||||||
|
build_installer()
|
||||||
|
|
||||||
print("\n" + "=" * 30)
|
print("\n" + "=" * 30)
|
||||||
print("ПРОЦЕСС ЗАВЕРШЕН")
|
print("ПРОЦЕСС ЗАВЕРШЕН")
|
||||||
print(f"Файл для отправки: dist/{ARCHIVE_NAME}.zip")
|
print(f"Файл для отправки: dist/{ARCHIVE_NAME}.zip")
|
||||||
|
print(f"Установщик: dist/{INSTALLER_NAME}")
|
||||||
print("=" * 30)
|
print("=" * 30)
|
||||||
|
|||||||
48
installer/AnabasisManager.iss
Normal file
48
installer/AnabasisManager.iss
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#define MyAppName "Anabasis Manager"
|
||||||
|
#ifndef MyAppVersion
|
||||||
|
#define MyAppVersion "0.0.0"
|
||||||
|
#endif
|
||||||
|
#ifndef MySourceDir
|
||||||
|
#define MySourceDir "..\\dist\\AnabasisManager"
|
||||||
|
#endif
|
||||||
|
#ifndef MyOutputDir
|
||||||
|
#define MyOutputDir "..\\dist"
|
||||||
|
#endif
|
||||||
|
#ifndef MyIconFile
|
||||||
|
#define MyIconFile "..\\icon.ico"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
[Setup]
|
||||||
|
AppId={{6CD9D6F2-4B95-4E9C-A8D8-2A9C8F6AA741}
|
||||||
|
AppName={#MyAppName}
|
||||||
|
AppVersion={#MyAppVersion}
|
||||||
|
AppPublisher=Benya
|
||||||
|
DefaultDirName={localappdata}\Programs\Anabasis Manager
|
||||||
|
DefaultGroupName=Anabasis Manager
|
||||||
|
DisableProgramGroupPage=yes
|
||||||
|
PrivilegesRequired=lowest
|
||||||
|
OutputDir={#MyOutputDir}
|
||||||
|
OutputBaseFilename=AnabasisManager-setup-{#MyAppVersion}
|
||||||
|
Compression=lzma2
|
||||||
|
SolidCompression=yes
|
||||||
|
WizardStyle=modern
|
||||||
|
ArchitecturesInstallIn64BitMode=x64compatible
|
||||||
|
UninstallDisplayIcon={app}\AnabasisManager.exe
|
||||||
|
SetupIconFile={#MyIconFile}
|
||||||
|
|
||||||
|
[Languages]
|
||||||
|
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
|
||||||
|
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||||
|
|
||||||
|
[Tasks]
|
||||||
|
Name: "desktopicon"; Description: "Создать ярлык на рабочем столе"; GroupDescription: "Дополнительные задачи:"
|
||||||
|
|
||||||
|
[Files]
|
||||||
|
Source: "{#MySourceDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||||||
|
|
||||||
|
[Icons]
|
||||||
|
Name: "{group}\Anabasis Manager"; Filename: "{app}\AnabasisManager.exe"
|
||||||
|
Name: "{autodesktop}\Anabasis Manager"; Filename: "{app}\AnabasisManager.exe"; Tasks: desktopicon
|
||||||
|
|
||||||
|
[Run]
|
||||||
|
Filename: "{app}\AnabasisManager.exe"; Description: "Запустить Anabasis Manager"; Flags: nowait postinstall skipifsilent
|
||||||
Reference in New Issue
Block a user