-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
69 lines (58 loc) · 2.63 KB
/
build.ps1
File metadata and controls
69 lines (58 loc) · 2.63 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
param(
[Parameter(Mandatory=$true)]
[Alias("v")]
[string]$Version,
[Parameter(Mandatory=$false)]
[string]$Repo = "Tackyflea/shapey",
[Parameter(Mandatory=$false)]
[string]$BuildPath = "build/windows/x64/runner/Release",
[Parameter(Mandatory=$false)]
[string]$OutputFolder = "releases"
)
# Configuration
$fullVersion = if ($Version.StartsWith("v")) { $Version } else { "v$Version" }
$zipName = "shapey-windows-$fullVersion.zip"
$zipPath = Join-Path $OutputFolder $zipName
Write-Host "`nVersion: $fullVersion" -ForegroundColor Green
Write-Host "Repository: $Repo" -ForegroundColor Green
Write-Host "Output: $zipPath`n" -ForegroundColor Green
if (-not (Test-Path $OutputFolder)) {
Write-Host "Creating output folder: $OutputFolder" -ForegroundColor Yellow
New-Item -ItemType Directory -Path $OutputFolder | Out-Null
}
if (-not (Test-Path $BuildPath)) {
Write-Host "ERROR: Build path not found: $BuildPath" -ForegroundColor Red
Write-Host "Please build your project first or check the path.`n" -ForegroundColor Yellow
exit 1
}
if (Test-Path $zipPath) {
Write-Host "Removing existing archive..." -ForegroundColor Yellow
Remove-Item $zipPath -Force
}
# Create zip archive
Write-Host "Creating archive..." -ForegroundColor Yellow
try {
Compress-Archive -Path "$BuildPath\*" -DestinationPath $zipPath -CompressionLevel Optimal
$zipSize = (Get-Item $zipPath).Length / 1MB
Write-Host "Archive created successfully! Size: $([math]::Round($zipSize, 2)) MB" -ForegroundColor Green
} catch {
Write-Host "ERROR: Failed to create archive" -ForegroundColor Red
Write-Host $_.Exception.Message -ForegroundColor Red
exit 1
}
$Notes = "Release $fullVersion"
Write-Host "`nCreating GitHub release..." -ForegroundColor Yellow
try {
gh release create $fullVersion $zipPath -R $Repo --notes $Notes --generate-notes=false
Write-Host "`nSUCCESS! Release created successfully!" -ForegroundColor Green
Write-Host "View at: https://github.com/$Repo/releases/tag/$fullVersion" -ForegroundColor Cyan
Write-Host "Local copy: $zipPath" -ForegroundColor Cyan
Write-Host "`nNote: GitHub auto-generates source code archives." -ForegroundColor Yellow
Write-Host "Your build is: shapey-live-windows-$fullVersion.zip`n" -ForegroundColor Yellow
} catch {
Write-Host "ERROR: Failed to create GitHub release" -ForegroundColor Red
Write-Host $_.Exception.Message -ForegroundColor Red
Write-Host "`nThe zip file was created but the release failed." -ForegroundColor Yellow
Write-Host "You can manually upload it or fix the error and retry.`n" -ForegroundColor Yellow
exit 1
}