|
| 1 | +$ErrorActionPreference = "Stop" |
| 2 | + |
| 3 | +$RepoRoot = (Resolve-Path "$PSScriptRoot\..").Path |
| 4 | +$VersionFile = Join-Path $RepoRoot "VERSION" |
| 5 | + |
| 6 | +if (-not (Test-Path $VersionFile)) { |
| 7 | + Write-Error "VERSION file not found at $VersionFile" |
| 8 | + exit 1 |
| 9 | +} |
| 10 | + |
| 11 | +$Version = (Get-Content $VersionFile -Raw).Trim() |
| 12 | + |
| 13 | +if ($Version -notmatch '^\d+\.\d+\.\d+(-[a-zA-Z0-9.]+)?$') { |
| 14 | + Write-Error "'$Version' is not valid semver (expected X.Y.Z)" |
| 15 | + exit 1 |
| 16 | +} |
| 17 | + |
| 18 | +Write-Host "Bumping all packages to $Version" |
| 19 | +Write-Host "---------------------------------" |
| 20 | + |
| 21 | +function Bump-Json { |
| 22 | + param([string]$File) |
| 23 | + if (-not (Test-Path $File)) { |
| 24 | + Write-Host " SKIP $File (not found)" |
| 25 | + return |
| 26 | + } |
| 27 | + $content = Get-Content $File -Raw |
| 28 | + $match = [regex]::Match($content, '"version"\s*:\s*"([^"]*)"') |
| 29 | + if (-not $match.Success) { |
| 30 | + Write-Host " SKIP $File (no version field found)" |
| 31 | + return |
| 32 | + } |
| 33 | + $old = $match.Groups[1].Value |
| 34 | + if ($old -eq $Version) { |
| 35 | + Write-Host " OK $File ($old -- already up to date)" |
| 36 | + } else { |
| 37 | + $content = $content -replace [regex]::Escape("`"version`": `"$old`""), "`"version`": `"$Version`"" |
| 38 | + Set-Content $File -Value $content -NoNewline |
| 39 | + Write-Host " SET $File ($old -> $Version)" |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | +function Bump-Toml { |
| 44 | + param([string]$File) |
| 45 | + if (-not (Test-Path $File)) { |
| 46 | + Write-Host " SKIP $File (not found)" |
| 47 | + return |
| 48 | + } |
| 49 | + $content = Get-Content $File -Raw |
| 50 | + $match = [regex]::Match($content, '(?m)^version\s*=\s*"([^"]*)"') |
| 51 | + if (-not $match.Success) { |
| 52 | + Write-Host " SKIP $File (no version field found)" |
| 53 | + return |
| 54 | + } |
| 55 | + $old = $match.Groups[1].Value |
| 56 | + if ($old -eq $Version) { |
| 57 | + Write-Host " OK $File ($old -- already up to date)" |
| 58 | + } else { |
| 59 | + $content = $content -replace ('(?m)^version\s*=\s*"' + [regex]::Escape($old) + '"'), "version = `"$Version`"" |
| 60 | + Set-Content $File -Value $content -NoNewline |
| 61 | + Write-Host " SET $File ($old -> $Version)" |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | +Bump-Json (Join-Path $RepoRoot "surfsense_web\package.json") |
| 66 | +Bump-Json (Join-Path $RepoRoot "surfsense_browser_extension\package.json") |
| 67 | +Bump-Json (Join-Path $RepoRoot "surfsense_desktop\package.json") |
| 68 | +Bump-Toml (Join-Path $RepoRoot "surfsense_backend\pyproject.toml") |
| 69 | + |
| 70 | +Write-Host "" |
| 71 | +Write-Host "Syncing lock files..." |
| 72 | +if (Get-Command uv -ErrorAction SilentlyContinue) { |
| 73 | + Push-Location (Join-Path $RepoRoot "surfsense_backend") |
| 74 | + uv lock |
| 75 | + Pop-Location |
| 76 | + Write-Host " OK surfsense_backend/uv.lock" |
| 77 | +} else { |
| 78 | + Write-Host " SKIP uv not found -- run 'uv lock' in surfsense_backend/ manually" |
| 79 | +} |
| 80 | + |
| 81 | +Write-Host "---------------------------------" |
| 82 | +Write-Host "Done. All packages set to $Version" |
0 commit comments