-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-release.ps1
More file actions
303 lines (261 loc) · 11.6 KB
/
Copy pathbuild-release.ps1
File metadata and controls
303 lines (261 loc) · 11.6 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
# SimpleUnitFrames Release Build Script
# Builds a release archive with all addon files, README, and bundled PerformanceLib
#
# Usage:
# .\build-release.ps1 -Version 1.26.0 -BuildDir ".\releases"
# .\build-release.ps1 -Version 1.26.0 -PerformanceLibPath "C:\path\to\PerformanceLib"
# .\build-release.ps1 -SkipPerformanceLib
#
# Parameters:
# -Version Release version (default: 1.26.0)
# -BuildDir Output directory for zip (default: .\releases)
# -OutputPath Explicit zip file path
# -PerformanceLibPath Custom path to PerformanceLib addon (auto-detected by default)
# -SkipPerformanceLib Skip bundling PerformanceLib (optional dep)
param(
[string]$Version = "1.26.0",
[string]$BuildDir = ".\releases",
[string]$OutputPath = $null,
[string]$PerformanceLibPath = $null,
[switch]$SkipPerformanceLib = $false
)
$ErrorActionPreference = "Stop"
# Paths
$RootDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$SUFDir = $RootDir
$WorkspaceRoot = Split-Path $RootDir
$TempBuild = Join-Path $env:TEMP "SUF-Release-$Version"
$ZipPath = if ($OutputPath) { $OutputPath } else { Join-Path $BuildDir "SimpleUnitFrames-$Version.zip" }
# Determine PerformanceLib path
$PerfLibDir = $null
# 1. Use explicit path if provided
if ($PerformanceLibPath -and (Test-Path $PerformanceLibPath)) {
$PerfLibDir = $PerformanceLibPath
Write-Host "Using PerformanceLib from explicitly provided path" -ForegroundColor Green
}
# 2. Check adjacent directory (default)
elseif (Test-Path (Join-Path $WorkspaceRoot "PerformanceLib")) {
$PerfLibDir = Join-Path $WorkspaceRoot "PerformanceLib"
}
# 3. Check workspace root for /PerformanceLib
elseif (Test-Path (Join-Path $WorkspaceRoot ".." "PerformanceLib")) {
$PerfLibDir = Join-Path $WorkspaceRoot ".." "PerformanceLib"
}
# 4. Search current workspace root
elseif (Test-Path "$WorkspaceRoot/PerformanceLib") {
$PerfLibDir = "$WorkspaceRoot/PerformanceLib"
}
# 5. If still not found and not skipping, try to find it anywhere in parent directories
if (-not $PerfLibDir -and -not $SkipPerformanceLib) {
$SearchPath = $WorkspaceRoot
for ($i = 0; $i -lt 3; $i++) {
$TestPath = Join-Path $SearchPath "PerformanceLib"
if (Test-Path $TestPath) {
$PerfLibDir = $TestPath
break
}
$SearchPath = Split-Path $SearchPath
}
}
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Cyan
Write-Host "SimpleUnitFrames Release Builder" -ForegroundColor Cyan
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Cyan
Write-Host ""
Write-Host "📦 Version: $Version" -ForegroundColor Yellow
Write-Host "📁 Root: $RootDir" -ForegroundColor Yellow
Write-Host "🎯 Output: $ZipPath" -ForegroundColor Yellow
Write-Host ""
# Clean and create temp directory
if (Test-Path $TempBuild) {
Remove-Item $TempBuild -Recurse -Force
Write-Host "✓ Cleaned existing temp build directory" -ForegroundColor Green
}
New-Item -ItemType Directory -Path $TempBuild | Out-Null
Write-Host "✓ Created temp build directory: $TempBuild" -ForegroundColor Green
# Function to copy addon files (excluding .git*, docs, workspaces, etc.)
function Copy-AddonFiles {
param([string]$SourceDir, [string]$DestDir, [string]$AddonName)
Write-Host ""
Write-Host "📌 Copying $AddonName addon files..." -ForegroundColor Cyan
$ExcludePatterns = @(
'.git',
'.github',
'.vscode',
'.agents',
'.claude',
'.gitignore',
'docs',
'scripts',
'releases',
'*.code-workspace',
'*.tgz',
'*.zip',
'*.ps1',
'test_*',
'node_modules',
'__pycache__',
'COMMIT_MESSAGE.txt',
'CLAUDE.md',
'API_VALIDATION_REPORT.md',
'RESEARCH.md',
'WORK_SUMMARY.md',
'TODO.md',
'LIBQTIP_*',
'PHASE*',
'README.workspace.md',
'MIGRAT*'
)
$CopyCount = 0
Get-ChildItem -Path $SourceDir -Recurse | ForEach-Object {
$RelativePath = $_.FullName.Substring($SourceDir.Length + 1)
$IsExcluded = $false
# Check if any parent directory (or this directory) is in the exclusion list
$RelativeParts = $RelativePath -split '\\'
foreach ($part in $RelativeParts) {
# Check if this part starts with a dot (catches .agents, .claude, .github, etc.)
if ($part -like '.*') {
$IsExcluded = $true
break
}
# Check against exclusion patterns
foreach ($pattern in $ExcludePatterns) {
if ($part -like $pattern) {
$IsExcluded = $true
break
}
}
if ($IsExcluded) { break }
}
# Special case: In root directory, only keep README.md (exclude all other .md files)
if (-not $IsExcluded -and $_ -is [System.IO.FileInfo]) {
if (-not $RelativePath.Contains('\')) { # Root level file only
if ($_.Extension -eq '.md' -and $_.Name -ne 'README.md') {
$IsExcluded = $true
}
}
}
if (-not $IsExcluded) {
$DestPath = Join-Path $DestDir $RelativePath
if ($_ -is [System.IO.DirectoryInfo]) {
New-Item -ItemType Directory -Path $DestPath -Force | Out-Null
}
else {
New-Item -ItemType Directory -Path (Split-Path $DestPath) -Force | Out-Null
Copy-Item -Path $_.FullName -Destination $DestPath -Force
$CopyCount++
}
}
}
Write-Host " → Copied $CopyCount files from $AddonName" -ForegroundColor Green
return $CopyCount
}
# Copy SimpleUnitFrames files
$SUFPath = Join-Path $TempBuild "SimpleUnitFrames"
New-Item -ItemType Directory -Path $SUFPath | Out-Null
$SUFCount = Copy-AddonFiles -SourceDir $SUFDir -DestDir $SUFPath -AddonName "SimpleUnitFrames"
# Copy README.md specifically (even if it's in docs exclusion logic)
$ReadmePath = Join-Path $SUFDir "README.md"
if (Test-Path $ReadmePath) {
Copy-Item -Path $ReadmePath -Destination (Join-Path $SUFPath "README.md") -Force
Write-Host " → Included README.md" -ForegroundColor Green
}
# Copy PerformanceLib if it exists or can be found
if (-not $SkipPerformanceLib) {
if ($PerfLibDir -and (Test-Path $PerfLibDir)) {
Write-Host ""
Write-Host "📌 Bundling PerformanceLib addon..." -ForegroundColor Cyan
Write-Host " → Found at: $PerfLibDir" -ForegroundColor Gray
$PerfPath = Join-Path $TempBuild "PerformanceLib"
New-Item -ItemType Directory -Path $PerfPath | Out-Null
$PerfCount = Copy-AddonFiles -SourceDir $PerfLibDir -DestDir $PerfPath -AddonName "PerformanceLib"
# Copy PerformanceLib README if exists
$PerfReadme = Join-Path $PerfLibDir "README.md"
if (Test-Path $PerfReadme) {
Copy-Item -Path $PerfReadme -Destination (Join-Path $PerfPath "README.md") -Force
Write-Host " → Included PerformanceLib README.md" -ForegroundColor Green
}
}
else {
Write-Host ""
Write-Host "⚠️ PerformanceLib not found (optional - continuing without bundling)" -ForegroundColor Yellow
if (-not $SkipPerformanceLib) {
Write-Host " Searched locations:" -ForegroundColor Yellow
Write-Host " • $WorkspaceRoot/PerformanceLib" -ForegroundColor Gray
Write-Host " • $(Join-Path $WorkspaceRoot ".." "PerformanceLib")" -ForegroundColor Gray
Write-Host ""
Write-Host " To specify custom path: .\build-release.ps1 -PerformanceLibPath 'C:\path\to\PerformanceLib'" -ForegroundColor Yellow
Write-Host " To skip bundling: .\build-release.ps1 -SkipPerformanceLib" -ForegroundColor Yellow
}
}
}
else {
Write-Host ""
Write-Host "⏭️ PerformanceLib bundling skipped (-SkipPerformanceLib flag)" -ForegroundColor Yellow
}
# Create build info file
Write-Host ""
Write-Host "📝 Creating build info..." -ForegroundColor Cyan
$BuildInfo = @"
SimpleUnitFrames Release v$Version
Built: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')
## Contents
- **SimpleUnitFrames/** - Main addon with complete functionality
- **PerformanceLib/** - Optional performance library (bundled for convenience)
- **README.md** - Installation and usage guide (in SimpleUnitFrames dir)
## Installation
1. Extract this archive to your World of Warcraft Interface/Addons directory
```
WorldOfWarcraft\_retail_\Interface\AddOns\
```
2. Both SimpleUnitFrames and PerformanceLib will be loaded as separate addons
3. Launch WoW and enable addons in the addon list
## Usage
- **/suf** - Open main options
- **/suf test** - Open interactive test panel
- **/sufperf** - Toggle performance dashboard (requires PerformanceLib)
- **/SUFprofile start|stop|analyze** - Performance profiling
## Requirements
- World of Warcraft Retail (Patch 12.0.0+)
- PerformanceLib (optional, bundled)
## Documentation
See SimpleUnitFrames/README.md for complete documentation.
"@
$BuildInfo | Out-File -FilePath (Join-Path $TempBuild "BUILD_INFO.txt") -Encoding UTF8
Write-Host " → Created BUILD_INFO.txt" -ForegroundColor Green
# Create zip archive
Write-Host ""
Write-Host "📦 Creating release archive..." -ForegroundColor Cyan
# Ensure output directory exists
$Output = Split-Path $ZipPath
if (-not (Test-Path $Output)) {
New-Item -ItemType Directory -Path $Output -Force | Out-Null
}
# Remove existing zip if present
if (Test-Path $ZipPath) {
Remove-Item $ZipPath -Force
}
# Create zip using .NET compression
$CompressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
$null = [System.IO.Compression.ZipFile]::CreateFromDirectory($TempBuild, $ZipPath, $CompressionLevel, $false)
$ZipSize = (Get-Item $ZipPath).Length / 1MB
Write-Host " → Created: $(Split-Path $ZipPath -Leaf)" -ForegroundColor Green
Write-Host " → Size: $([math]::Round($ZipSize, 2)) MB" -ForegroundColor Green
# Cleanup temp
Write-Host ""
Write-Host "🧹 Cleaning up temp files..." -ForegroundColor Cyan
Remove-Item $TempBuild -Recurse -Force
Write-Host " → Removed temp build directory" -ForegroundColor Green
# Summary
Write-Host ""
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Green
Write-Host "✅ Release Archive Created Successfully!" -ForegroundColor Green
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Green
Write-Host ""
Write-Host "📦 Archive: $ZipPath" -ForegroundColor Yellow
Write-Host "💾 Size: $([math]::Round($ZipSize, 2)) MB" -ForegroundColor Yellow
Write-Host ""
Write-Host "📋 To distribute this release:" -ForegroundColor Cyan
Write-Host " • Share the .zip file with users" -ForegroundColor Gray
Write-Host " • They extract to: Interface\AddOns\" -ForegroundColor Gray
Write-Host " • Both addons will auto-load" -ForegroundColor Gray
Write-Host ""