Repository navigation
Expand file tree
/
Copy pathrelease.ps1
More file actions
68 lines (57 loc) · 1.58 KB
/
Copy pathrelease.ps1
File metadata and controls
68 lines (57 loc) · 1.58 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
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$repoRoot = Resolve-Path $PSScriptRoot
Set-Location $repoRoot
$version = (Get-Content (Join-Path $repoRoot "VERSION") -Raw).Trim()
if ([string]::IsNullOrWhiteSpace($version)) {
throw "VERSION is empty."
}
$tag = "v$version"
$windowsAsset = Join-Path $repoRoot "dist\SleekCodeBrowser-Setup-$version.exe"
$ubuntuAsset = Join-Path $repoRoot "dist\sleek-code-browser_${version}_amd64.deb"
if ((git status --porcelain).Trim().Length -gt 0) {
git add .
try {
git commit -m "Release $tag"
}
catch {
Write-Host "No commit created (possibly no staged diff after add)."
}
}
git push origin main
try {
git rev-parse $tag | Out-Null
}
catch {
git tag $tag
}
git push origin $tag
if (-not (Get-Command gh -ErrorAction SilentlyContinue)) {
Write-Host "gh CLI not found; skipping direct release creation."
exit 0
}
$assets = @()
if (Test-Path $windowsAsset) { $assets += $windowsAsset }
if (Test-Path $ubuntuAsset) { $assets += $ubuntuAsset }
$releaseExists = $true
try {
gh release view $tag | Out-Null
}
catch {
$releaseExists = $false
}
if ($releaseExists) {
if ($assets.Count -gt 0) {
gh release upload $tag $assets --clobber
}
gh release edit $tag --title "Sleek Code Browser $tag" --latest
}
else {
if ($assets.Count -gt 0) {
gh release create $tag --title "Sleek Code Browser $tag" --notes "Release $tag" $assets
}
else {
gh release create $tag --title "Sleek Code Browser $tag" --notes "Release $tag"
}
gh release edit $tag --latest
}