-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.ps1
More file actions
93 lines (79 loc) · 2.94 KB
/
deploy.ps1
File metadata and controls
93 lines (79 loc) · 2.94 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
# TLDRWP Deployment Script
# This script builds the plugin and creates a deployment ZIP file
# Includes only distribution files (matches GitHub Actions workflow)
Write-Host "Starting TLDRWP deployment..." -ForegroundColor Green
# Step 1: Build the plugin
Write-Host "Building plugin assets..." -ForegroundColor Yellow
npm run build
if ($LASTEXITCODE -ne 0) {
Write-Host "Build failed!" -ForegroundColor Red
exit 1
}
# Step 2: Extract version from plugin file
Write-Host "Reading plugin version..." -ForegroundColor Yellow
$pluginContent = Get-Content "tldrwp.php" -Raw
if ($pluginContent -match "Version:\s*([0-9]+\.[0-9]+\.[0-9]+)") {
$version = $matches[1]
Write-Host "Version detected: $version" -ForegroundColor Green
} else {
Write-Host "Could not detect version, using 0.1.0" -ForegroundColor Yellow
$version = "0.1.0"
}
# Step 3: Create deployment directory
$deployDir = "deploy"
$zipName = "tldrwp-v$version.zip"
if (Test-Path $deployDir) {
Remove-Item $deployDir -Recurse -Force
}
New-Item -ItemType Directory -Path $deployDir | Out-Null
# Step 4: Copy files to deployment directory (matching .distignore)
Write-Host "Copying plugin files (excluding development files)..." -ForegroundColor Yellow
# Files and directories to include in distribution (matches what 10up action includes)
$filesToCopy = @(
"admin",
"blocks",
"build", # Built assets from wp-scripts
"includes",
"public",
"LICENSE",
"readme.txt",
"tldrwp.php",
"uninstall.php"
)
$copiedCount = 0
foreach ($item in $filesToCopy) {
if (Test-Path $item) {
try {
if (Test-Path $item -PathType Container) {
Copy-Item $item -Destination $deployDir -Recurse -Force
Write-Host " [OK] Copied directory: $item" -ForegroundColor Green
} else {
Copy-Item $item -Destination $deployDir -Force
Write-Host " [OK] Copied file: $item" -ForegroundColor Green
}
$copiedCount++
} catch {
Write-Host " [ERROR] Error copying $item : $_" -ForegroundColor Red
}
} else {
Write-Host " [WARN] Missing: $item" -ForegroundColor Yellow
}
}
Write-Host " Total items copied: $copiedCount" -ForegroundColor Green
# Step 5: Create ZIP file
Write-Host "Creating ZIP file: $zipName" -ForegroundColor Yellow
Set-Location $deployDir
Compress-Archive -Path * -DestinationPath "../$zipName" -Force
Set-Location ..
# Step 6: Clean up
Remove-Item $deployDir -Recurse -Force
# Step 7: Show results
$zipSize = (Get-Item $zipName).Length
$zipSizeKB = [math]::Round($zipSize / 1KB, 2)
$zipSizeMB = [math]::Round($zipSize / 1MB, 2)
Write-Host ""
Write-Host "Deployment completed successfully!" -ForegroundColor Green
Write-Host "ZIP file: $zipName" -ForegroundColor Cyan
Write-Host "Size: $zipSizeKB KB ($zipSizeMB MB)" -ForegroundColor Cyan
Write-Host "Location: $((Get-Location).Path)\$zipName" -ForegroundColor Cyan
Write-Host ""