-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.ps1
69 lines (53 loc) · 1.61 KB
/
publish.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
[CmdletBinding()]
param (
[Parameter()]
[switch]
$NoBuild,
[Parameter()]
$Server = "pi@dev2",
[switch]
$NoClean = $false,
[switch]
$DebugBuild = $false,
[switch]
$NoSpaBuild = $false
)
$ErrorActionPreference = "Stop"
$Folder = "./publish"
$Project = ".\src\Resona.UI\Resona.UI.csproj"
if (-not (Test-Path $Folder)) {
New-Item $Folder -ItemType Directory
}
$Runtime = "linux-arm"
#>>> Build
if (-not $NoBuild) {
Get-ChildItem $Folder | Remove-Item -Recurse
if ($DebugBuild) {
dotnet publish $Project -o $Folder -r "linux-arm" -c Debug -f net9.0 --self-contained true -p:NoSpaBuild=$NoSpaBuild
}
else {
dotnet publish $Project -o $Folder -r "linux-arm" -c Release -f net9.0 -p:PublishReadyToRun=true `
-p:PublishSingleFile=true -p:PublishTrimmed=false `
--self-contained true -p:IncludeNativeLibrariesForSelfExtract=true `
-p:NoSpaBuild=$NoSpaBuild
}
if (!$?) {
throw "Build failed"
}
}
#>>> Publish Resona
# Create the bin folder, if it doesn't already exist
ssh $Server "mkdir -p ~/bin"
# Disable the service (if installed) so we can replace the executable
ssh $Server "./disable-auto-run.sh"
if ($NoClean) {
scp $(Join-Path $Folder "Resona*") "$($Server):bin"
}
else {
ssh $Server "cd ~/bin && find . -type f ! -name 'resona.db*' ! -path './images/*' | xargs rm -f"
scp -r -p "$($Folder)/*" "$($Server):bin"
}
# Name Resona executable
ssh $Server 'chmod +x ~/bin/Resona'
# Re-enable the service (if installed). This will also auto start the program.
ssh $Server "./reenable-auto-run.sh"