feat(dist): crates.io + binstall + Windows install.ps1 + license files
ci / gate (push) Successful in 3m14s
ci / gate (push) Successful in 3m14s
Distribution prep on the road to public availability (plan steps 2–3a). - Cargo.toml: publish-ready (drop publish=false; homepage/keywords/ categories/exclude) + [package.metadata.binstall] with per-target overrides (linux-gnu->musl, windows-msvc->gnu/gnullvm). dry-run clean. - scripts/install.ps1: Windows `irm | iex` one-liner — written but untested here (no PowerShell; validate on Windows). README Windows block. - README.md (new); LICENSE-MIT + LICENSE-APACHE (dual, (c) Lazy Evaluation Ltd); CONTRIBUTING.md (inbound=outbound dual-license note). - ADR-0055 Amendment 1 (install.ps1), ADR-0056 (crates.io/binstall), README index + plan updates. The actual `cargo publish` remains a gated maintainer step (token, irreversible) at a new tagged release; real cargo-binstall validation pending.
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Download and install a prebuilt rdbms-playground binary (Windows).
|
||||
|
||||
.DESCRIPTION
|
||||
The Windows counterpart of scripts/install.sh. Detects the CPU
|
||||
architecture, downloads the matching release .exe from the Gitea
|
||||
releases, verifies its SHA-256 checksum, installs it to
|
||||
%LOCALAPPDATA%\Programs\rdbms-playground, and adds that directory to
|
||||
your user PATH.
|
||||
|
||||
Quick start:
|
||||
irm https://git.lazyeval.net/oli/rdbms-playground/raw/branch/main/scripts/install.ps1 | iex
|
||||
|
||||
We ship gnu / gnullvm Windows builds (x86_64 / aarch64); this maps the
|
||||
host architecture to the right asset.
|
||||
|
||||
.PARAMETER Version
|
||||
Install a specific tag (e.g. v0.2.0) instead of the latest release.
|
||||
Defaults to $env:RDBMS_VERSION, else the latest release.
|
||||
|
||||
.PARAMETER InstallDir
|
||||
Install directory. Defaults to $env:RDBMS_INSTALL_DIR, else
|
||||
%LOCALAPPDATA%\Programs\rdbms-playground.
|
||||
|
||||
.NOTES
|
||||
Written but NOT tested on Windows from this environment (no PowerShell
|
||||
here) — validate on a real Windows host. The verified sibling is
|
||||
install.sh (Linux/macOS).
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$Version = $env:RDBMS_VERSION,
|
||||
[string]$InstallDir = $(if ($env:RDBMS_INSTALL_DIR) { $env:RDBMS_INSTALL_DIR } else { "$env:LOCALAPPDATA\Programs\rdbms-playground" })
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$Repo = 'https://git.lazyeval.net/oli/rdbms-playground'
|
||||
$Api = 'https://git.lazyeval.net/api/v1/repos/oli/rdbms-playground'
|
||||
$Bin = 'rdbms-playground'
|
||||
|
||||
# Map the host CPU to the target triple we publish for Windows.
|
||||
$osArch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
|
||||
switch ($osArch) {
|
||||
'X64' { $target = 'x86_64-pc-windows-gnu' }
|
||||
'Arm64' { $target = 'aarch64-pc-windows-gnullvm' }
|
||||
default { throw "install: unsupported CPU architecture: $osArch" }
|
||||
}
|
||||
|
||||
# Resolve the release tag (explicit -Version, else the latest release).
|
||||
if (-not $Version) {
|
||||
$Version = (Invoke-RestMethod -Uri "$Api/releases/latest").tag_name
|
||||
if (-not $Version) { throw 'install: could not determine the latest release tag' }
|
||||
}
|
||||
|
||||
$asset = "$Bin-$Version-$target.exe"
|
||||
$url = "$Repo/releases/download/$Version/$asset"
|
||||
|
||||
$tmp = Join-Path $env:TEMP ([System.Guid]::NewGuid().ToString())
|
||||
New-Item -ItemType Directory -Path $tmp -Force | Out-Null
|
||||
try {
|
||||
$exe = Join-Path $tmp "$Bin.exe"
|
||||
$shaFile = "$exe.sha256"
|
||||
|
||||
Write-Host "downloading $asset ..."
|
||||
Invoke-WebRequest -Uri $url -OutFile $exe
|
||||
Invoke-WebRequest -Uri "$url.sha256" -OutFile $shaFile
|
||||
|
||||
# The sidecar is "<hash> <name>"; compare just the hash.
|
||||
$expected = ((Get-Content -Raw $shaFile) -split '\s+')[0].ToLower()
|
||||
$actual = (Get-FileHash -Algorithm SHA256 -Path $exe).Hash.ToLower()
|
||||
if ($expected -ne $actual) {
|
||||
throw "install: checksum mismatch (expected $expected, got $actual) — refusing to install"
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
|
||||
$dest = Join-Path $InstallDir "$Bin.exe"
|
||||
Move-Item -Path $exe -Destination $dest -Force
|
||||
Write-Host "installed $Bin $Version -> $dest"
|
||||
|
||||
# Add the install dir to the user PATH (persistent) if it's not there.
|
||||
$userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
|
||||
if (-not $userPath) { $userPath = '' }
|
||||
if (($userPath -split ';') -notcontains $InstallDir) {
|
||||
$newPath = if ($userPath) { "$userPath;$InstallDir" } else { $InstallDir }
|
||||
[Environment]::SetEnvironmentVariable('Path', $newPath, 'User')
|
||||
Write-Host "added $InstallDir to your user PATH — restart your shell to pick it up"
|
||||
}
|
||||
}
|
||||
finally {
|
||||
Remove-Item -Path $tmp -Recurse -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
Reference in New Issue
Block a user