a50dd3b34b
- Rebuild StudioBridge-2.1.3.jar from latest upstream (v2.1.3) and deploy to portable-dist - Add ensurePersistentDirectories() so the app creates ~/.studio-bridge and Profiles at startup (GUI + --sendonly) - Bundle full StudioBridge source under StudioBridge-src/ (with rebuild-jar.bat) - Update launchers (Launch-StudioBridge.bat, portable-dist/StudioBridge.bat) to v2.1.3 - Add check-update.ps1 and UPDATE.md for the step-by-step update runbook - Update README (v2.1.3, persistent data + updating sections) - Ignore StudioBridge-src/target/ build output
107 lines
3.7 KiB
PowerShell
107 lines
3.7 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
check-update.ps1 - Check if a newer StudioBridge release exists on GitHub
|
|
and compare it with the version bundled in this project.
|
|
|
|
.DESCRIPTION
|
|
Used as Step 1 of the update procedure (see UPDATE.md).
|
|
It reads the currently bundled version from the jar in portable-dist,
|
|
queries the GitHub releases API for the latest release, and reports
|
|
whether an update is available.
|
|
|
|
.EXAMPLE
|
|
.\check-update.ps1
|
|
.\check-update.ps1 -Repo "Rdiger-36/StudioBridge"
|
|
|
|
.NOTES
|
|
Exit codes:
|
|
0 - up to date (or no update available)
|
|
1 - update available
|
|
2 - error (offline, API failure, or version could not be determined)
|
|
#>
|
|
param(
|
|
[string]$Repo = "Rdiger-36/StudioBridge",
|
|
[string]$PortableDir = (Join-Path $PSScriptRoot "portable-dist")
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
function Get-BundledVersion {
|
|
# Bundled version = parsed from the deployed jar filename: StudioBridge-X.Y.Z.jar
|
|
$jar = Get-ChildItem -Path $PortableDir -Filter "StudioBridge-*.jar" -File -ErrorAction SilentlyContinue |
|
|
Where-Object { $_.Name -match 'StudioBridge-(\d+\.\d+\.\d+)\.jar$' } |
|
|
Select-Object -First 1
|
|
|
|
if ($jar) {
|
|
if ($jar.Name -match 'StudioBridge-(\d+\.\d+\.\d+)\.jar$') {
|
|
return $matches[1]
|
|
}
|
|
}
|
|
|
|
# Fallback: read the version from the launcher script (JAR_FILE=...StudioBridge-X.Y.Z.jar)
|
|
$bat = Join-Path $PortableDir "StudioBridge.bat"
|
|
if (Test-Path $bat) {
|
|
$line = Select-String -Path $bat -Pattern 'StudioBridge-(\d+\.\d+\.\d+)\.jar' | Select-Object -First 1
|
|
if ($line -and $line.Matches[0].Groups[1]) {
|
|
return $line.Matches[0].Groups[1].Value
|
|
}
|
|
}
|
|
return $null
|
|
}
|
|
|
|
function Get-LatestVersion {
|
|
$headers = @{ 'User-Agent' = 'StudioBridge-update-check' }
|
|
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest" -Headers $headers
|
|
# Normalize tags like "v.2.1.3", "v2.1.3", "2.1.3" -> "2.1.3"
|
|
return ($release.tag_name -replace '^v\.?', '')
|
|
}
|
|
|
|
function Test-Newer([string]$current, [string]$latest) {
|
|
$a = $current -split '\.' | ForEach-Object { [int]$_ }
|
|
$b = $latest -split '\.' | ForEach-Object { [int]$_ }
|
|
for ($i = 0; $i -lt [Math]::Max($a.Count, $b.Count); $i++) {
|
|
$x = if ($i -lt $a.Count) { $a[$i] } else { 0 }
|
|
$y = if ($i -lt $b.Count) { $b[$i] } else { 0 }
|
|
if ($x -ne $y) { return $x -lt $y }
|
|
}
|
|
return $false
|
|
}
|
|
|
|
# --- Main ----------------------------------------------------------------
|
|
try {
|
|
$bundled = Get-BundledVersion
|
|
if (-not $bundled) {
|
|
Write-Host "ERROR: Could not determine the bundled version in: $PortableDir" -ForegroundColor Red
|
|
exit 2
|
|
}
|
|
|
|
Write-Host "Repo : $Repo"
|
|
Write-Host "Bundled version : $bundled"
|
|
|
|
$latest = Get-LatestVersion
|
|
Write-Host "Latest on GitHub : $latest"
|
|
|
|
if ($bundled -eq $latest) {
|
|
Write-Host ""
|
|
Write-Host "OK - You are up to date. No update needed." -ForegroundColor Green
|
|
exit 0
|
|
}
|
|
|
|
if (Test-Newer $bundled $latest) {
|
|
Write-Host ""
|
|
Write-Host "UPDATE AVAILABLE: $bundled -> $latest" -ForegroundColor Yellow
|
|
Write-Host "Follow the steps in UPDATE.md to download, rebuild and deploy."
|
|
exit 1
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "Note: bundled version ($bundled) is newer than the latest GitHub release ($latest)." -ForegroundColor Cyan
|
|
exit 0
|
|
}
|
|
catch {
|
|
Write-Host "ERROR: $($_.Exception.Message)" -ForegroundColor Red
|
|
if ($_.ErrorDetails.Message) { Write-Host $_.ErrorDetails.Message -ForegroundColor Red }
|
|
Write-Host "Check your internet connection, then retry." -ForegroundColor Yellow
|
|
exit 2
|
|
}
|