Publish release assets from tag workflow
This commit is contained in:
@@ -68,3 +68,30 @@ jobs:
|
||||
artifacts/OCSentinelClient-win-x64.zip.sha256
|
||||
artifacts/version.json
|
||||
if-no-files-found: warn
|
||||
|
||||
- name: Publish Gitea release assets
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
shell: pwsh
|
||||
run: |
|
||||
$headers = @{ Authorization = "token $env:GITEA_TOKEN" }
|
||||
$repository = $env:GITEA_REPOSITORY
|
||||
$baseUrl = "$env:GITEA_SERVER_URL/api/v1/repos/$repository"
|
||||
$tag = "${{ github.ref_name }}"
|
||||
$releaseBody = @{
|
||||
tag_name = $tag
|
||||
target_commitish = "${{ github.sha }}"
|
||||
name = "OfficeCom Sentinel $tag"
|
||||
body = "Automated OfficeCom Sentinel client release."
|
||||
} | ConvertTo-Json
|
||||
|
||||
try {
|
||||
$release = Invoke-RestMethod -Method Get -Headers $headers -Uri "$baseUrl/releases/tags/$tag"
|
||||
}
|
||||
catch {
|
||||
$release = Invoke-RestMethod -Method Post -Headers $headers -ContentType "application/json" -Body $releaseBody -Uri "$baseUrl/releases"
|
||||
}
|
||||
|
||||
foreach ($file in @("artifacts/OCSentinelClient-win-x64.zip", "artifacts/OCSentinelClient-win-x64.zip.sha256", "artifacts/version.json")) {
|
||||
$assetName = [System.IO.Path]::GetFileName($file)
|
||||
Invoke-RestMethod -Method Post -Headers $headers -InFile $file -ContentType "application/octet-stream" -Uri "$baseUrl/releases/$($release.id)/assets?name=$assetName" | Out-Null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user