# Upload Windows Build to Forgejo Packages # Usage: .\upload_to_packages.ps1 -Version 1.0.0 -ForgejoToken $token param( [Parameter(Mandatory=$true)] [string]$Version, [Parameter(Mandatory=$true)] [string]$ForgejoToken, [string]$ForgejoUrl = "https://git.him-tools.de", [string]$Repo = "HIM-public/webdrop-bridge", [string]$ExePath = "build\dist\windows\WebDropBridge.exe", [string]$ChecksumPath = "build\dist\windows\WebDropBridge.exe.sha256" ) $ErrorActionPreference = "Stop" # Verify files exist if (-not (Test-Path $ExePath)) { Write-Host "ERROR: Executable not found at $ExePath" -ForegroundColor Red exit 1 } if (-not (Test-Path $ChecksumPath)) { Write-Host "ERROR: Checksum file not found at $ChecksumPath" -ForegroundColor Red exit 1 } Write-Host "Uploading WebDropBridge $Version to Forgejo Packages..." -ForegroundColor Cyan # Get file info $exeSize = (Get-Item $ExePath).Length / 1MB $checksum = Get-Content $ChecksumPath -Raw Write-Host "File: WebDropBridge.exe ($([math]::Round($exeSize, 2)) MB)" Write-Host "Checksum: $($checksum.Substring(0, 16))..." # Upload executable Write-Host "`nUploading executable..." -ForegroundColor Yellow $exeUrl = "$ForgejoUrl/api/v1/repos/$Repo/packages/generic/webdrop-bridge/$Version/WebDropBridge.exe" $headers = @{ "Authorization" = "token $ForgejoToken" } try { $response = Invoke-WebRequest -Uri $exeUrl ` -Method PUT ` -Headers $headers ` -InFile $ExePath ` -ContentType "application/octet-stream" Write-Host "āœ“ Executable uploaded successfully" -ForegroundColor Green } catch { Write-Host "ERROR uploading executable: $_" -ForegroundColor Red exit 1 } # Upload checksum Write-Host "Uploading checksum..." -ForegroundColor Yellow $checksumUrl = "$ForgejoUrl/api/v1/repos/$Repo/packages/generic/webdrop-bridge/$Version/WebDropBridge.exe.sha256" try { $response = Invoke-WebRequest -Uri $checksumUrl ` -Method PUT ` -Headers $headers ` -Body $checksum ` -ContentType "text/plain" Write-Host "āœ“ Checksum uploaded successfully" -ForegroundColor Green } catch { Write-Host "ERROR uploading checksum: $_" -ForegroundColor Red exit 1 } Write-Host "`nāœ“ Upload complete!" -ForegroundColor Green Write-Host "View at: $ForgejoUrl/$Repo/packages" -ForegroundColor Cyan