Functions/Public/Remove-GitHubRelease.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
function Remove-GitHubRelease { <# .SYNOPSIS Remove a release .DESCRIPTION Remove a release .PARAMETER Repository The name of the repository .PARAMETER Id The Id of the release to remove .INPUTS System.String .OUTPUTS System.Management.Automation.PSObject .EXAMPLE Remove-GitHubRelease -Repository MyRepository -Id 12345 #> [CmdletBinding(SupportsShouldProcess,ConfirmImpact="High")][OutputType('System.Management.Automation.PSObject')] Param ( [Parameter(Mandatory=$true, Position=0)] [ValidateNotNullOrEmpty()] [String]$Repository, [Parameter(Mandatory=$true, Position=1, ValueFromPipelineByPropertyName=$true)] [ValidateNotNullOrEmpty()] [String[]]$Id ) Begin { # --- Grab the sessionstate variable & test throw if it is null $SessionInfo = Get-GitHubSessionInformation -Verbose:$VerbosePreference } Process { try { foreach ($ReleaseId in $Id) { if ($PSCmdlet.ShouldProcess($Repository)){ $URI = "/repos/$($SessionInfo.Username)/$($Repository)/releases/$($ReleaseId)" Invoke-GitHubRestMethod -Method DELETE -URI $URI -Verbose:$VerbosePreference } } } catch [Exception] { throw $_.Exception } } End {} } |