<# Builds the app, zips it and publishes a Gitea release that the in-app updater picks up. release.ps1 -Version 1.0.1 -Token builds, tags v1.0.1, creates the release, uploads zip + .sha256 release.ps1 -Version 1.0.1 -BuildOnly only writes dist\\CVRManager-win-x64.zip(.sha256) The token needs write:repository. #> [CmdletBinding()] param( [Parameter(Mandatory)][string]$Version, [string]$Token = $env:GITEA_TOKEN, [string]$GiteaUrl = 'https://git.koneko.cat', [string]$Repo = 'Koneko/CVRManager', [string]$Notes = '', [switch]$BuildOnly ) $ErrorActionPreference = 'Stop' $root = Split-Path $PSScriptRoot -Parent $out = Join-Path $root "dist\$Version" if (Test-Path $out) { Remove-Item $out -Recurse -Force } dotnet publish "$root\CVRManager.csproj" -c Release -r win-x64 --self-contained false -p:Version=$Version -o "$out\app" | Out-Null if ($LASTEXITCODE -ne 0) { throw 'publish failed' } $zip = Join-Path $out 'CVRManager-win-x64.zip' Compress-Archive -Path "$out\app\*" -DestinationPath $zip $hash = (Get-FileHash $zip -Algorithm SHA256).Hash.ToLowerInvariant() Set-Content "$zip.sha256" "$hash CVRManager-win-x64.zip" -NoNewline "Built $zip ($([math]::Round((Get-Item $zip).Length / 1MB, 1)) MB) sha256 $hash" if ($BuildOnly) { return } if (-not $Token) { throw 'No token: pass -Token or set GITEA_TOKEN.' } $h = @{ Authorization = "token $Token" } $api = "$GiteaUrl/api/v1/repos/$Repo" $body = @{ tag_name = "v$Version"; name = "CVR Manager $Version"; body = $Notes; draft = $false; prerelease = $false } | ConvertTo-Json $rel = Invoke-RestMethod -Method Post -Uri "$api/releases" -Headers $h -ContentType 'application/json' -Body $body foreach ($f in $zip, "$zip.sha256") { Invoke-RestMethod -Method Post -Uri "$api/releases/$($rel.id)/assets?name=$([IO.Path]::GetFileName($f))" -Headers $h -Form @{ attachment = Get-Item $f } | Out-Null } "Published $($rel.html_url)"