diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-01 22:23:00 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-01 22:23:00 +0100 |
| commit | 4887abc5773b33ab1e213ed5f528dfebd242e2cd (patch) | |
| tree | 8eb2316783a21817cce422c3fb58ec953206dd9a /web/install.ps1 | |
| parent | v4.3.1: render Windows through wgpu and keep the installer window open (diff) | |
| download | zagan-bet-master.tar.gz zagan-bet-master.zip | |
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.
Diffstat (limited to 'web/install.ps1')
| -rw-r--r-- | web/install.ps1 | 108 |
1 files changed, 108 insertions, 0 deletions
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 @@ | |||
| 1 | # Zagan-Bet installer for Windows. | ||
| 2 | # | ||
| 3 | # Asks the site which build is newest, verifies its SHA-256, installs it for | ||
| 4 | # the current user and adds a Start-menu shortcut. Point it at a staging site | ||
| 5 | # with -Site http://127.0.0.1:8899; add -NoPause for automation. | ||
| 6 | # | ||
| 7 | # Run it with: | ||
| 8 | # powershell -ExecutionPolicy Bypass -File .\install.ps1 | ||
| 9 | param( | ||
| 10 | [string]$Site = "https://zagan.2137697.xyz", | ||
| 11 | [switch]$NoPause | ||
| 12 | ) | ||
| 13 | |||
| 14 | $ErrorActionPreference = "Stop" | ||
| 15 | |||
| 16 | function Finish([int]$Code) { | ||
| 17 | if (-not $NoPause) { | ||
| 18 | Read-Host "Press Enter to close" | Out-Null | ||
| 19 | } | ||
| 20 | exit $Code | ||
| 21 | } | ||
| 22 | |||
| 23 | function Stop-Install([string]$Message) { | ||
| 24 | Write-Host "install: $Message" -ForegroundColor Red | ||
| 25 | Finish 1 | ||
| 26 | } | ||
| 27 | |||
| 28 | try { | ||
| 29 | $latest = (Invoke-WebRequest -Uri "$Site/latest.php" -UseBasicParsing).Content | ||
| 30 | } catch { | ||
| 31 | Stop-Install "could not read $Site/latest.php: $_" | ||
| 32 | } | ||
| 33 | |||
| 34 | $line = ($latest -split "`r?`n") | | ||
| 35 | Where-Object { $_ -match '^gui windows x86_64 ' } | | ||
| 36 | Select-Object -First 1 | ||
| 37 | if (-not $line) { | ||
| 38 | Stop-Install "no Windows build is published yet" | ||
| 39 | } | ||
| 40 | |||
| 41 | $parts = $line.Trim() -split '\s+' | ||
| 42 | if ($parts.Count -lt 6) { | ||
| 43 | Stop-Install "the latest-build file is malformed" | ||
| 44 | } | ||
| 45 | $Version = $parts[3] | ||
| 46 | $Binary = $parts[4] | ||
| 47 | $Sha256 = $parts[5] | ||
| 48 | $Url = "$Site/bin/gui/$Binary" | ||
| 49 | |||
| 50 | Write-Host "Newest Zagan-Bet is $Version." | ||
| 51 | |||
| 52 | $here = Split-Path -Parent $MyInvocation.MyCommand.Path | ||
| 53 | $candidates = @( | ||
| 54 | (Join-Path $here $Binary), | ||
| 55 | (Join-Path (Get-Location) $Binary), | ||
| 56 | (Join-Path $env:USERPROFILE "Downloads\$Binary") | ||
| 57 | ) | ||
| 58 | $sourceFile = $null | ||
| 59 | foreach ($candidate in $candidates) { | ||
| 60 | if (Test-Path -LiteralPath $candidate) { | ||
| 61 | $sourceFile = $candidate | ||
| 62 | break | ||
| 63 | } | ||
| 64 | } | ||
| 65 | |||
| 66 | $temporary = $null | ||
| 67 | if (-not $sourceFile) { | ||
| 68 | $temporary = Join-Path ([System.IO.Path]::GetTempPath()) $Binary | ||
| 69 | Write-Host "Downloading $Binary..." | ||
| 70 | try { | ||
| 71 | Invoke-WebRequest -Uri $Url -OutFile $temporary -UseBasicParsing | ||
| 72 | } catch { | ||
| 73 | Stop-Install "download failed: $_" | ||
| 74 | } | ||
| 75 | $sourceFile = $temporary | ||
| 76 | } | ||
| 77 | |||
| 78 | try { | ||
| 79 | $actual = (Get-FileHash -LiteralPath $sourceFile -Algorithm SHA256).Hash.ToLowerInvariant() | ||
| 80 | if ($actual -ne $Sha256.ToLowerInvariant()) { | ||
| 81 | Stop-Install "checksum mismatch: expected $Sha256, got $actual" | ||
| 82 | } | ||
| 83 | |||
| 84 | $installDir = Join-Path $env:LOCALAPPDATA "Programs\Zagan-Bet" | ||
| 85 | New-Item -ItemType Directory -Force -Path $installDir | Out-Null | ||
| 86 | $target = Join-Path $installDir "zagan-bet-gui.exe" | ||
| 87 | Copy-Item -LiteralPath $sourceFile -Destination $target -Force | ||
| 88 | |||
| 89 | $startMenu = Join-Path $env:APPDATA "Microsoft\Windows\Start Menu\Programs" | ||
| 90 | New-Item -ItemType Directory -Force -Path $startMenu | Out-Null | ||
| 91 | $shortcutPath = Join-Path $startMenu "Zagan-Bet.lnk" | ||
| 92 | $shell = New-Object -ComObject WScript.Shell | ||
| 93 | $shortcut = $shell.CreateShortcut($shortcutPath) | ||
| 94 | $shortcut.TargetPath = $target | ||
| 95 | $shortcut.WorkingDirectory = $installDir | ||
| 96 | $shortcut.IconLocation = "$target,0" | ||
| 97 | $shortcut.Description = "Slots, roulette, blackjack and crash" | ||
| 98 | $shortcut.Save() | ||
| 99 | |||
| 100 | Write-Host "Installed Zagan-Bet $Version to $target" | ||
| 101 | Write-Host "A Start-menu shortcut was created." | ||
| 102 | } finally { | ||
| 103 | if ($temporary -and (Test-Path -LiteralPath $temporary)) { | ||
| 104 | Remove-Item -LiteralPath $temporary -Force | ||
| 105 | } | ||
| 106 | } | ||
| 107 | |||
| 108 | Finish 0 | ||
