mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 00:36:31 +02:00
chore: add lock file syncing in bump-version script
This commit is contained in:
parent
553843ab06
commit
4e2e94250c
3 changed files with 92 additions and 1 deletions
82
scripts/bump-version.ps1
Normal file
82
scripts/bump-version.ps1
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$RepoRoot = (Resolve-Path "$PSScriptRoot\..").Path
|
||||
$VersionFile = Join-Path $RepoRoot "VERSION"
|
||||
|
||||
if (-not (Test-Path $VersionFile)) {
|
||||
Write-Error "VERSION file not found at $VersionFile"
|
||||
exit 1
|
||||
}
|
||||
|
||||
$Version = (Get-Content $VersionFile -Raw).Trim()
|
||||
|
||||
if ($Version -notmatch '^\d+\.\d+\.\d+(-[a-zA-Z0-9.]+)?$') {
|
||||
Write-Error "'$Version' is not valid semver (expected X.Y.Z)"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Bumping all packages to $Version"
|
||||
Write-Host "---------------------------------"
|
||||
|
||||
function Bump-Json {
|
||||
param([string]$File)
|
||||
if (-not (Test-Path $File)) {
|
||||
Write-Host " SKIP $File (not found)"
|
||||
return
|
||||
}
|
||||
$content = Get-Content $File -Raw
|
||||
$match = [regex]::Match($content, '"version"\s*:\s*"([^"]*)"')
|
||||
if (-not $match.Success) {
|
||||
Write-Host " SKIP $File (no version field found)"
|
||||
return
|
||||
}
|
||||
$old = $match.Groups[1].Value
|
||||
if ($old -eq $Version) {
|
||||
Write-Host " OK $File ($old -- already up to date)"
|
||||
} else {
|
||||
$content = $content -replace [regex]::Escape("`"version`": `"$old`""), "`"version`": `"$Version`""
|
||||
Set-Content $File -Value $content -NoNewline
|
||||
Write-Host " SET $File ($old -> $Version)"
|
||||
}
|
||||
}
|
||||
|
||||
function Bump-Toml {
|
||||
param([string]$File)
|
||||
if (-not (Test-Path $File)) {
|
||||
Write-Host " SKIP $File (not found)"
|
||||
return
|
||||
}
|
||||
$content = Get-Content $File -Raw
|
||||
$match = [regex]::Match($content, '(?m)^version\s*=\s*"([^"]*)"')
|
||||
if (-not $match.Success) {
|
||||
Write-Host " SKIP $File (no version field found)"
|
||||
return
|
||||
}
|
||||
$old = $match.Groups[1].Value
|
||||
if ($old -eq $Version) {
|
||||
Write-Host " OK $File ($old -- already up to date)"
|
||||
} else {
|
||||
$content = $content -replace ('(?m)^version\s*=\s*"' + [regex]::Escape($old) + '"'), "version = `"$Version`""
|
||||
Set-Content $File -Value $content -NoNewline
|
||||
Write-Host " SET $File ($old -> $Version)"
|
||||
}
|
||||
}
|
||||
|
||||
Bump-Json (Join-Path $RepoRoot "surfsense_web\package.json")
|
||||
Bump-Json (Join-Path $RepoRoot "surfsense_browser_extension\package.json")
|
||||
Bump-Json (Join-Path $RepoRoot "surfsense_desktop\package.json")
|
||||
Bump-Toml (Join-Path $RepoRoot "surfsense_backend\pyproject.toml")
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Syncing lock files..."
|
||||
if (Get-Command uv -ErrorAction SilentlyContinue) {
|
||||
Push-Location (Join-Path $RepoRoot "surfsense_backend")
|
||||
uv lock
|
||||
Pop-Location
|
||||
Write-Host " OK surfsense_backend/uv.lock"
|
||||
} else {
|
||||
Write-Host " SKIP uv not found -- run 'uv lock' in surfsense_backend/ manually"
|
||||
}
|
||||
|
||||
Write-Host "---------------------------------"
|
||||
Write-Host "Done. All packages set to $Version"
|
||||
|
|
@ -56,5 +56,14 @@ bump_json "$REPO_ROOT/surfsense_browser_extension/package.json"
|
|||
bump_json "$REPO_ROOT/surfsense_desktop/package.json"
|
||||
bump_toml "$REPO_ROOT/surfsense_backend/pyproject.toml"
|
||||
|
||||
echo ""
|
||||
echo "Syncing lock files..."
|
||||
if command -v uv &>/dev/null; then
|
||||
(cd "$REPO_ROOT/surfsense_backend" && uv lock)
|
||||
echo " OK surfsense_backend/uv.lock"
|
||||
else
|
||||
echo " SKIP uv not found -- run 'uv lock' in surfsense_backend/ manually"
|
||||
fi
|
||||
|
||||
echo "---------------------------------"
|
||||
echo "Done. All packages set to $VERSION"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue