Use curl for asset upload
This commit is contained in:
@@ -40,22 +40,30 @@ jobs:
|
||||
$baseUrl = "https://git.marketally.com/api/v1"
|
||||
|
||||
Write-Host "Creating release for tag: $tag"
|
||||
Write-Host "Token length: $($env:GITEA_TOKEN.Length)"
|
||||
|
||||
$headers = @{
|
||||
"Authorization" = "token $env:GITEA_TOKEN"
|
||||
"Content-Type" = "application/json"
|
||||
}
|
||||
|
||||
# Check if release already exists
|
||||
try {
|
||||
$existing = Invoke-RestMethod -Uri "$baseUrl/repos/$repo/releases/tags/$tag" -Headers @{"Authorization"="token $env:GITEA_TOKEN"} -ErrorAction Stop
|
||||
$releaseId = $existing.id
|
||||
Write-Host "Release already exists with ID: $releaseId"
|
||||
} catch {
|
||||
# Create new release
|
||||
$body = @{
|
||||
tag_name = $tag
|
||||
name = "Monitor Control $tag"
|
||||
body = "## Monitor Control $tag`n`n### Installation`n1. Download the ZIP file`n2. Extract to a folder`n3. Run DellMonitorControl.exe`n`n### Requirements`n- Windows 10/11`n- .NET 9.0 Runtime"
|
||||
} | ConvertTo-Json
|
||||
|
||||
$release = Invoke-RestMethod -Uri "$baseUrl/repos/$repo/releases" -Method Post -Headers $headers -Body $body
|
||||
Write-Host "Release created with ID: $($release.id)"
|
||||
$release = Invoke-RestMethod -Uri "$baseUrl/repos/$repo/releases" -Method Post -Headers @{"Authorization"="token $env:GITEA_TOKEN"; "Content-Type"="application/json"} -Body $body
|
||||
$releaseId = $release.id
|
||||
Write-Host "Release created with ID: $releaseId"
|
||||
}
|
||||
|
||||
# Upload asset using curl (more reliable for file uploads)
|
||||
$filePath = "./MonitorControl-$tag.zip"
|
||||
Invoke-RestMethod -Uri "$baseUrl/repos/$repo/releases/$($release.id)/assets?name=MonitorControl-$tag.zip" -Method Post -Headers @{"Authorization"="token $env:GITEA_TOKEN"} -InFile $filePath -ContentType "application/zip"
|
||||
$fileName = "MonitorControl-$tag.zip"
|
||||
Write-Host "Uploading $fileName..."
|
||||
|
||||
curl.exe -X POST -H "Authorization: token $env:GITEA_TOKEN" -F "attachment=@$filePath" "$baseUrl/repos/$repo/releases/$releaseId/assets?name=$fileName"
|
||||
|
||||
Write-Host "Asset uploaded successfully"
|
||||
|
||||
Reference in New Issue
Block a user