diff --git a/tools/publish.ps1 b/tools/publish.ps1 new file mode 100644 index 0000000000..452a0c45e1 --- /dev/null +++ b/tools/publish.ps1 @@ -0,0 +1,185 @@ +# publish.ps1 — Build, package, and upload TINQSEngine (Godot fork) to S3 +# +# Usage: +# .\tools\publish.ps1 # Build + upload (auto-bumps patch) +# .\tools\publish.ps1 -Version 1.1.0 # Build + upload specific version +# .\tools\publish.ps1 -SkipBuild # Package + upload existing build +# .\tools\publish.ps1 -DryRun # Show what would be uploaded +# +# Requires: AWS CLI (configured), Python, SCons, VS 2022 Build Tools +# Uploads to: s3://tinqs-cli-releases/godot/v/ + +param( + [string]$Version = "", + [switch]$SkipBuild, + [switch]$DryRun, + [int]$Jobs = 0 +) + +$ErrorActionPreference = "Stop" +$GodotRoot = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path) +$BinDir = "$GodotRoot\bin" +$VersionFile = "$GodotRoot\VERSION.tinqs" +$S3Bucket = "tinqs-cli-releases" +$S3Prefix = "godot" + +# --- Resolve version --- +if ($Version -eq "") { + if (Test-Path $VersionFile) { + $current = (Get-Content $VersionFile -Raw).Trim() + # Auto-bump patch + $parts = $current.Split(".") + $parts[2] = [int]$parts[2] + 1 + $Version = $parts -join "." + } else { + $Version = "1.0.0" + } +} + +# Git info +Push-Location $GodotRoot +$commitHash = git rev-parse --short HEAD 2>&1 +$commitFull = git rev-parse HEAD 2>&1 +$branch = git branch --show-current 2>&1 +Pop-Location + +Write-Host "" +Write-Host "========================================" -ForegroundColor Cyan +Write-Host " TINQSEngine Publish - v$Version" -ForegroundColor Cyan +Write-Host "========================================" -ForegroundColor Cyan +Write-Host " Branch: $branch" -ForegroundColor Gray +Write-Host " Commit: $commitHash" -ForegroundColor Gray +Write-Host " S3: s3://${S3Bucket}/${S3Prefix}/v${Version}/" -ForegroundColor Gray +Write-Host "" + +# --- Build --- +if (-not $SkipBuild) { + Write-Host "Step 1/4: Building..." -ForegroundColor Yellow + + if ($Jobs -le 0) { $Jobs = [Environment]::ProcessorCount } + + Push-Location $GodotRoot + $buildOut = python -m SCons platform=windows target=editor module_mono_enabled=yes -j$Jobs 2>&1 + if ($LASTEXITCODE -ne 0) { + Write-Host ($buildOut | Out-String) -ForegroundColor Red + Write-Host "ERROR: Build failed" -ForegroundColor Red + Pop-Location + exit 1 + } + Pop-Location + Write-Host " Build complete." -ForegroundColor Green +} else { + Write-Host "Step 1/4: Build skipped." -ForegroundColor DarkGray +} + +# --- Verify binaries exist --- +$editorExe = "$BinDir\godot.windows.editor.x86_64.mono.exe" +$consoleExe = "$BinDir\godot.windows.editor.x86_64.mono.console.exe" +$sharpDir = "$BinDir\GodotSharp" + +foreach ($path in @($editorExe, $consoleExe, $sharpDir)) { + if (-not (Test-Path $path)) { + Write-Host "ERROR: Missing $path" -ForegroundColor Red + Write-Host "Run without -SkipBuild to compile first." -ForegroundColor Yellow + exit 1 + } +} + +$editorSize = [math]::Round((Get-Item $editorExe).Length / 1MB, 1) +Write-Host " Editor binary: $editorSize MB" -ForegroundColor Gray + +# --- Package --- +Write-Host "Step 2/4: Packaging..." -ForegroundColor Yellow + +$packageName = "tinqs-godot-v${Version}-windows-x86_64-mono" +$stageDir = "$env:TEMP\$packageName" +$tarFile = "$env:TEMP\${packageName}.zip" + +# Clean staging +if (Test-Path $stageDir) { Remove-Item $stageDir -Recurse -Force } +New-Item -ItemType Directory -Path $stageDir | Out-Null + +# Copy binaries +Copy-Item $editorExe "$stageDir\godot.windows.editor.x86_64.mono.exe" +Copy-Item $consoleExe "$stageDir\godot.windows.editor.x86_64.mono.console.exe" +Copy-Item $sharpDir "$stageDir\GodotSharp" -Recurse + +# Write manifest +$builtAt = Get-Date -Format 'yyyy-MM-ddTHH:mm:ssZ' +$manifestObj = @{ + version = $Version + commit = $commitFull + commit_short = $commitHash + branch = $branch + platform = "windows" + arch = "x86_64" + mono = $true + built = $builtAt + modules = @("agent_api","agent_log","agent_events","agent_console","agent_replay","agent_vision","agent_fbx","agent_auth","agent_analytics") +} +$manifestObj | ConvertTo-Json -Depth 3 | Set-Content "$stageDir\manifest.json" -Encoding UTF8 + +# Create zip +if (Test-Path $tarFile) { Remove-Item $tarFile -Force } +Compress-Archive -Path $stageDir -DestinationPath $tarFile -CompressionLevel Optimal + +$tarSize = [math]::Round((Get-Item $tarFile).Length / 1MB, 1) +Write-Host " Package: $tarFile -- $tarSize MB" -ForegroundColor Green + +# --- Upload to S3 --- +Write-Host "Step 3/4: Uploading to S3..." -ForegroundColor Yellow + +$s3VersionPath = "s3://${S3Bucket}/${S3Prefix}/v${Version}/${packageName}.zip" +$s3LatestPath = "s3://${S3Bucket}/${S3Prefix}/latest/${packageName}.zip" +$s3Manifest = "s3://${S3Bucket}/${S3Prefix}/v${Version}/manifest.json" +$s3LatestManifest = "s3://${S3Bucket}/${S3Prefix}/latest/manifest.json" + +if ($DryRun) { + Write-Host " DRY RUN - Would upload:" -ForegroundColor Yellow + Write-Host " $tarFile -> $s3VersionPath" -ForegroundColor DarkGray + Write-Host " $tarFile -> $s3LatestPath" -ForegroundColor DarkGray + Write-Host " manifest.json -> $s3Manifest" -ForegroundColor DarkGray + Write-Host " manifest.json -> $s3LatestManifest" -ForegroundColor DarkGray +} else { + # Versioned upload + aws s3 cp $tarFile $s3VersionPath --region eu-west-1 2>&1 + aws s3 cp "$stageDir\manifest.json" $s3Manifest --region eu-west-1 2>&1 + # Latest upload + aws s3 cp $tarFile $s3LatestPath --region eu-west-1 2>&1 + aws s3 cp "$stageDir\manifest.json" $s3LatestManifest --region eu-west-1 2>&1 + + if ($LASTEXITCODE -ne 0) { + Write-Host "ERROR: S3 upload failed" -ForegroundColor Red + exit 1 + } + Write-Host " Uploaded to v$Version + latest" -ForegroundColor Green +} + +# --- Update VERSION file --- +Write-Host "Step 4/4: Updating VERSION.tinqs..." -ForegroundColor Yellow +$Version | Set-Content $VersionFile -Encoding ASCII -NoNewline + +if (-not $DryRun) { + Push-Location $GodotRoot + git add VERSION.tinqs + git commit -m "release: v$Version" --allow-empty 2>&1 | Out-Null + Pop-Location +} + +# --- Cleanup --- +Remove-Item $stageDir -Recurse -Force -ErrorAction SilentlyContinue + +# --- Summary --- +Write-Host "" +Write-Host "========================================" -ForegroundColor Green +Write-Host " PUBLISHED v$Version" -ForegroundColor Green +Write-Host "========================================" -ForegroundColor Green +Write-Host " S3: s3://${S3Bucket}/${S3Prefix}/v${Version}/" -ForegroundColor Gray +Write-Host " URL: https://${S3Bucket}.s3.eu-west-1.amazonaws.com/${S3Prefix}/v${Version}/${packageName}.zip" -ForegroundColor Gray +Write-Host " Commit: $commitHash" -ForegroundColor Gray +Write-Host " Size: $tarSize MB" -ForegroundColor Gray +Write-Host "" +Write-Host "Fetch in tinqs-engine:" -ForegroundColor White +Write-Host " Set .engine-version to: $Version" -ForegroundColor DarkGray +Write-Host " Run: .\tools\fetch-engine.ps1" -ForegroundColor DarkGray +Write-Host ""