# Windows bootstrap for the published AI Plate desktop installer. # Keep the URL and checksum pinned together when updating the release. & { $ErrorActionPreference = 'Stop' if ([Environment]::OSVersion.Platform -ne [PlatformID]::Win32NT) { throw 'AI Plate currently publishes a Windows installer only.' } if (-not [Environment]::Is64BitOperatingSystem) { throw 'AI Plate requires 64-bit Windows.' } $downloadUrl = 'https://github.com/Typo-Bunch/AI-Plate/releases/download/v1.0.0-rc.2/AI.Plate.Setup.1.0.0-rc.2.exe' $expectedHash = '269ece749ed8cfcf471bc3942f751fb4ac9f077b493a85b06baa06452727cdf6' $versionLabel = 'Latest Release' try { $releaseJson = Invoke-RestMethod -Uri 'https://api.github.com/repos/Typo-Bunch/AI-Plate/releases/latest' -Headers @{ 'User-Agent' = 'AI-Plate-Installer' } -TimeoutSec 5 -ErrorAction Stop $exeAsset = $releaseJson.assets | Where-Object { $_.name -like '*.exe' } | Select-Object -First 1 if ($exeAsset) { $downloadUrl = $exeAsset.browser_download_url if ($releaseJson.tag_name) { $versionLabel = $releaseJson.tag_name } } } catch { # Fall back gracefully to pinned release } $tempDirectory = Join-Path ([IO.Path]::GetTempPath()) ('aiplate-' + [Guid]::NewGuid().ToString('N')) $installer = Join-Path $tempDirectory 'AI-Plate-Setup.exe' $previousProtocol = [Net.ServicePointManager]::SecurityProtocol try { [Net.ServicePointManager]::SecurityProtocol = $previousProtocol -bor [Net.SecurityProtocolType]::Tls12 New-Item -ItemType Directory -Path $tempDirectory | Out-Null Write-Host "Downloading AI Plate ($versionLabel)..." Invoke-WebRequest -UseBasicParsing -Uri $downloadUrl -OutFile $installer if ($expectedHash -and ($downloadUrl -like '*1.0.0-rc.2*')) { if ((Get-FileHash -LiteralPath $installer -Algorithm SHA256).Hash -ne $expectedHash) { throw 'Installer checksum mismatch. Setup was not started.' } Write-Host 'Checksum verified. Opening the AI Plate setup wizard...' } else { Write-Host 'Download complete. Opening the AI Plate setup wizard...' } $setup = Start-Process -FilePath $installer -Wait -PassThru if ($setup.ExitCode -ne 0) { throw "Setup exited with code $($setup.ExitCode)." } Write-Host 'Setup finished. You can launch AI Plate from the Start menu.' } finally { [Net.ServicePointManager]::SecurityProtocol = $previousProtocol # Delete only the known download and the now-empty temporary directory. if (Test-Path -LiteralPath $installer) { Remove-Item -LiteralPath $installer -Force } if (Test-Path -LiteralPath $tempDirectory) { Remove-Item -LiteralPath $tempDirectory } } }