|
| 1 | +# Local Release Testing Script |
| 2 | +# This script tests the release process locally before pushing to GitHub |
| 3 | + |
| 4 | +Write-Host "Testing gh-notif release process locally..." -ForegroundColor Green |
| 5 | + |
| 6 | +# Check if GoReleaser is installed |
| 7 | +if (!(Get-Command goreleaser -ErrorAction SilentlyContinue)) { |
| 8 | + Write-Host "[ERROR] GoReleaser not found. Please install it first:" -ForegroundColor Red |
| 9 | + Write-Host " scoop install goreleaser" -ForegroundColor Yellow |
| 10 | + Write-Host " Or download from: https://github.com/goreleaser/goreleaser/releases" -ForegroundColor Yellow |
| 11 | + exit 1 |
| 12 | +} |
| 13 | + |
| 14 | +Write-Host "[OK] GoReleaser found" -ForegroundColor Green |
| 15 | + |
| 16 | +# Clean previous builds |
| 17 | +Write-Host "[INFO] Cleaning previous builds..." -ForegroundColor Blue |
| 18 | +if (Test-Path "dist") { |
| 19 | + Remove-Item -Recurse -Force "dist" |
| 20 | +} |
| 21 | + |
| 22 | +# Test GoReleaser configuration |
| 23 | +Write-Host "[INFO] Checking GoReleaser configuration..." -ForegroundColor Blue |
| 24 | +goreleaser check |
| 25 | +if ($LASTEXITCODE -ne 0) { |
| 26 | + Write-Host "[ERROR] GoReleaser configuration check failed!" -ForegroundColor Red |
| 27 | + exit 1 |
| 28 | +} |
| 29 | +Write-Host "[OK] GoReleaser configuration is valid" -ForegroundColor Green |
| 30 | + |
| 31 | +# Test build process |
| 32 | +Write-Host "[INFO] Testing build process..." -ForegroundColor Blue |
| 33 | +goreleaser build --snapshot --clean |
| 34 | +if ($LASTEXITCODE -ne 0) { |
| 35 | + Write-Host "[ERROR] Build failed!" -ForegroundColor Red |
| 36 | + exit 1 |
| 37 | +} |
| 38 | +Write-Host "[OK] Build successful" -ForegroundColor Green |
| 39 | + |
| 40 | +# List generated files |
| 41 | +Write-Host "[INFO] Generated files:" -ForegroundColor Blue |
| 42 | +if (Test-Path "dist") { |
| 43 | + Get-ChildItem -Recurse "dist" | Select-Object Name, Length | Format-Table |
| 44 | +} |
| 45 | + |
| 46 | +# Test Docker build (if Docker is available) |
| 47 | +if (Get-Command docker -ErrorAction SilentlyContinue) { |
| 48 | + Write-Host "[INFO] Testing Docker build..." -ForegroundColor Blue |
| 49 | + |
| 50 | + # Copy a binary to test Docker build |
| 51 | + $linuxBinary = Get-ChildItem "dist" -Recurse -Filter "*linux_amd64*" | Where-Object { $_.Name -eq "gh-notif" } | Select-Object -First 1 |
| 52 | + if ($linuxBinary) { |
| 53 | + Copy-Item $linuxBinary.FullName "gh-notif" |
| 54 | + docker build -t gh-notif-test . |
| 55 | + if ($LASTEXITCODE -eq 0) { |
| 56 | + Write-Host "[OK] Docker build successful" -ForegroundColor Green |
| 57 | + |
| 58 | + # Test running the Docker image |
| 59 | + Write-Host "[INFO] Testing Docker image..." -ForegroundColor Blue |
| 60 | + docker run --rm gh-notif-test version |
| 61 | + |
| 62 | + # Clean up |
| 63 | + Remove-Item "gh-notif" -ErrorAction SilentlyContinue |
| 64 | + } else { |
| 65 | + Write-Host "[ERROR] Docker build failed!" -ForegroundColor Red |
| 66 | + } |
| 67 | + } else { |
| 68 | + Write-Host "[WARN] No Linux binary found for Docker test" -ForegroundColor Yellow |
| 69 | + } |
| 70 | +} else { |
| 71 | + Write-Host "[WARN] Docker not found, skipping Docker build test" -ForegroundColor Yellow |
| 72 | +} |
| 73 | + |
| 74 | +# Test full release process (without publishing) |
| 75 | +Write-Host "[INFO] Testing full release process (dry run)..." -ForegroundColor Blue |
| 76 | +goreleaser release --snapshot --clean |
| 77 | +if ($LASTEXITCODE -ne 0) { |
| 78 | + Write-Host "[ERROR] Release process failed!" -ForegroundColor Red |
| 79 | + exit 1 |
| 80 | +} |
| 81 | +Write-Host "[OK] Release process successful" -ForegroundColor Green |
| 82 | + |
| 83 | +# Show summary |
| 84 | +Write-Host "`n[SUMMARY] Test Summary:" -ForegroundColor Cyan |
| 85 | +Write-Host "[OK] GoReleaser configuration valid" -ForegroundColor Green |
| 86 | +Write-Host "[OK] Build process working" -ForegroundColor Green |
| 87 | +Write-Host "[OK] Release process working" -ForegroundColor Green |
| 88 | + |
| 89 | +if (Test-Path "dist") { |
| 90 | + $fileCount = (Get-ChildItem -Recurse "dist").Count |
| 91 | + Write-Host "[INFO] Generated $fileCount files in dist/" -ForegroundColor Blue |
| 92 | +} |
| 93 | + |
| 94 | +Write-Host "`n[SUCCESS] All tests passed! Ready to push to GitHub." -ForegroundColor Green |
| 95 | +Write-Host "[INFO] To create a release, run:" -ForegroundColor Yellow |
| 96 | +Write-Host " git tag v1.0.6" -ForegroundColor White |
| 97 | +Write-Host " git push origin v1.0.6" -ForegroundColor White |
0 commit comments