feat(starter): intial starter release
This commit is contained in:
68
scripts/release.ps1
Normal file
68
scripts/release.ps1
Normal file
@@ -0,0 +1,68 @@
|
||||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$versionFile = Join-Path $scriptDir "..\VERSION"
|
||||
$env:GOOS = "windows"
|
||||
$env:GOARCH = "amd64"
|
||||
$keepReleases = 10
|
||||
|
||||
if (Test-Path $versionFile) {
|
||||
$version = Get-Content $versionFile -Raw | ForEach-Object { $_.Trim() }
|
||||
Write-Host "Project version: $version"
|
||||
} else {
|
||||
Write-Host "VERSION file not found at $versionFile"
|
||||
}
|
||||
|
||||
Write-Host "Building release version: $version"
|
||||
|
||||
Write-Host "`nBuilding Go backend..."
|
||||
Push-Location ./backend
|
||||
|
||||
go build -ldflags "-X main.version=$version" -o lst_backend.exe ./main.go
|
||||
Pop-Location
|
||||
|
||||
Write-Host "`nBuilding frontend..."
|
||||
Push-Location ./frontend
|
||||
npm install
|
||||
npm run build
|
||||
Pop-Location
|
||||
|
||||
|
||||
$releaseFolder = Join-Path $scriptDir "releases"
|
||||
$zipName = "release-$version.zip"
|
||||
$zipPath = Join-Path $releaseFolder $zipName
|
||||
|
||||
|
||||
if (-not (Test-Path $releaseFolder)) {
|
||||
New-Item -ItemType Directory -Path $releaseFolder | Out-Null
|
||||
}
|
||||
|
||||
# Remove zip if it already exists
|
||||
if (Test-Path $zipPath) {
|
||||
Write-Host "Removing existing zip: $zipPath"
|
||||
Remove-Item $zipPath -Force
|
||||
}
|
||||
|
||||
# Clean up older release files (keep only newest X)
|
||||
$existingZips = Get-ChildItem -Path $releaseFolder -Filter "release-*.zip" | Sort-Object LastWriteTime -Descending
|
||||
|
||||
if ($existingZips.Count -gt $keepReleases) {
|
||||
$toRemove = $existingZips | Select-Object -Skip $keepReleases
|
||||
foreach ($file in $toRemove) {
|
||||
Write-Host "Deleting old release: $($file.Name)"
|
||||
Remove-Item $file.FullName -Force
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "`nPackaging release: $($zipName)"
|
||||
|
||||
$filesToInclude = @(
|
||||
"backend\lst_backend.exe",
|
||||
"frontend\.nitro",
|
||||
"frontend\.tanstack",
|
||||
"frontend\.output",
|
||||
"frontend\public",
|
||||
"VERSION"
|
||||
)
|
||||
|
||||
Compress-Archive -Path $filesToInclude -DestinationPath $zipPath
|
||||
|
||||
Write-Host "`nRelease package created at: $($zipPath)"
|
||||
Reference in New Issue
Block a user