PowerShell_Scripts/git/Get-GitHubReleaseAssets.ps1

19 lines
613 B
PowerShell

[CmdletBinding()]param(
[Parameter(Mandatory)]
[string]$GitHubProject,
[string]$tag='latest',
[Alias("Match")]
[string]$MatchPattern
)
filter Out-Matched { $_ | Where-Object { $_ -match $MatchPattern } }
Set-Alias FinalOutput Out-Default
if( $MatchPattern ) { Set-Alias FinalOutput Out-Matched }
Invoke-WebRequest https://github.com/$GitHubProject/releases/$tag -UseBasicParsing -ErrorAction Stop |
Select-Object -ExpandProperty Links |
Where-Object href -match 'download/.*' |
Select-Object -ExpandProperty href |
ForEach-Object { "https://github.com$_" } |
FinalOutput