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 /scripts | |
| 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 'scripts')
| -rwxr-xr-x | scripts/deploy.sh | 24 | ||||
| -rw-r--r-- | scripts/installers/linux.sh.in | 78 | ||||
| -rw-r--r-- | scripts/installers/windows.ps1.in | 87 | ||||
| -rwxr-xr-x | scripts/publish.sh | 37 | ||||
| -rw-r--r-- | scripts/render-installer.py | 49 |
5 files changed, 32 insertions, 243 deletions
diff --git a/scripts/deploy.sh b/scripts/deploy.sh index b18d462..63bd31c 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh | |||
| @@ -95,6 +95,20 @@ origin=$(printf '%s' "$URL" | sed -E 's#^(https?://[^/]+).*#\1#') | |||
| 95 | grep -oE '[0-9a-f]{64} [A-Za-z0-9._-]+' "$tmp/page.html" > "$tmp/sums" || true | 95 | grep -oE '[0-9a-f]{64} [A-Za-z0-9._-]+' "$tmp/page.html" > "$tmp/sums" || true |
| 96 | [ -s "$tmp/sums" ] || die "no SHA-256 lines on the page (is index.php being served?)" | 96 | [ -s "$tmp/sums" ] || die "no SHA-256 lines on the page (is index.php being served?)" |
| 97 | 97 | ||
| 98 | for script in install.sh install.ps1; do | ||
| 99 | grep -qE "href=\"[^\"]*/$script\"" "$tmp/page.html" \ | ||
| 100 | || die "$script is not linked from the page" | ||
| 101 | curl -fsSL --max-time 30 "$origin/$script" -o "$tmp/$script" \ | ||
| 102 | || die "could not fetch $script" | ||
| 103 | cmp -s "web/$script" "$tmp/$script" \ | ||
| 104 | || die "$script served from the site differs from the local file" | ||
| 105 | done | ||
| 106 | |||
| 107 | curl -fsSL --max-time 30 "$origin/latest.php" -o "$tmp/latest.txt" \ | ||
| 108 | || die "could not fetch latest.php" | ||
| 109 | newest=$(awk '$1 == "version" { print $2; exit }' "$tmp/latest.txt") | ||
| 110 | [ -n "$newest" ] || die "latest.php has no version line" | ||
| 111 | |||
| 98 | failed=0 | 112 | failed=0 |
| 99 | verified=0 | 113 | verified=0 |
| 100 | for local in "${artifacts[@]}"; do | 114 | for local in "${artifacts[@]}"; do |
| @@ -132,6 +146,16 @@ for local in "${artifacts[@]}"; do | |||
| 132 | continue | 146 | continue |
| 133 | fi | 147 | fi |
| 134 | 148 | ||
| 149 | version=$(printf '%s' "$file" | sed -E 's/^zagan-bet-[a-z]+-([0-9]+\.[0-9]+\.[0-9]+)-.*/\1/') | ||
| 150 | if [ "$version" = "$newest" ]; then | ||
| 151 | latest_hash=$(awk -v kind="$kind" -v name="$file" '$1 == kind && $5 == name { print $6 }' "$tmp/latest.txt") | ||
| 152 | if [ "$latest_hash" != "$local_hash" ]; then | ||
| 153 | echo " $file: latest.php shows ${latest_hash:-nothing}, local is $local_hash" | ||
| 154 | failed=1 | ||
| 155 | continue | ||
| 156 | fi | ||
| 157 | fi | ||
| 158 | |||
| 135 | echo " $file: ok" | 159 | echo " $file: ok" |
| 136 | verified=$((verified + 1)) | 160 | verified=$((verified + 1)) |
| 137 | done | 161 | done |
diff --git a/scripts/installers/linux.sh.in b/scripts/installers/linux.sh.in deleted file mode 100644 index 5b53c02..0000000 --- a/scripts/installers/linux.sh.in +++ /dev/null | |||
| @@ -1,78 +0,0 @@ | |||
| 1 | #!/usr/bin/env bash | ||
| 2 | # Zagan-Bet desktop installer for Linux. | ||
| 3 | # | ||
| 4 | # Verifies the app against its published SHA-256, installs it for the current | ||
| 5 | # user and adds a launcher. Put the downloaded app next to this script, or run | ||
| 6 | # the script on its own and it will fetch the matching binary. | ||
| 7 | set -euo pipefail | ||
| 8 | |||
| 9 | VERSION="__VERSION__" | ||
| 10 | BINARY="__BINARY__" | ||
| 11 | SHA256="__SHA256__" | ||
| 12 | URL="__URL__" | ||
| 13 | |||
| 14 | say() { printf '%s\n' "$*"; } | ||
| 15 | die() { printf 'install: %s\n' "$*" >&2; exit 1; } | ||
| 16 | |||
| 17 | command -v sha256sum >/dev/null 2>&1 || die "sha256sum is required" | ||
| 18 | |||
| 19 | here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) | ||
| 20 | source_file="" | ||
| 21 | for candidate in "$here/$BINARY" "./$BINARY" "$HOME/Downloads/$BINARY"; do | ||
| 22 | if [ -f "$candidate" ]; then | ||
| 23 | source_file=$candidate | ||
| 24 | break | ||
| 25 | fi | ||
| 26 | done | ||
| 27 | |||
| 28 | cleanup="" | ||
| 29 | if [ -z "$source_file" ]; then | ||
| 30 | command -v curl >/dev/null 2>&1 || die "put $BINARY next to this installer, or install curl" | ||
| 31 | cleanup=$(mktemp) || die "cannot create a temporary file" | ||
| 32 | say "Downloading $BINARY..." | ||
| 33 | curl -fsSL --max-time 300 "$URL" -o "$cleanup" || die "download failed" | ||
| 34 | source_file=$cleanup | ||
| 35 | fi | ||
| 36 | trap 'if [ -n "$cleanup" ]; then rm -f "$cleanup"; fi' EXIT | ||
| 37 | |||
| 38 | actual=$(sha256sum "$source_file" | awk '{print $1}') | ||
| 39 | [ "$actual" = "$SHA256" ] || die "checksum mismatch: expected $SHA256, got $actual" | ||
| 40 | |||
| 41 | bin_dir="${XDG_BIN_HOME:-$HOME/.local/bin}" | ||
| 42 | data_dir="${XDG_DATA_HOME:-$HOME/.local/share}" | ||
| 43 | app="$bin_dir/zagan-bet-gui" | ||
| 44 | desktop_dir="$data_dir/applications" | ||
| 45 | icon_dir="$data_dir/icons/hicolor/scalable/apps" | ||
| 46 | |||
| 47 | mkdir -p "$bin_dir" "$desktop_dir" "$icon_dir" | ||
| 48 | install -m 0755 "$source_file" "$app" | ||
| 49 | |||
| 50 | cat > "$icon_dir/zagan-bet.svg" <<'ICON' | ||
| 51 | __ICON__ | ||
| 52 | ICON | ||
| 53 | |||
| 54 | cat > "$desktop_dir/zagan-bet.desktop" <<DESKTOP | ||
| 55 | [Desktop Entry] | ||
| 56 | Type=Application | ||
| 57 | Name=Zagan-Bet | ||
| 58 | Comment=Slots, roulette, blackjack and crash | ||
| 59 | Exec=$app | ||
| 60 | Icon=zagan-bet | ||
| 61 | Terminal=false | ||
| 62 | Categories=Game; | ||
| 63 | DESKTOP | ||
| 64 | chmod 0644 "$desktop_dir/zagan-bet.desktop" "$icon_dir/zagan-bet.svg" | ||
| 65 | |||
| 66 | if command -v update-desktop-database >/dev/null 2>&1; then | ||
| 67 | update-desktop-database "$desktop_dir" >/dev/null 2>&1 || true | ||
| 68 | fi | ||
| 69 | if command -v gtk-update-icon-cache >/dev/null 2>&1; then | ||
| 70 | gtk-update-icon-cache -q "$data_dir/icons/hicolor" >/dev/null 2>&1 || true | ||
| 71 | fi | ||
| 72 | |||
| 73 | say "Installed Zagan-Bet $VERSION to $app" | ||
| 74 | say "A launcher was added to your applications menu." | ||
| 75 | case ":$PATH:" in | ||
| 76 | *":$bin_dir:"*) ;; | ||
| 77 | *) say "Add $bin_dir to PATH to start it as 'zagan-bet-gui'." ;; | ||
| 78 | esac | ||
diff --git a/scripts/installers/windows.ps1.in b/scripts/installers/windows.ps1.in deleted file mode 100644 index 4b8e61d..0000000 --- a/scripts/installers/windows.ps1.in +++ /dev/null | |||
| @@ -1,87 +0,0 @@ | |||
| 1 | # Zagan-Bet desktop installer for Windows. | ||
| 2 | # | ||
| 3 | # Verifies the app against its published SHA-256, installs it for the current | ||
| 4 | # user and adds a Start-menu shortcut. Put the downloaded app next to this | ||
| 5 | # script, or run the script on its own and it will fetch the matching binary. | ||
| 6 | # | ||
| 7 | # Run it with: | ||
| 8 | # powershell -ExecutionPolicy Bypass -File .\zagan-bet-gui-*-install.ps1 | ||
| 9 | # Add -NoPause to run it unattended. | ||
| 10 | param([switch]$NoPause) | ||
| 11 | |||
| 12 | $ErrorActionPreference = "Stop" | ||
| 13 | |||
| 14 | $Version = "__VERSION__" | ||
| 15 | $Binary = "__BINARY__" | ||
| 16 | $Sha256 = "__SHA256__" | ||
| 17 | $Url = "__URL__" | ||
| 18 | |||
| 19 | function Finish([int]$Code) { | ||
| 20 | if (-not $NoPause) { | ||
| 21 | Read-Host "Press Enter to close" | Out-Null | ||
| 22 | } | ||
| 23 | exit $Code | ||
| 24 | } | ||
| 25 | |||
| 26 | function Stop-Install([string]$Message) { | ||
| 27 | Write-Host "install: $Message" -ForegroundColor Red | ||
| 28 | Finish 1 | ||
| 29 | } | ||
| 30 | |||
| 31 | $here = Split-Path -Parent $MyInvocation.MyCommand.Path | ||
| 32 | $candidates = @( | ||
| 33 | (Join-Path $here $Binary), | ||
| 34 | (Join-Path (Get-Location) $Binary), | ||
| 35 | (Join-Path $env:USERPROFILE "Downloads\$Binary") | ||
| 36 | ) | ||
| 37 | $sourceFile = $null | ||
| 38 | foreach ($candidate in $candidates) { | ||
| 39 | if (Test-Path -LiteralPath $candidate) { | ||
| 40 | $sourceFile = $candidate | ||
| 41 | break | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 | $temporary = $null | ||
| 46 | if (-not $sourceFile) { | ||
| 47 | $temporary = Join-Path ([System.IO.Path]::GetTempPath()) $Binary | ||
| 48 | Write-Host "Downloading $Binary..." | ||
| 49 | try { | ||
| 50 | Invoke-WebRequest -Uri $Url -OutFile $temporary -UseBasicParsing | ||
| 51 | } catch { | ||
| 52 | Stop-Install "download failed: $_" | ||
| 53 | } | ||
| 54 | $sourceFile = $temporary | ||
| 55 | } | ||
| 56 | |||
| 57 | try { | ||
| 58 | $actual = (Get-FileHash -LiteralPath $sourceFile -Algorithm SHA256).Hash.ToLowerInvariant() | ||
| 59 | if ($actual -ne $Sha256.ToLowerInvariant()) { | ||
| 60 | Stop-Install "checksum mismatch: expected $Sha256, got $actual" | ||
| 61 | } | ||
| 62 | |||
| 63 | $installDir = Join-Path $env:LOCALAPPDATA "Programs\Zagan-Bet" | ||
| 64 | New-Item -ItemType Directory -Force -Path $installDir | Out-Null | ||
| 65 | $target = Join-Path $installDir "zagan-bet-gui.exe" | ||
| 66 | Copy-Item -LiteralPath $sourceFile -Destination $target -Force | ||
| 67 | |||
| 68 | $startMenu = Join-Path $env:APPDATA "Microsoft\Windows\Start Menu\Programs" | ||
| 69 | New-Item -ItemType Directory -Force -Path $startMenu | Out-Null | ||
| 70 | $shortcutPath = Join-Path $startMenu "Zagan-Bet.lnk" | ||
| 71 | $shell = New-Object -ComObject WScript.Shell | ||
| 72 | $shortcut = $shell.CreateShortcut($shortcutPath) | ||
| 73 | $shortcut.TargetPath = $target | ||
| 74 | $shortcut.WorkingDirectory = $installDir | ||
| 75 | $shortcut.IconLocation = "$target,0" | ||
| 76 | $shortcut.Description = "Slots, roulette, blackjack and crash" | ||
| 77 | $shortcut.Save() | ||
| 78 | |||
| 79 | Write-Host "Installed Zagan-Bet $Version to $target" | ||
| 80 | Write-Host "A Start-menu shortcut was created." | ||
| 81 | } finally { | ||
| 82 | if ($temporary -and (Test-Path -LiteralPath $temporary)) { | ||
| 83 | Remove-Item -LiteralPath $temporary -Force | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | Finish 0 | ||
diff --git a/scripts/publish.sh b/scripts/publish.sh index 3a04631..fbcd588 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh | |||
| @@ -5,20 +5,19 @@ | |||
| 5 | # zagan-bet-client-<version>-<platform>-<arch>[.exe] | 5 | # zagan-bet-client-<version>-<platform>-<arch>[.exe] |
| 6 | # zagan-bet-server-<version>-<platform>-<arch>[.exe] | 6 | # zagan-bet-server-<version>-<platform>-<arch>[.exe] |
| 7 | # zagan-bet-gui-<version>-<platform>-<arch>[.exe] | 7 | # zagan-bet-gui-<version>-<platform>-<arch>[.exe] |
| 8 | # zagan-bet-gui-<version>-<platform>-<arch>-install.sh | ||
| 9 | # zagan-bet-gui-<version>-<platform>-<arch>-install.ps1 | ||
| 10 | # | 8 | # |
| 11 | # Cargo always writes target/<triple>/<profile>/<bin>, so the rename happens | 9 | # Cargo always writes target/<triple>/<profile>/<bin>, so the rename happens |
| 12 | # here after each build. The version comes from Cargo.toml. | 10 | # here after each build. The version comes from Cargo.toml. |
| 13 | # | 11 | # |
| 14 | # The GUI uses the workspace's `gui-release` profile (small, stripped, LTO). | 12 | # The GUI uses the workspace's `gui-release` profile (small, stripped, LTO). |
| 15 | # The public git repository is the GPL source for these binaries, so publish | 13 | # The installers are stable site files (web/install.sh and web/install.ps1): |
| 16 | # from a clean tree (or set ALLOW_DIRTY=1 for a preview). | 14 | # they ask web/latest.php for the newest build, so they are not regenerated |
| 15 | # here. The public git repository is the GPL source for these binaries, so | ||
| 16 | # publish from a clean tree (or set ALLOW_DIRTY=1 for a preview). | ||
| 17 | # | 17 | # |
| 18 | # Usage: | 18 | # Usage: |
| 19 | # ./scripts/publish.sh | 19 | # ./scripts/publish.sh |
| 20 | # DEST=/srv/www/bin ./scripts/publish.sh | 20 | # DEST=/srv/www/bin ./scripts/publish.sh |
| 21 | # URL_BASE=https://staging.example/ ./scripts/publish.sh | ||
| 22 | set -euo pipefail | 21 | set -euo pipefail |
| 23 | 22 | ||
| 24 | ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) | 23 | ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) |
| @@ -31,22 +30,12 @@ if [ -z "${VERSION:-}" ]; then | |||
| 31 | fi | 30 | fi |
| 32 | 31 | ||
| 33 | DEST=${DEST:-web/bin} | 32 | DEST=${DEST:-web/bin} |
| 34 | URL_BASE=${URL_BASE:-https://zagan.2137697.xyz} | ||
| 35 | 33 | ||
| 36 | if [ "${ALLOW_DIRTY:-0}" != "1" ] && [ -n "$(git status --porcelain)" ]; then | 34 | if [ "${ALLOW_DIRTY:-0}" != "1" ] && [ -n "$(git status --porcelain)" ]; then |
| 37 | echo "the working tree is dirty; commit the release first (or ALLOW_DIRTY=1)" >&2 | 35 | echo "the working tree is dirty; commit the release first (or ALLOW_DIRTY=1)" >&2 |
| 38 | exit 1 | 36 | exit 1 |
| 39 | fi | 37 | fi |
| 40 | 38 | ||
| 41 | command -v python3 >/dev/null || { | ||
| 42 | echo "python3 is required to render the installers" >&2 | ||
| 43 | exit 1 | ||
| 44 | } | ||
| 45 | |||
| 46 | hash_of() { | ||
| 47 | sha256sum "$1" | awk '{print $1}' | ||
| 48 | } | ||
| 49 | |||
| 50 | publish() { | 39 | publish() { |
| 51 | local triple=$1 kind=$2 platform=$3 arch=$4 | 40 | local triple=$1 kind=$2 platform=$3 arch=$4 |
| 52 | local ext="" | 41 | local ext="" |
| @@ -85,23 +74,13 @@ publish_gui() { | |||
| 85 | 74 | ||
| 86 | mkdir -p "$DEST/gui" | 75 | mkdir -p "$DEST/gui" |
| 87 | install -m 0755 "$source" "$DEST/gui/$artifact" | 76 | install -m 0755 "$source" "$DEST/gui/$artifact" |
| 88 | local sha | ||
| 89 | sha=$(hash_of "$DEST/gui/$artifact") | ||
| 90 | echo " $DEST/gui/$artifact ($(du -h "$DEST/gui/$artifact" | cut -f1))" | 77 | echo " $DEST/gui/$artifact ($(du -h "$DEST/gui/$artifact" | cut -f1))" |
| 91 | |||
| 92 | if [ "$platform" = linux ]; then | ||
| 93 | python3 scripts/render-installer.py \ | ||
| 94 | scripts/installers/linux.sh.in \ | ||
| 95 | "$DEST/gui/zagan-bet-gui-$VERSION-linux-$arch-install.sh" \ | ||
| 96 | "$VERSION" "$artifact" "$sha" "$URL_BASE/bin/gui/$artifact" | ||
| 97 | elif [ "$platform" = windows ]; then | ||
| 98 | python3 scripts/render-installer.py \ | ||
| 99 | scripts/installers/windows.ps1.in \ | ||
| 100 | "$DEST/gui/zagan-bet-gui-$VERSION-windows-$arch-install.ps1" \ | ||
| 101 | "$VERSION" "$artifact" "$sha" "$URL_BASE/bin/gui/$artifact" | ||
| 102 | fi | ||
| 103 | } | 78 | } |
| 104 | 79 | ||
| 80 | rm web/bin/client/* | ||
| 81 | rm web/bin/gui/* | ||
| 82 | rm web/bin/server/* | ||
| 83 | |||
| 105 | publish_gui x86_64-unknown-linux-gnu linux x86_64 | 84 | publish_gui x86_64-unknown-linux-gnu linux x86_64 |
| 106 | publish_gui x86_64-pc-windows-gnu windows x86_64 | 85 | publish_gui x86_64-pc-windows-gnu windows x86_64 |
| 107 | 86 | ||
diff --git a/scripts/render-installer.py b/scripts/render-installer.py deleted file mode 100644 index 1a00551..0000000 --- a/scripts/render-installer.py +++ /dev/null | |||
| @@ -1,49 +0,0 @@ | |||
| 1 | #!/usr/bin/env python3 | ||
| 2 | """Fill an installer template with one published artifact's details. | ||
| 3 | |||
| 4 | Usage: render-installer.py <template> <output> <version> <binary> <sha256> <url> | ||
| 5 | |||
| 6 | The Linux template embeds the application icon so the installer works offline. | ||
| 7 | """ | ||
| 8 | |||
| 9 | from __future__ import annotations | ||
| 10 | |||
| 11 | import pathlib | ||
| 12 | import sys | ||
| 13 | |||
| 14 | |||
| 15 | def main(argv: list[str]) -> int: | ||
| 16 | if len(argv) != 7: | ||
| 17 | print( | ||
| 18 | "usage: render-installer.py <template> <output> <version> " | ||
| 19 | "<binary> <sha256> <url>", | ||
| 20 | file=sys.stderr, | ||
| 21 | ) | ||
| 22 | return 2 | ||
| 23 | |||
| 24 | template, output, version, binary, sha256, url = argv[1:] | ||
| 25 | root = pathlib.Path(__file__).resolve().parent.parent | ||
| 26 | icon = (root / "gui" / "assets" / "zagan-bet.svg").read_text() | ||
| 27 | |||
| 28 | text = pathlib.Path(template).read_text() | ||
| 29 | replacements = { | ||
| 30 | "__VERSION__": version, | ||
| 31 | "__BINARY__": binary, | ||
| 32 | "__SHA256__": sha256, | ||
| 33 | "__URL__": url, | ||
| 34 | "__ICON__": icon.rstrip("\n"), | ||
| 35 | } | ||
| 36 | for placeholder, value in replacements.items(): | ||
| 37 | text = text.replace(placeholder, value) | ||
| 38 | |||
| 39 | destination = pathlib.Path(output) | ||
| 40 | destination.write_text(text) | ||
| 41 | if destination.suffix == ".sh": | ||
| 42 | destination.chmod(0o755) | ||
| 43 | |||
| 44 | print(f" {destination} ({destination.stat().st_size} bytes)") | ||
| 45 | return 0 | ||
| 46 | |||
| 47 | |||
| 48 | if __name__ == "__main__": | ||
| 49 | raise SystemExit(main(sys.argv)) | ||
