Harden hosted deploy script

This commit is contained in:
2026-07-12 12:17:35 -05:00
parent 6559295a64
commit 2fce849666
7 changed files with 32 additions and 13 deletions
+4
View File
@@ -1,5 +1,9 @@
# Changelog # Changelog
## 0.1.24 - 2026-07-12
- Fixed the hosted deploy script to use a separate `dist-hosted` output, user-writable remote runtime paths, reliable WSL path conversion, explicit rsync/PM2 failure checks, and rsynced deploy metadata.
## 0.1.23 - 2026-07-12 ## 0.1.23 - 2026-07-12
- Added the hosted web build path for the private online alpha. - Added the hosted web build path for the private online alpha.
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "libre-study", "name": "libre-study",
"version": "0.1.23", "version": "0.1.24",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "libre-study", "name": "libre-study",
"version": "0.1.23", "version": "0.1.24",
"dependencies": { "dependencies": {
"@tauri-apps/api": "^2.11.1", "@tauri-apps/api": "^2.11.1",
"react": "^19.2.7", "react": "^19.2.7",
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "libre-study", "name": "libre-study",
"private": true, "private": true,
"version": "0.1.23", "version": "0.1.24",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite --host 127.0.0.1", "dev": "vite --host 127.0.0.1",
+22 -7
View File
@@ -1,16 +1,21 @@
param( param(
[string]$HostName = "christunscripted", [string]$HostName = "christunscripted",
[string]$RemoteRoot = "/sites/libre-study", [string]$RemoteRoot = "/home/jbird/libre-study",
[string]$RemoteBibleDataRoot = "/sites/libre-bible-data/packages/json", [string]$RemoteBibleDataRoot = "/home/jbird/libre-bible-data/packages/json",
[int]$Port = 9174 [int]$Port = 9174
) )
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
function ConvertTo-WslPath([string]$Path) {
$resolved = (Resolve-Path $Path).Path.Replace("\", "/")
return (wsl wslpath -a "$resolved").Trim()
}
$repoRoot = Split-Path -Parent $PSScriptRoot $repoRoot = Split-Path -Parent $PSScriptRoot
$dataRepo = Resolve-Path (Join-Path $repoRoot "..\libre-bible-data") $dataRepo = Resolve-Path (Join-Path $repoRoot "..\libre-bible-data")
$repoRootWsl = (wsl wslpath -a "$repoRoot").Trim() $repoRootWsl = ConvertTo-WslPath $repoRoot
$dataRepoWsl = (wsl wslpath -a "$dataRepo").Trim() $dataRepoWsl = ConvertTo-WslPath $dataRepo
$commit = (git -C $repoRoot rev-parse HEAD).Trim() $commit = (git -C $repoRoot rev-parse HEAD).Trim()
$deployedAt = (Get-Date).ToUniversalTime().ToString("o") $deployedAt = (Get-Date).ToUniversalTime().ToString("o")
@@ -33,12 +38,20 @@ $deployInfo = @{
deployedAt = $deployedAt deployedAt = $deployedAt
source = "libre-study" source = "libre-study"
} | ConvertTo-Json -Compress } | ConvertTo-Json -Compress
$deployInfoPath = Join-Path $env:TEMP "libre-study-deploy-info.json"
Set-Content -Path $deployInfoPath -Value $deployInfo -NoNewline
$deployInfoPathWsl = ConvertTo-WslPath $deployInfoPath
$escapedDeployInfo = $deployInfo.Replace("'", "'\''") wsl ssh $HostName "mkdir -p '$RemoteRoot/app' '$RemoteRoot/server' '$RemoteRoot/state' '$RemoteBibleDataRoot'"
wsl ssh $HostName "mkdir -p '$RemoteRoot/app' '$RemoteRoot/server' '$RemoteRoot/state' '$RemoteBibleDataRoot' && printf '%s' '$escapedDeployInfo' > '$RemoteRoot/deploy-info.json'" if ($LASTEXITCODE -ne 0) { throw "Remote directory preparation failed." }
wsl rsync -az "$deployInfoPathWsl" "${HostName}:$RemoteRoot/deploy-info.json"
if ($LASTEXITCODE -ne 0) { throw "Deploy info rsync failed." }
wsl rsync -az --delete "$repoRootWsl/dist-hosted/" "${HostName}:$RemoteRoot/app/" wsl rsync -az --delete "$repoRootWsl/dist-hosted/" "${HostName}:$RemoteRoot/app/"
if ($LASTEXITCODE -ne 0) { throw "App rsync failed." }
wsl rsync -az --delete "$repoRootWsl/server/" "${HostName}:$RemoteRoot/server/" wsl rsync -az --delete "$repoRootWsl/server/" "${HostName}:$RemoteRoot/server/"
if ($LASTEXITCODE -ne 0) { throw "Server rsync failed." }
wsl rsync -az --delete "$dataRepoWsl/packages/json/" "${HostName}:$RemoteBibleDataRoot/" wsl rsync -az --delete "$dataRepoWsl/packages/json/" "${HostName}:$RemoteBibleDataRoot/"
if ($LASTEXITCODE -ne 0) { throw "LibreBible rsync failed." }
$pm2Command = @" $pm2Command = @"
cd '$RemoteRoot' && cd '$RemoteRoot' &&
@@ -51,4 +64,6 @@ pm2 save
"@ "@
wsl ssh $HostName $pm2Command wsl ssh $HostName $pm2Command
Write-Output "Deployed Libre Study web commit $commit to $HostName:$RemoteRoot on port $Port." if ($LASTEXITCODE -ne 0) { throw "PM2 start/restart failed." }
Remove-Item $deployInfoPath -Force -ErrorAction SilentlyContinue
Write-Output "Deployed Libre Study web commit $commit to ${HostName}:$RemoteRoot on port $Port."
+1 -1
View File
@@ -77,7 +77,7 @@ checksum = "2a4385e2e34eb35d6b3efe798b9eb88096925d87726c0798709bf56d9ed84af3"
[[package]] [[package]]
name = "app" name = "app"
version = "0.1.23" version = "0.1.24"
dependencies = [ dependencies = [
"log", "log",
"rusqlite", "rusqlite",
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "app" name = "app"
version = "0.1.23" version = "0.1.24"
description = "A Tauri App" description = "A Tauri App"
authors = ["you"] authors = ["you"]
license = "" license = ""
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json", "$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "Libre Study", "productName": "Libre Study",
"version": "0.1.23", "version": "0.1.24",
"identifier": "org.librestudy.desktop", "identifier": "org.librestudy.desktop",
"build": { "build": {
"frontendDist": "../dist", "frontendDist": "../dist",