Decky/scripts/Set-Version.ps1
Elijah 6a8c6a1eb6
Some checks are pending
Validate Decky / web-client (push) Waiting to run
Add board and stack management for 0.3.0
2026-07-19 19:03:18 -07:00

36 lines
1.6 KiB
PowerShell

#requires -Version 5.1
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[ValidatePattern('^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$')]
[string]$Version
)
$ErrorActionPreference = 'Stop'
$repositoryRoot = Split-Path -Parent $PSScriptRoot
$appRoot = Join-Path $repositoryRoot 'app'
Push-Location $appRoot
try {
& npm.cmd version $Version --no-git-tag-version --allow-same-version
if ($LASTEXITCODE) { throw 'npm could not update package.json and package-lock.json.' }
} finally {
Pop-Location
}
$tauriConfigPath = Join-Path $appRoot 'src-tauri\tauri.conf.json'
$tauriConfig = Get-Content -Raw -LiteralPath $tauriConfigPath
$tauriConfig = [regex]::Replace($tauriConfig, '(?m)(^\s*"version"\s*:\s*")[^"]+("\s*,)', "`${1}$Version`${2}", 1)
[IO.File]::WriteAllText($tauriConfigPath, $tauriConfig, (New-Object Text.UTF8Encoding($false)))
$cargoManifestPath = Join-Path $appRoot 'src-tauri\Cargo.toml'
$cargoManifest = Get-Content -Raw -LiteralPath $cargoManifestPath
$cargoManifest = [regex]::Replace($cargoManifest, '(?m)(^version\s*=\s*")[^"]+("\s*$)', "`${1}$Version`${2}", 1)
[IO.File]::WriteAllText($cargoManifestPath, $cargoManifest, (New-Object Text.UTF8Encoding($false)))
$appSourcePath = Join-Path $appRoot 'src\App.svelte'
$appSource = Get-Content -Raw -LiteralPath $appSourcePath
$appSource = [regex]::Replace($appSource, "(?m)(let currentVersion = ')[^']+(';)", "`${1}$Version`${2}", 1)
[IO.File]::WriteAllText($appSourcePath, $appSource, (New-Object Text.UTF8Encoding($false)))
Write-Host "Decky version set to $Version in npm, Tauri, Cargo, and the browser-preview fallback."