From 4887abc5773b33ab1e213ed5f528dfebd242e2cd Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 1 Nov 2026 22:23:00 +0100 Subject: v4.4.0: stable installers that follow the newest published build Adds web/latest.php: a plain-text feed of the newest version with each artifact's filename and SHA-256. The per-release generated installers are replaced by stable web/install.sh and web/install.ps1; both read the feed, pick the newest build, verify it, install per-user and add a launcher. Publishing a new app version no longer regenerates or versions the installers. publish.sh drops the installer renderer and Python dependency. deploy.sh now also verifies latest.php against the local artifacts and that the served installer scripts match the repository. --- web/install.ps1 | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 web/install.ps1 (limited to 'web/install.ps1') diff --git a/web/install.ps1 b/web/install.ps1 new file mode 100644 index 0000000..92eef83 --- /dev/null +++ b/web/install.ps1 @@ -0,0 +1,108 @@ +# Zagan-Bet installer for Windows. +# +# Asks the site which build is newest, verifies its SHA-256, installs it for +# the current user and adds a Start-menu shortcut. Point it at a staging site +# with -Site http://127.0.0.1:8899; add -NoPause for automation. +# +# Run it with: +# powershell -ExecutionPolicy Bypass -File .\install.ps1 +param( + [string]$Site = "https://zagan.2137697.xyz", + [switch]$NoPause +) + +$ErrorActionPreference = "Stop" + +function Finish([int]$Code) { + if (-not $NoPause) { + Read-Host "Press Enter to close" | Out-Null + } + exit $Code +} + +function Stop-Install([string]$Message) { + Write-Host "install: $Message" -ForegroundColor Red + Finish 1 +} + +try { + $latest = (Invoke-WebRequest -Uri "$Site/latest.php" -UseBasicParsing).Content +} catch { + Stop-Install "could not read $Site/latest.php: $_" +} + +$line = ($latest -split "`r?`n") | + Where-Object { $_ -match '^gui windows x86_64 ' } | + Select-Object -First 1 +if (-not $line) { + Stop-Install "no Windows build is published yet" +} + +$parts = $line.Trim() -split '\s+' +if ($parts.Count -lt 6) { + Stop-Install "the latest-build file is malformed" +} +$Version = $parts[3] +$Binary = $parts[4] +$Sha256 = $parts[5] +$Url = "$Site/bin/gui/$Binary" + +Write-Host "Newest Zagan-Bet is $Version." + +$here = Split-Path -Parent $MyInvocation.MyCommand.Path +$candidates = @( + (Join-Path $here $Binary), + (Join-Path (Get-Location) $Binary), + (Join-Path $env:USERPROFILE "Downloads\$Binary") +) +$sourceFile = $null +foreach ($candidate in $candidates) { + if (Test-Path -LiteralPath $candidate) { + $sourceFile = $candidate + break + } +} + +$temporary = $null +if (-not $sourceFile) { + $temporary = Join-Path ([System.IO.Path]::GetTempPath()) $Binary + Write-Host "Downloading $Binary..." + try { + Invoke-WebRequest -Uri $Url -OutFile $temporary -UseBasicParsing + } catch { + Stop-Install "download failed: $_" + } + $sourceFile = $temporary +} + +try { + $actual = (Get-FileHash -LiteralPath $sourceFile -Algorithm SHA256).Hash.ToLowerInvariant() + if ($actual -ne $Sha256.ToLowerInvariant()) { + Stop-Install "checksum mismatch: expected $Sha256, got $actual" + } + + $installDir = Join-Path $env:LOCALAPPDATA "Programs\Zagan-Bet" + New-Item -ItemType Directory -Force -Path $installDir | Out-Null + $target = Join-Path $installDir "zagan-bet-gui.exe" + Copy-Item -LiteralPath $sourceFile -Destination $target -Force + + $startMenu = Join-Path $env:APPDATA "Microsoft\Windows\Start Menu\Programs" + New-Item -ItemType Directory -Force -Path $startMenu | Out-Null + $shortcutPath = Join-Path $startMenu "Zagan-Bet.lnk" + $shell = New-Object -ComObject WScript.Shell + $shortcut = $shell.CreateShortcut($shortcutPath) + $shortcut.TargetPath = $target + $shortcut.WorkingDirectory = $installDir + $shortcut.IconLocation = "$target,0" + $shortcut.Description = "Slots, roulette, blackjack and crash" + $shortcut.Save() + + Write-Host "Installed Zagan-Bet $Version to $target" + Write-Host "A Start-menu shortcut was created." +} finally { + if ($temporary -and (Test-Path -LiteralPath $temporary)) { + Remove-Item -LiteralPath $temporary -Force + } +} + +Finish 0 -- cgit v1.2.3