File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 5757 if (-not (Test-Path artifacts/cloudsqlctl-windows-x64.zip)) { throw "Missing zip bundle" }
5858 if (-not (Test-Path artifacts/SHA256SUMS.txt)) { throw "Missing SHA256SUMS.txt" }
5959
60+ - name : Delete existing release assets (same tag)
61+ shell : pwsh
62+ env :
63+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
64+ run : |
65+ $tag = $env:GITHUB_REF -replace 'refs/tags/', ''
66+ $headers = @{
67+ Authorization = "Bearer $env:GITHUB_TOKEN"
68+ Accept = "application/vnd.github+json"
69+ }
70+ try {
71+ $release = Invoke-RestMethod -Method Get -Uri "https://api.github.com/repos/$env:GITHUB_REPOSITORY/releases/tags/$tag" -Headers $headers
72+ } catch {
73+ if ($_.Exception.Response.StatusCode.value__ -eq 404) {
74+ Write-Host "No existing release for $tag"
75+ exit 0
76+ }
77+ throw
78+ }
79+
80+ if (-not $release) {
81+ Write-Host "No existing release data for $tag"
82+ exit 0
83+ }
84+
85+ foreach ($asset in $release.assets) {
86+ Write-Host "Deleting asset $($asset.name)"
87+ Invoke-RestMethod -Method Delete -Uri "https://api.github.com/repos/$env:GITHUB_REPOSITORY/releases/assets/$($asset.id)" -Headers $headers
88+ }
89+
6090 - name : Release
6191 uses : softprops/action-gh-release@v2
6292 if : startsWith(github.ref, 'refs/tags/')
You can’t perform that action at this time.
0 commit comments