forked from HeidiSQL/HeidiSQL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-update.ps1
More file actions
76 lines (62 loc) · 2.99 KB
/
Copy pathdeploy-update.ps1
File metadata and controls
76 lines (62 loc) · 2.99 KB
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
70
71
72
73
74
75
76
param(
[switch]$Mandatory,
[string]$Notes = "Correcoes da versao CSLOG."
)
$ErrorActionPreference = "Stop"
# ── Configuration ──────────────────────────────────────────────────
$RemoteUser = "cslog"
$RemoteHost = "192.168.20.11"
$RemotePort = "2225"
$RemoteDir = "/home/cslog/heidisql_bin"
$ExePath = "D:\git\HeidiSQL\out\heidisql64.exe"
$RepoDir = "D:\git\HeidiSQL"
$Filename = "heidisql64.exe"
$Channel = "stable"
# ── Validate exe exists ───────────────────────────────────────────
if (-not (Test-Path $ExePath)) {
Write-Error "$ExePath not found. Run build.bat first."
exit 1
}
# ── Extract version from exe ──────────────────────────────────────
$vi = (Get-Item $ExePath).VersionInfo
$Version = $vi.FileVersionRaw.ToString()
$Revision = $vi.FilePrivatePart
if (-not $Version -or $Version -eq "0.0.0.0") {
Write-Error "Could not read version from $ExePath"
exit 1
}
# ── Get git commit ────────────────────────────────────────────────
$Commit = git -c safe.directory=$RepoDir -C $RepoDir rev-parse --short HEAD
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to get git commit hash."
exit 1
}
# ── Compute SHA-256 ───────────────────────────────────────────────
$Sha256 = (Get-FileHash -Algorithm SHA256 $ExePath).Hash.ToLower()
# ── Generate manifest.json ────────────────────────────────────────
$ManifestPath = Join-Path (Split-Path $ExePath) "manifest.json"
$manifest = @{
enabled = $true
channel = $Channel
version = $Version
revision = [int]$Revision
commit = $Commit
filename = $Filename
package_type = "exe"
sha256 = $Sha256
mandatory = [bool]$Mandatory
release_notes = $Notes
} | ConvertTo-Json -Depth 1
[System.IO.File]::WriteAllText($ManifestPath, $manifest, (New-Object System.Text.UTF8Encoding $false))
Write-Host "── manifest.json ──" -ForegroundColor Cyan
Write-Host $manifest
Write-Host ""
# ── Deploy to server ──────────────────────────────────────────────
Write-Host "Uploading $Filename + manifest.json to ${RemoteHost}:${RemoteDir} ..." -ForegroundColor Cyan
scp -P $RemotePort $ExePath $ManifestPath "${RemoteUser}@${RemoteHost}:${RemoteDir}/"
if ($LASTEXITCODE -ne 0) {
Write-Error "SCP failed."
exit 1
}
Write-Host ""
Write-Host "Done. Version $Version (rev $Revision, commit $Commit) deployed." -ForegroundColor Green