ci(builds): added better logic to building

This commit is contained in:
2025-07-12 14:31:15 -05:00
parent eed01197c0
commit 320968f994
8 changed files with 265 additions and 45 deletions

View File

@@ -1,33 +1,45 @@
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$versionFile = Join-Path $scriptDir "..\VERSION"
$rootDir = Join-Path $scriptDir ".."
$packageJsonPath = Join-Path $rootDir "package.json"
$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"
function Get-PackageVersion {
param (
[string]$packageJsonPath
)
if (-not (Test-Path $packageJsonPath)) {
Write-Warning "package.json not found at $packageJsonPath"
return $null
}
$jsonContent = Get-Content $packageJsonPath -Raw
try {
$json = $jsonContent | ConvertFrom-Json
return $json.version
}
catch {
Write-Warning "Failed to parse package.json: $_"
return $null
}
}
Write-Host "Building release version: $version"
$version = Get-PackageVersion -packageJsonPath $packageJsonPath
Write-Host "Project version from package.json is: $version"
$buildNumberFile = Join-Path $rootDir "BUILD_NUMBER"
Write-Host "`nBuilding Go backend..."
Push-Location ./backend
if (Test-Path $buildNumberFile) {
$buildNumber = Get-Content $buildNumberFile -Raw
$buildNumber = $buildNumber.Trim()
Write-Host "Current build number: $buildNumber"
} else {
Write-Warning "BUILD_NUMBER file not found at $buildNumberFile"
}
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"
$releaseFolder = Join-Path $rootDir "releases"
$zipName = "release-v$version-$buildNumber.zip"
$zipPath = Join-Path $releaseFolder $zipName
@@ -60,7 +72,7 @@ $filesToInclude = @(
"frontend\.tanstack",
"frontend\.output",
"frontend\public",
"VERSION"
"package.json"
)
Compress-Archive -Path $filesToInclude -DestinationPath $zipPath