-
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e2aef7e
commit 43dc636
Showing
15 changed files
with
670 additions
and
711 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
Function Get-PSIssue { | ||
[cmdletbinding()] | ||
[outputtype("GitHubIssue")] | ||
Param( | ||
[Parameter(HelpMessage = "Display issues updated since this time.")] | ||
[datetime]$Since, | ||
[Parameter(HelpMessage = "Specify a comma separated list of labels to filter with. If you select multiple labels, the issue must have all of them.")] | ||
[string[]]$Label, | ||
[Parameter(HelpMessage = "The number of results to return.")] | ||
[ValidateSet(25, 50, 75, 100, 150, 200)] | ||
[int]$Count = 25 | ||
|
||
) | ||
Begin { | ||
Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Starting $($myinvocation.mycommand)" | ||
|
||
#number of results per page is 25 so calculate how many pages are needed. | ||
[int]$m = $count / 25 | ||
if ($m -ne 1) { | ||
[int]$PageCount = $m + 1 | ||
} | ||
else { | ||
[int]$PageCount = 1 | ||
} | ||
|
||
Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Getting $pageCount page(s)." | ||
$uri = "https://api.github.com/repos/PowerShell/PowerShell/issues?&state=open&sort=updated&direction=desc&per_page=25" | ||
|
||
$header = @{ accept = "application/vnd.github.v3+json" } | ||
|
||
if ($since) { | ||
$dt = "{0:u}" -f $since | ||
$uri += "&since=$dt" | ||
} | ||
|
||
if ($Label) { | ||
$Labelstring = $Label -join "," | ||
$uri += "&labels=$Labelstring" | ||
Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Filtering for labels $Labelstring" | ||
} | ||
|
||
$irm = @{ | ||
uri = $uri | ||
headers = $header | ||
DisableKeepAlive = $True | ||
UseBasicParsing = $True | ||
} | ||
|
||
$results = [System.Collections.Generic.List[object]]::new() | ||
#set a flag to indicate we should keep getting pages | ||
$run = $True | ||
} #begin | ||
Process { | ||
|
||
1..$pageCount | ForEach-Object { | ||
if ($run) { | ||
$irm.uri = "$uri&page=$_" | ||
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Getting recent PowerShell issues: $($irm.uri)" | ||
#filter out pull requests | ||
$r = (Invoke-RestMethod @irm).ForEach({ $_ | NewGHIssue }) | ||
if ($r.title) { | ||
$results.AddRange($r) | ||
} | ||
else { | ||
Write-Warning "No matching issues found." | ||
$run = $False | ||
} | ||
} #if $run | ||
} #foreach page | ||
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Returned $($results.count) matching issues" | ||
$results | ||
} #process | ||
End { | ||
Write-Verbose "[$((Get-Date).TimeofDay) END ] Ending $($myinvocation.mycommand)" | ||
} #end | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Function Get-PSIssueLabel { | ||
[cmdletbinding()] | ||
Param( | ||
[Parameter(HelpMessage = "Specify a label name. You can use wildcards.")] | ||
[string]$Name | ||
) | ||
Write-Verbose "Starting $($myinvocation.mycommand)" | ||
|
||
$Label = [System.Collections.Generic.list[object]]::new() | ||
|
||
$header = @{ accept = "application/vnd.github.v3+json" } | ||
$irm = @{ | ||
uri = "" | ||
headers = $header | ||
DisableKeepAlive = $true | ||
UseBasicParsing = $True | ||
} | ||
$page = 0 | ||
do { | ||
Write-Verbose "Processing Page $page" | ||
$page++ | ||
$irm.uri = "https://api.github.com/repos/powershell/powershell/labels?per_page=50&page=$Page" | ||
Write-Verbose $irm.uri | ||
$r = Invoke-RestMethod @irm | ||
$Label.Addrange( $r.ForEach( { $_ | Select-Object -Property Name, Description })) | ||
} until ($r.count -eq 0 -or $page -ge 4) | ||
|
||
Write-Verbose "Found $($Label.count) labels" | ||
if ($Name) { | ||
Write-Verbose "Filtering for $Name" | ||
($label).where( { $_.name -like $Name }) | ||
} | ||
else { | ||
$Label | ||
}$p | ||
Write-Verbose "Ending $($myinvocation.mycommand)" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
function Get-PSReleaseAsset { | ||
|
||
[CmdletBinding()] | ||
[OutputType("PSCustomObject")] | ||
param( | ||
[Parameter(HelpMessage = "Limit results to a given platform. The default is all platforms.")] | ||
[ValidateSet("Rhel", "Raspbian", "Ubuntu", "Debian", "Windows", "AppImage", "Arm", "MacOS", "Alpine", "FXDependent", "CentOS", "Linux")] | ||
[string[]]$Family, | ||
[ValidateSet('deb', 'gz', 'msi', 'pkg', 'rpm', 'zip', 'msix')] | ||
[Parameter(HelpMessage = "Limit results to a given format. The default is all formats.")] | ||
[string[]]$Format, | ||
[Alias("x64")] | ||
[switch]$Only64Bit, | ||
[Parameter(HelpMessage = "Get the latest preview release.")] | ||
[switch]$Preview, | ||
[Parameter(HelpMessage = "Only get LTS release-related assets.")] | ||
[switch]$LTS | ||
) | ||
|
||
begin { | ||
Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Starting: $($MyInvocation.MyCommand)" | ||
} #begin | ||
|
||
process { | ||
try { | ||
if ($Preview) { | ||
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Getting preview assets" | ||
$data = GetData -Preview -ErrorAction Stop | ||
} | ||
else { | ||
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Getting normal assets" | ||
$data = GetData -ErrorAction Stop | ||
} | ||
#parse out file names and hashes | ||
#updated pattern 10 March 2020 to capture LTS assets | ||
[regex]$rx = "(?<file>[p|P]ower[s|S]hell((-preview)|(-lts))?[-|_]\d.*)\s+-\s+(?<hash>\w+)" | ||
# pre GA pattern | ||
#"(?<file>[p|P]ower[s|S]hell(-preview)?[-|_]\d.*)\s+-\s+(?<hash>\w+)" | ||
# original regex pattern | ||
#"(?<file>[p|P]ower[s|S]hell[-|_]\d.*)\s+-\s+(?<hash>\w+)" | ||
$r = $rx.Matches($data.body) | ||
$r | ForEach-Object -Begin { | ||
$h = @{ } | ||
} -Process { | ||
#if there is a duplicate entry, assume it is part of a Note | ||
$f = $_.Groups["file"].Value.Trim() | ||
$v = $_.Groups["hash"].Value.Trim() | ||
if (-not ($h.ContainsKey($f))) { | ||
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Adding $f [$v]" | ||
$h.Add($f, $v ) | ||
} | ||
else { | ||
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Ignoring duplicate asset: $f [$v]" | ||
} | ||
} | ||
|
||
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Found $($data.assets.count) downloads" | ||
|
||
$assets = $data.assets | | ||
Select-Object @{Name = "FileName"; Expression = { $_.Name } }, | ||
@{Name = "Family"; Expression = { | ||
switch -regex ($_.name) { | ||
"Win-x\d{2}" { "Windows" ; break } | ||
"arm\d{2}.zip" { "Arm" ; break } | ||
"Ubuntu" { "Ubuntu"; break } | ||
"osx" { "MacOS"; break } | ||
"debian" { "Debian"; break } | ||
"appimage" { "AppImage"; break } | ||
"rhel" { "Rhel"; break } | ||
"linux-arm" { "Raspbian"; break } | ||
"alpine" { "Alpine" ; break } | ||
"fxdepend" { "FXDependent"; break } | ||
"centos" { "CentOS"; break } | ||
"linux-x64" { "Linux" ; break } | ||
} | ||
} | ||
}, | ||
@{Name = "Format"; Expression = { | ||
$_.name.Split(".")[-1] | ||
} | ||
}, | ||
@{Name = "SizeMB"; Expression = { $_.size / 1MB -as [int32] } }, | ||
@{Name = "Hash"; Expression = { $h.Item($_.name) } }, | ||
@{Name = "Created"; Expression = { $_.created_at -as [datetime] } }, | ||
@{Name = "Updated"; Expression = { $_.updated_at -as [datetime] } }, | ||
@{Name = "URL"; Expression = { $_.browser_download_Url } }, | ||
@{Name = "DownloadCount"; Expression = { $_.download_count } } | ||
|
||
if ($Family) { | ||
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Filtering by family" | ||
$assets = $assets.where( { $_.family -match $($family -join "|") }) | ||
} | ||
if ($Only64Bit) { | ||
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Filtering for 64bit" | ||
$assets = ($assets).where( { $_.filename -match "(x|amd)64" }) | ||
} | ||
|
||
if ($Format) { | ||
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Filtering for format" | ||
$assets = $assets.where( { $_.format -match $("^$format$" -join "|") }) | ||
} | ||
|
||
If ($LTS) { | ||
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Filtering for LTS assets" | ||
$assets = $assets.where( { $_.filename -match "LTS" }) | ||
} | ||
#write the results to the pipeline | ||
if ($assets.filename) { | ||
$assets | ||
} | ||
else { | ||
Write-Warning "Get-PSReleaseAsset Failed to find any release assets using the specified criteria." | ||
} | ||
} #Try | ||
catch { | ||
throw $_ | ||
} | ||
} #process | ||
|
||
end { | ||
Write-Verbose "[$((Get-Date).TimeofDay) END ] Ending: $($MyInvocation.MyCommand)" | ||
} #end | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
function Get-PSReleaseCurrent { | ||
[CmdletBinding()] | ||
[OutputType("PSReleaseStatus")] | ||
param( | ||
[Parameter(HelpMessage = "Get the latest preview release")] | ||
[switch]$Preview | ||
) | ||
|
||
begin { | ||
Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Starting: $($MyInvocation.MyCommand)" | ||
} #begin | ||
|
||
process { | ||
|
||
$data = GetData @PSBoundParameters | ||
|
||
#get the local version from the GitCommitID on v6 platforms | ||
#or PSVersion table for everything else | ||
if ($PSVersionTable.ContainsKey("GitCommitID")) { | ||
$local = $PSVersionTable.GitCommitID | ||
} | ||
else { | ||
$Local = $PSVersionTable.PSVersion | ||
} | ||
|
||
if ($data.tag_name) { | ||
#create a custom object. This object has a custom format file. | ||
[pscustomobject]@{ | ||
PSTypeName = "PSReleaseStatus" | ||
Name = $data.name | ||
Version = $data.tag_name | ||
Released = $($data.published_at -as [datetime]) | ||
LocalVersion = $local | ||
URL = $data.html_url | ||
Draft = If ($data.draft -eq 'True') {$True} else {$false} | ||
Prerelease = If ($data.prerelease -eq 'True') { $True } else { $false } | ||
} | ||
} | ||
} #process | ||
|
||
end { | ||
Write-Verbose "[$((Get-Date).TimeofDay) END ] Ending: $($MyInvocation.MyCommand)" | ||
} #end | ||
|
||
} |
Oops, something went wrong.