docs(changelog): add v0.1.1.3 download and SHA256 links; add release automation scripts (upload/prune/manage/checksums)
This commit is contained in:
43
scripts/gitea_upload.ps1
Normal file
43
scripts/gitea_upload.ps1
Normal file
@ -0,0 +1,43 @@
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$Server,
|
||||
[Parameter(Mandatory=$true)][string]$Owner,
|
||||
[Parameter(Mandatory=$true)][string]$Repo,
|
||||
[Parameter(Mandatory=$true)][string]$Token,
|
||||
[Parameter(Mandatory=$true)][string]$ZipPath
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
if (-not (Test-Path -LiteralPath $ZipPath)) {
|
||||
throw "ZIP not found: $ZipPath"
|
||||
}
|
||||
|
||||
$headers = @{ Authorization = "token $Token" }
|
||||
|
||||
$latestUrl = "$Server/api/v1/repos/$Owner/$Repo/releases/latest"
|
||||
$latest = Invoke-RestMethod -Headers $headers -Method GET -Uri $latestUrl
|
||||
if (-not $latest -or -not $latest.id) {
|
||||
throw "Failed to get latest release from $latestUrl"
|
||||
}
|
||||
|
||||
$rid = [string]$latest.id
|
||||
$name = [System.IO.Path]::GetFileName($ZipPath)
|
||||
$escapedName = [System.Uri]::EscapeDataString($name)
|
||||
$uploadUrl = "$Server/api/v1/repos/$Owner/$Repo/releases/$rid/assets?name=$escapedName"
|
||||
|
||||
Write-Host "Latest release id: $rid"
|
||||
Write-Host "Uploading $name to $uploadUrl"
|
||||
|
||||
# Use Invoke-WebRequest multipart form upload
|
||||
$form = @{ attachment = Get-Item -LiteralPath $ZipPath }
|
||||
$resp = Invoke-WebRequest -Headers $headers -Method Post -Uri $uploadUrl -Form $form
|
||||
|
||||
if ($resp.StatusCode -ge 200 -and $resp.StatusCode -lt 300) {
|
||||
Write-Host "Upload successful (HTTP $($resp.StatusCode))"
|
||||
} else {
|
||||
Write-Host "Upload failed (HTTP $($resp.StatusCode))" -ForegroundColor Red
|
||||
if ($resp.Content) { Write-Host $resp.Content }
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user