Git Repository

Personal RAG

Personal RAG speichert Texte und strukturierte Fakten lokal in SQLite, durchsucht sie mit FTS5 und stellt sie über MCP per stdio oder Streamable HTTP bereit.

Projektseite ↗
HTTPShttps://zanvex.de/git/personal-rag.git

build.ps1

[CmdletBinding()]
param()

$ErrorActionPreference = 'Stop'

$projectPath = $PSScriptRoot
$distPath = Join-Path $projectPath 'dist'
$expectedDistPath = [System.IO.Path]::GetFullPath((Join-Path $projectPath 'dist'))

if ([System.IO.Path]::GetFullPath($distPath) -ne $expectedDistPath) {
    throw 'Refusing to clean an unexpected dist path.'
}

if (Test-Path -LiteralPath $distPath) {
    Remove-Item -LiteralPath $distPath -Recurse -Force
}
New-Item -ItemType Directory -Path $distPath | Out-Null
$stagingPath = Join-Path $distPath '.staging'
New-Item -ItemType Directory -Path $stagingPath | Out-Null

Write-Host 'Running tests...'
& go test ./...
if ($LASTEXITCODE -ne 0) {
    throw 'Tests failed.'
}

$targets = @(
    @{ OS = 'windows'; Arch = 'amd64'; Extension = '.exe' },
    @{ OS = 'windows'; Arch = 'arm64'; Extension = '.exe' },
    @{ OS = 'linux';   Arch = 'amd64'; Extension = '' },
    @{ OS = 'linux';   Arch = 'arm64'; Extension = '' },
    @{ OS = 'darwin';  Arch = 'amd64'; Extension = '' },
    @{ OS = 'darwin';  Arch = 'arm64'; Extension = '' }
)

$oldGOOS = $env:GOOS
$oldGOARCH = $env:GOARCH
$oldCGOEnabled = $env:CGO_ENABLED

try {
    $env:CGO_ENABLED = '0'
    foreach ($target in $targets) {
        $env:GOOS = $target.OS
        $env:GOARCH = $target.Arch
        $fileName = "personal-rag-$($target.OS)-$($target.Arch)$($target.Extension)"
        $outputPath = Join-Path $stagingPath $fileName
        $archiveName = "personal-rag-$($target.OS)-$($target.Arch).zip"
        $archivePath = Join-Path $distPath $archiveName

        Write-Host "Building $fileName..."
        & go build -trimpath -o $outputPath ./cmd/personal-rag
        if ($LASTEXITCODE -ne 0) {
            throw "Build failed for $($target.OS)/$($target.Arch)."
        }

        Compress-Archive -LiteralPath $outputPath -DestinationPath $archivePath
    }
}
finally {
    $env:GOOS = $oldGOOS
    $env:GOARCH = $oldGOARCH
    $env:CGO_ENABLED = $oldCGOEnabled
    if (Test-Path -LiteralPath $stagingPath) {
        Remove-Item -LiteralPath $stagingPath -Recurse -Force
    }
}

Write-Host "Build complete: $distPath"
Get-ChildItem -LiteralPath $distPath -File | Select-Object Name, Length