Skip to content

Commit 4cd13d0

Browse files
[APIPUB-61] Changes in OnRelease Workflow to Delete Previous PreRelease *Tags* as well as GH Releases (Ed-Fi-Alliance-OSS#96)
* Add changes to remove Previous PreRelease Tags as well as GH Releases * Fix Verbosity in case of exception
1 parent 3d264f9 commit 4cd13d0

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

.github/workflows/on-release.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
3636
$page = 1
3737
$release_list = @()
38+
$tagsToDelete = @()
3839
3940
Do {
4041
@@ -49,11 +50,28 @@ jobs:
4950
$release_list | ForEach-Object {
5051
if ($_.tag_name -like "Pre-Release-*" -and $_.prerelease) {
5152
"Deleting pre-release $($_.tag_name)" | Write-Output
53+
# Store tag name for later deletion
54+
$tagsToDelete += $_.tag_name
55+
# Delete the release
5256
Invoke-RestMethod -Method Delete -Uri $_.url -Headers $gh_headers
5357
}
5458
}
5559
5660
$page += 1
5761
} While ($release_list.count -gt 0)
5862
63+
# Delete the git tags for the pre-releases
64+
$tagsToDelete | ForEach-Object {
65+
$tagName = $_
66+
"Deleting git tag $tagName" | Write-Output
67+
$tagUrl = "https://api.github.com/repos/$repo/git/refs/tags/$tagName"
68+
try {
69+
Invoke-RestMethod -Method Delete -Uri $tagUrl -Headers $gh_headers
70+
"Successfully deleted tag $tagName" | Write-Output
71+
}
72+
catch {
73+
"Warning: Could not delete tag $tagName - $($_.Exception.Message)" | Write-Output
74+
}
75+
}
76+
5977
# Manually doing promote packages to release on azure artifacts

0 commit comments

Comments
 (0)