From 4c7690c270c3aa4ed188926cb39c19dbc37c19c4 Mon Sep 17 00:00:00 2001 From: Ralf-Peter Wolff Date: Mon, 11 May 2026 09:04:15 +0200 Subject: [PATCH] Fix: install Go 1.26.3 directly, use GOTOOLCHAIN=local (no runtime download) --- build-windows.ps1 | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/build-windows.ps1 b/build-windows.ps1 index 80f884e..24496c0 100644 --- a/build-windows.ps1 +++ b/build-windows.ps1 @@ -42,37 +42,49 @@ function Download-File($url, $dest) { } # 1. Go pruefen / als ZIP installieren (kein MSI = kein Exit 1603) -Write-Host "[1/3] Pruefe Go..." -$goRoot = "C:\Go" -$goExe = "$goRoot\bin\go.exe" +# upterm benoetigt Go >= 1.26 - direkt richtige Version installieren +Write-Host "[1/3] Pruefe Go (benoetigt >= 1.26)..." +$goRoot = "C:\Go" +$goExe = "$goRoot\bin\go.exe" +$goVersion = "1.26.3" -if (-not (Test-Path $goExe)) { - $goVersion = "1.22.4" - $goZip = "C:\Windows\Temp\go-windows.zip" - $goUrl = "https://golang.org/dl/go$goVersion.windows-amd64.zip" +$needsInstall = $true +if (Test-Path $goExe) { + $verLine = (& $goExe version 2>&1).ToString() + if ($verLine -match 'go(\d+)\.(\d+)') { + $major = [int]$Matches[1]; $minor = [int]$Matches[2] + if ($major -gt 1 -or ($major -eq 1 -and $minor -ge 26)) { + $needsInstall = $false + Write-Host " OK ($verLine)" + } else { + Write-Host " Go $major.$minor zu alt - aktualisiere auf $goVersion..." + Remove-Item -Recurse -Force $goRoot -ErrorAction SilentlyContinue + } + } +} - Write-Host " Go nicht gefunden - lade go$goVersion (ZIP) herunter..." +if ($needsInstall) { + $goZip = "C:\Windows\Temp\go-windows.zip" + $goUrl = "https://golang.org/dl/go$goVersion.windows-amd64.zip" + Write-Host " Lade go$goVersion (ZIP) herunter..." if (-not (Download-File $goUrl $goZip)) { Read-Host "Enter zum Beenden"; exit 1 } - Write-Host " Entpacke nach $goRoot ..." if (Test-Path $goRoot) { Remove-Item -Recurse -Force $goRoot } Expand-Archive -Path $goZip -DestinationPath "C:\" -Force Remove-Item $goZip -ErrorAction SilentlyContinue - if (-not (Test-Path $goExe)) { Write-Host "FEHLER: go.exe nach Entpacken nicht gefunden." Read-Host "Enter zum Beenden"; exit 1 } + Write-Host " OK (go$goVersion installiert)" } # Go in PATH dieser Session if ($env:PATH -notlike "*$goRoot\bin*") { $env:PATH = "$env:PATH;$goRoot\bin" } -$goVer = & $goExe version 2>&1 -Write-Host " OK ($goVer)" # 2. upterm bauen via Quellcode-ZIP # (go install erlaubt keine replace-Direktiven in externen Modulen) @@ -104,7 +116,7 @@ $env:TMP = "C:\GoTemp" $env:GOCACHE = "C:\GoCache" $env:GOTMPDIR = "C:\GoTemp" Push-Location $repoDir -$env:GOTOOLCHAIN = "auto" +$env:GOTOOLCHAIN = "local" & $goExe build -o "$env:GOPATH\bin\upterm.exe" ./cmd/upterm 2>&1 | ForEach-Object { Write-Host " $_" } $buildExit = $LASTEXITCODE Pop-Location