Добавлены скрипты сборки для кроссплатформенных двоичных файлов и лицензия GPL.

- Добавлен файл LICENSE с лицензией GNU General Public License версии 3.0.
- Создан скрипт PowerShell (build-all.ps1) для сборки двоичных файлов Windows и Linux из Windows с использованием кросс-компиляции.
- Разработан скрипт сборки Linux (build-linux.sh) для сборки двоичных файлов Linux.
- Реализован скрипт PowerShell (build-windows.ps1) для сборки двоичных файлов Windows.
- Каждый скрипт сборки включает упаковку и генерацию контрольной суммы SHA256 для двоичных файлов.
This commit is contained in:
Dmitriy Fofanov
2025-11-05 13:05:49 +03:00
parent 77af408c9e
commit eee9a4a093
33 changed files with 1091 additions and 126 deletions

80
scripts/build-windows.ps1 Normal file
View File

@@ -0,0 +1,80 @@
# PowerShell script for building Windows binaries
# Usage: .\scripts\build-windows.ps1
# Exit on error
$ErrorActionPreference = "Stop"
# Read version from VERSION file
$VERSION = Get-Content -Path "VERSION" -Raw
$VERSION = $VERSION.Trim()
$BINARY = "compress"
$OUTPUT_DIR = "dist"
Write-Host "Building compress $VERSION for Windows..." -ForegroundColor Green
# Create output directory if it doesn't exist
if (-Not (Test-Path $OUTPUT_DIR)) {
New-Item -ItemType Directory -Path $OUTPUT_DIR | Out-Null
}
# Build for Windows amd64
Write-Host "`nBuilding Windows amd64..." -ForegroundColor Cyan
$env:CGO_ENABLED = "0"
$env:GOOS = "windows"
$env:GOARCH = "amd64"
go build -ldflags "-s -w" -o "$OUTPUT_DIR\${BINARY}-windows-amd64.exe" .\cmd
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to build Windows amd64"
exit 1
}
# Build for Windows arm64
Write-Host "Building Windows arm64..." -ForegroundColor Cyan
$env:GOOS = "windows"
$env:GOARCH = "arm64"
go build -ldflags "-s -w" -o "$OUTPUT_DIR\${BINARY}-windows-arm64.exe" .\cmd
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to build Windows arm64"
exit 1
}
Write-Host "`nPackaging Windows releases..." -ForegroundColor Green
# Package Windows amd64
Write-Host "Packaging Windows amd64..." -ForegroundColor Cyan
$tempDir = New-Item -ItemType Directory -Path "$OUTPUT_DIR\temp-windows-amd64" -Force
Copy-Item "$OUTPUT_DIR\${BINARY}-windows-amd64.exe" "$tempDir\${BINARY}.exe"
Copy-Item "LICENSE" "$tempDir\" -ErrorAction SilentlyContinue
Copy-Item "README.md" "$tempDir\" -ErrorAction SilentlyContinue
Copy-Item "config.yaml.example" "$tempDir\" -ErrorAction SilentlyContinue
Compress-Archive -Path "$tempDir\*" -DestinationPath "$OUTPUT_DIR\${BINARY}-${VERSION}-windows-amd64.zip" -Force
Remove-Item $tempDir -Recurse -Force
# Package Windows arm64
Write-Host "Packaging Windows arm64..." -ForegroundColor Cyan
$tempDir = New-Item -ItemType Directory -Path "$OUTPUT_DIR\temp-windows-arm64" -Force
Copy-Item "$OUTPUT_DIR\${BINARY}-windows-arm64.exe" "$tempDir\${BINARY}.exe"
Copy-Item "LICENSE" "$tempDir\" -ErrorAction SilentlyContinue
Copy-Item "README.md" "$tempDir\" -ErrorAction SilentlyContinue
Copy-Item "config.yaml.example" "$tempDir\" -ErrorAction SilentlyContinue
Compress-Archive -Path "$tempDir\*" -DestinationPath "$OUTPUT_DIR\${BINARY}-${VERSION}-windows-arm64.zip" -Force
Remove-Item $tempDir -Recurse -Force
Write-Host "`nGenerating SHA256 checksums..." -ForegroundColor Green
# Generate SHA256 checksums
Get-FileHash "$OUTPUT_DIR\${BINARY}-${VERSION}-windows-amd64.zip" -Algorithm SHA256 |
Select-Object -ExpandProperty Hash |
Out-File "$OUTPUT_DIR\${BINARY}-${VERSION}-windows-amd64.zip.sha256" -Encoding ASCII
Get-FileHash "$OUTPUT_DIR\${BINARY}-${VERSION}-windows-arm64.zip" -Algorithm SHA256 |
Select-Object -ExpandProperty Hash |
Out-File "$OUTPUT_DIR\${BINARY}-${VERSION}-windows-arm64.zip.sha256" -Encoding ASCII
Write-Host "`nBuild complete! Artifacts:" -ForegroundColor Green
Write-Host " - $OUTPUT_DIR\${BINARY}-${VERSION}-windows-amd64.zip" -ForegroundColor Yellow
Write-Host " - $OUTPUT_DIR\${BINARY}-${VERSION}-windows-amd64.zip.sha256" -ForegroundColor Yellow
Write-Host " - $OUTPUT_DIR\${BINARY}-${VERSION}-windows-arm64.zip" -ForegroundColor Yellow
Write-Host " - $OUTPUT_DIR\${BINARY}-${VERSION}-windows-arm64.zip.sha256" -ForegroundColor Yellow
Write-Host "`nDone!" -ForegroundColor Green