73 lines
2.4 KiB
PowerShell
73 lines
2.4 KiB
PowerShell
# Local build and push script
|
|
# Usage: .\scripts\deploy\build-and-push.ps1
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
Write-Host "Starting local build and push process..." -ForegroundColor Cyan
|
|
|
|
if (-not (Test-Path "package.json")) {
|
|
Write-Host "Error: Please run this script from project root" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "Cleaning old build artifacts..." -ForegroundColor Yellow
|
|
$distPath = "apps\web-antd\dist"
|
|
if (Test-Path $distPath) {
|
|
Remove-Item -Recurse -Force $distPath
|
|
}
|
|
|
|
if (-not (Test-Path "node_modules")) {
|
|
Write-Host "Installing dependencies..." -ForegroundColor Yellow
|
|
pnpm install
|
|
}
|
|
|
|
Write-Host "Building project..." -ForegroundColor Yellow
|
|
pnpm build:antd
|
|
|
|
if (-not (Test-Path $distPath)) {
|
|
Write-Host "Error: Build failed, dist directory not found" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
$distItems = Get-ChildItem $distPath -ErrorAction SilentlyContinue
|
|
if ($null -eq $distItems) {
|
|
Write-Host "Error: Build failed, dist directory is empty" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
if ($distItems.Count -eq 0) {
|
|
Write-Host "Error: Build failed, dist directory is empty" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "Build successful!" -ForegroundColor Green
|
|
|
|
$buildSize = (Get-ChildItem $distPath -Recurse | Measure-Object -Property Length -Sum).Sum / 1MB
|
|
$buildSizeRounded = [math]::Round($buildSize, 2)
|
|
Write-Host "Build size: $buildSizeRounded MB" -ForegroundColor Cyan
|
|
|
|
$response = Read-Host "Do you want to commit and push to repository? (y/n)"
|
|
if ($response -eq "y" -or $response -eq "Y") {
|
|
$gitStatus = git status --porcelain
|
|
if ($gitStatus) {
|
|
Write-Host "Staging build artifacts..." -ForegroundColor Yellow
|
|
git add -f apps/web-antd/dist
|
|
git add -A
|
|
|
|
Write-Host "Committing changes..." -ForegroundColor Yellow
|
|
git commit -m "chore: build and deploy web-antd [skip ci]" 2>&1 | Out-Null
|
|
|
|
Write-Host "Pushing to repository..." -ForegroundColor Yellow
|
|
git push origin master
|
|
|
|
Write-Host "Build artifacts pushed successfully!" -ForegroundColor Green
|
|
Write-Host "Waiting for CI/CD to deploy..." -ForegroundColor Cyan
|
|
} else {
|
|
Write-Host "No changes to commit" -ForegroundColor Yellow
|
|
}
|
|
} else {
|
|
Write-Host "Skipping git push. You can manually commit and push later." -ForegroundColor Yellow
|
|
}
|
|
|
|
Write-Host "Done!" -ForegroundColor Green
|
|
|