diff --git a/Changelog.md b/Changelog.md new file mode 100644 index 0000000..806fca5 --- /dev/null +++ b/Changelog.md @@ -0,0 +1,66 @@ +# Change log for PSReleaseTools + +## v0.7.0 + ++ Added switch parameter on `Get-PSReleaseAsset` to only get x64 versions ++ Added an option to display current release summary as a markdown document ++ help updates ++ file cleanup for the PowerShell Gallery ++ fixed license + +## v0.6.1 + ++ Added code to fix TLS issue with GitHub (Issue #5) + +## v0.6.0 + ++ Updated to support GA for PowerShell 6 (Issue #4) ++ Changed Save-PSReleaseAsset Name parameter to Family ++ Modified Family values ++ Updated documentation ++ Updated screen shots and README.md + +## v0.5.1.0 + ++ added asset support for SUSE and AppImage ++ minor changes to help documentation ++ updated Pester tests + +## v0.5.0.0 + ++ modified download to pull file hashes from summary ++ and compare them to downloaded files. This is BREAKING CHANGE. ++ Updated Get-PSReleaseAsset to include the SHA256 hash ++ Updated help ++ updated README + +## v0.4.0.2 + ++ fixed semantic versioning in the manifest + +## v0.4.0.1 + ++ Changed to semantic versioning + +## v0.4.0 + ++ updated author name in manifest ++ Added Get-PSReleaseCurrent ++ Updated help + +## v0.3.0 + ++ Renamed Save-PSRelease to Save-PSReleaseAsset for consistency (Issue #1) ++ Updated documentation ++ Updated manifest ++ Published to PSGallery + +## v0.2.0 + ++ Added external documentation + +## v0.1.0 + ++ Initial module release ++ updated license copyright ++ updated README diff --git a/Changelog.txt b/Changelog.txt deleted file mode 100644 index bfffe69..0000000 --- a/Changelog.txt +++ /dev/null @@ -1,48 +0,0 @@ -#Changelog for PSReleaseTools - -v0.6.1 -Added code to fix TLS issue with GitHub (Issue #5) - -v0.6.0 -Updated to support GA for PowerShell 6 (Issue #4) -Changed Save-PSReleaseAsset Name parameter to Family -Modified Family values -Updated documentation -Updated screen shots and README.md - -v0.5.1.0 -added asset support for SUSE and AppImage -minor changes to help documentation -updated Pester tests - -v0.5.0.0 -modified download to pull file hashes from summary -and compare them to downloaded files. This is BREAKING CHANGE. -Updated Get-PSReleaseAsset to include the SHA256 hash -Updated help -updated README - -v0.4.0.2 -fixed semantic versioning in the manifest - -v0.4.0.1 -Changed to semantic versioning - -v0.4.0 -updated author name in manifest -Added Get-PSReleaseCurrent -Updated help - -v0.3.0 -Renamed Save-PSRelease to Save-PSReleaseAsset for consistency (Issue #1) -Updated documentation -Updated manifest -Published to PSGallery - -v0.2.0 -Added external documentation - -v0.1.0 -Initial module release -updated license copyright -updated README diff --git a/Docs/Get-PSReleaseAsset.md b/Docs/Get-PSReleaseAsset.md index 86f332a..36d0cbb 100644 --- a/Docs/Get-PSReleaseAsset.md +++ b/Docs/Get-PSReleaseAsset.md @@ -8,15 +8,17 @@ schema: 2.0.0 # Get-PSReleaseAsset ## SYNOPSIS + Get PowerShell release assets. ## SYNTAX -``` -Get-PSReleaseAsset [[-Family] ] [] +```yaml +Get-PSReleaseAsset [[-Family] ] [-Only64Bit] [] ``` ## DESCRIPTION + Use this command to get details about the different PowerShell release assets. The default is to get all assets but you can limit results to a particular family like Windows or Ubuntu. This command will not download the file but allow you to look at the details. You can pipe these results to Save-PSReleaseAsset to download. @@ -24,7 +26,8 @@ This command will not download the file but allow you to look at the details. Yo ## EXAMPLES ### EXAMPLE 1 -``` + +```powershell PS C:\> Get-PSReleaseAsset -Family Rhel FileName : powershell-6.0.0-1.rhel.7.x86_64.rpm @@ -39,7 +42,8 @@ DownloadCount : 230 ``` ### EXAMPLE 2 -``` + +```powershell PS C:\> Get-PSReleaseAsset -Family ubuntu | Save-PSReleaseAsset -Path D:\PS6 -whatif What if: Performing the operation "Downloading https://github.com/PowerShell/PowerShell/releases/download/v6.0.0/powershell_6.0.0-1.ubuntu.14.04_amd64.deb" on target "D:\PS6\powershell_6.0.0-1.ubuntu.14.04_amd64.deb". What if: Performing the operation "Downloading https://github.com/PowerShell/PowerShell/releases/download/v6.0.0/powershell_6.0.0-1.ubuntu.16.04_amd64.deb" on target "D:\PS6\powershell_6.0.0-1.ubuntu.16.04_amd64.deb". @@ -51,13 +55,14 @@ Run the command without -Whatif to actually download the Ubuntu related files an ## PARAMETERS ### -Family + Limit search to a particular platform. ```yaml Type: String[] Parameter Sets: (All) Aliases: -Accepted values: Rhel,Raspbian,Ubuntu,Debian,Windows,AppImage,Arm,MacOS +Accepted values: Rhel, Raspbian, Ubuntu, Debian, Windows, AppImage, Arm, MacOS Required: False Position: 0 @@ -66,7 +71,24 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Only64Bit + +Only display 64bit assets. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS @@ -78,8 +100,8 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ### System.Object ## NOTES -Learn more about PowerShell: -http://jdhitsolutions.com/blog/essential-powershell-resources/ + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ ## RELATED LINKS diff --git a/Docs/Get-PSReleaseCurrent.md b/Docs/Get-PSReleaseCurrent.md index e8c4837..ddee129 100644 --- a/Docs/Get-PSReleaseCurrent.md +++ b/Docs/Get-PSReleaseCurrent.md @@ -8,38 +8,41 @@ schema: 2.0.0 # Get-PSReleaseCurrent ## SYNOPSIS + Get the current PowerShell v6 release ## SYNTAX -``` +```yaml Get-PSReleaseCurrent [] ``` ## DESCRIPTION -This command will query the GitHub repository for the latest release and write an object to the pipeline. -If you are running v6 the LocalVersion property will reflect the GitCommitID so you can accurately compare and determine if you need to update. +This command will query the GitHub repository for the latest release and write an object to the pipeline. If you are running v6 the LocalVersion property will reflect the GitCommitID so you can accurately compare and determine if you need to update. ## EXAMPLES ### Example 1 -``` + +```powershell PS C:\> Get-PSReleaseCurrent Name Version Released LocalVersion ---- ------- -------- ------------ -v6.0.0 release of PowerShell Core v6.0.0 1/10/2018 5:21:29 PM 5.1.16299.98 +v6.1.0 Release of PowerShell Core v6.1.0 9/13/2018 9:49:59 PM 6.1.0 ``` This gets the current release from a Windows platform. ### Example 2 -``` + +```powershell PS /home/me> Get-PSReleaseCurrent -Name Version Released LocalVersion ----- ------- -------- ------------ -v6.0.0 release of PowerShell Core v6.0.0 1/10/18 10:21:29 PM v6.0.0 + +Name Version Released LocalVersion +---- ------- -------- ------------ +v6.1.0 Release of PowerShell Core v6.1.0 9/13/18 9:49:59 PM 6.1.0 ``` This gets the current release from an Ubuntu platform. @@ -47,6 +50,7 @@ This gets the current release from an Ubuntu platform. ## PARAMETERS ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS @@ -58,8 +62,8 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ### System.Object ## NOTES -Learn more about PowerShell: -http://jdhitsolutions.com/blog/essential-powershell-resources/ + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ ## RELATED LINKS diff --git a/Docs/Get-PSReleaseSummary.md b/Docs/Get-PSReleaseSummary.md index 1d88130..c3d599b 100644 --- a/Docs/Get-PSReleaseSummary.md +++ b/Docs/Get-PSReleaseSummary.md @@ -1,6 +1,6 @@ --- external help file: PSReleaseTools-help.xml -Module Name: PSReleaseTools +Module Name: psreleasetools online version: schema: 2.0.0 --- @@ -8,28 +8,31 @@ schema: 2.0.0 # Get-PSReleaseSummary ## SYNOPSIS + Get information on latest PowerShell v6 release ## SYNTAX -``` -Get-PSReleaseSummary [] +```yaml +Get-PSReleaseSummary [-AsMarkdown] [] ``` ## DESCRIPTION -This command will query the PowerShell GitHub repository for the latest release information using the GitHub APIs. You do not need to have a GitHub account in order to use this command. -The output is a text report. +This command will query the PowerShell GitHub repository for the latest release information using the GitHub APIs. You do not need to have a GitHub account in order to use this command, although you may still reach an API limit if you run this command repeatedly in a short time frame. + +The default output is a text report but you have the the option to create a markdown version. ## EXAMPLES ### EXAMPLE 1 -``` + +```powershell PS C:\> Get-PSReleaseSummary ----------------------------------------------------------- Release : v6.0.0 -Published: 01/10/2018 17:21:29 +Published: 01/10/2018 17:21:29 ----------------------------------------------------------- ### Breaking changes @@ -124,9 +127,34 @@ powershell_6.0.0-1.ubuntu.16.04_amd64.deb 1/10/2018 1:28:29 PM 50 powershell_6.0.0-1.ubuntu.17.04_amd64.deb 1/10/2018 1:28:40 PM 50 ``` +### EXAMPLE 2 + +```powershell +PS /home/jeff> get-psreleasesummary -AsMarkdown | show-markdown +``` + +Get the current release summary as markdown and use the Show-Markdown command in PowerShell Core to render the markdown in the console. Note that Show-Markdown may not render tables correctly. + ## PARAMETERS +### -AsMarkdown + +Create a markdown version of the report. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS @@ -138,12 +166,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ### system.string ## NOTES -Learn more about PowerShell: -http://jdhitsolutions.com/blog/essential-powershell-resources/ + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ ## RELATED LINKS [Get-PSReleaseCurrent]() [Invoke-Restmethod]() - diff --git a/Docs/PSReleaseTools.md b/Docs/PSReleaseTools.md index 3e1ab40..67a88fd 100644 --- a/Docs/PSReleaseTools.md +++ b/Docs/PSReleaseTools.md @@ -7,19 +7,26 @@ Locale: en-US --- # PSReleaseTools Module + ## Description -A set of commands for working with PowerShell 6.0 from GitHub + +A set of commands for working with PowerShell Core from the [GitHub Repository](https://github.com/PowerShell/PowerShell) ## PSReleaseTools Cmdlets + ### [Get-PSReleaseAsset](Get-PSReleaseAsset.md) + Get download file information for each new platform. ### [Get-PSReleaseCurrent](Get-PSReleaseCurrent.md) -Get the current status of PowerShell v6 + +Get the current status of PowerShell Core ### [Get-PSReleaseSummary](Get-PSReleaseSummary.md) -Get a text summary of the latest PowerShell v6 release + +Get a text summary of the latest PowerShell Core release ### [Save-PSReleaseAsset](Save-PSReleaseAsset.md) -Save PowerShell v6 installation files. + +Save PowerShell Core installation files. diff --git a/Docs/Save-PSReleaseAsset.md b/Docs/Save-PSReleaseAsset.md index d57d05e..83df238 100644 --- a/Docs/Save-PSReleaseAsset.md +++ b/Docs/Save-PSReleaseAsset.md @@ -8,49 +8,62 @@ schema: 2.0.0 # Save-PSReleaseAsset ## SYNOPSIS + Download the latest PowerShell v6 beta releases ## SYNTAX ### All (Default) -``` + +```yaml Save-PSReleaseAsset [[-Path] ] [-All] [-Passthru] [-WhatIf] [-Confirm] [] ``` ### Family -``` + +```yaml Save-PSReleaseAsset [[-Path] ] -Family [-Passthru] [-WhatIf] [-Confirm] [] ``` ### file -``` + +```yaml Save-PSReleaseAsset [[-Path] ] [-Asset ] [-Passthru] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION -This command will download the latest PowerShell v6 alpha releases from the GitHub repository. You can download everything or limit the download to specific platforms. + +This command will download the latest PowerShell Core releases from the GitHub repository. You can download everything or limit the download to specific platforms. If you select Windows files you can use the -Format dynamic parameter to download only MSI or ZIP files. Note that this will not work if you specify a combination of Windows and non-Windows platforms. ## EXAMPLES ### EXAMPLE 1 -``` + +```powershell PS C:\> Save-PSReleaseAsset C:\PS6 -all ``` ### EXAMPLE 2 -``` + +```powershell PS C:\> Save-PSReleaseAsset -path C:\PS6 -family Windows -format msi ``` + Download and save Windows MSI packages. + ### EXAMPLE 3 -``` + +```powershell PS C:\> Save-PSReleaseAsset -path C:\PS6 -name Ubuntu,Debian ``` + Download and save Ubuntu and Debian packages. + ### EXAMPLE 4 -``` + +```powershell PS C:\> Get-PSReleaseAsset -Family Ubuntu | Save-PSReleaseAsset -path D:\Temp ``` @@ -59,6 +72,7 @@ Get the Ubuntu assets and save them to D:\Temp ## PARAMETERS ### -Path + The destination folder for all downloads. ```yaml @@ -74,6 +88,7 @@ Accept wildcard characters: False ``` ### -All + Download all files to the destination path. This is the default behavior. ```yaml @@ -89,6 +104,7 @@ Accept wildcard characters: False ``` ### -Passthru + ```yaml Type: SwitchParameter Parameter Sets: (All) @@ -102,8 +118,8 @@ Accept wildcard characters: False ``` ### -WhatIf -Shows what would happen if the cmdlet runs. -The cmdlet is not run. + +Shows what would happen if the cmdlet runs. The cmdlet is not run. ```yaml Type: SwitchParameter @@ -118,6 +134,7 @@ Accept wildcard characters: False ``` ### -Confirm + Prompts you for confirmation before running the cmdlet. ```yaml @@ -133,6 +150,7 @@ Accept wildcard characters: False ``` ### -Asset + An asset object piped from Get-PSReleaseAsset ```yaml @@ -148,6 +166,7 @@ Accept wildcard characters: False ``` ### -Family + The platform you wish to download. ```yaml @@ -164,6 +183,7 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS @@ -172,11 +192,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## OUTPUTS -### system.io.fileinfo +### System.IO.FileInfo ## NOTES -Learn more about PowerShell: -http://jdhitsolutions.com/blog/essential-powershell-resources/ + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ ## RELATED LINKS diff --git a/LICENSE.txt b/LICENSE.txt index d566a34..f8ae83f 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,3 +1,5 @@ +MIT License + Copyright (c) 2017-2018 JDH Information Technology Solutions, Inc. diff --git a/PSReleaseTools.psd1 b/PSReleaseTools.psd1 index d9a322c..c394478 100644 Binary files a/PSReleaseTools.psd1 and b/PSReleaseTools.psd1 differ diff --git a/PSReleaseTools.psm1 b/PSReleaseTools.psm1 index c817bd7..f0bb0f7 100644 --- a/PSReleaseTools.psm1 +++ b/PSReleaseTools.psm1 @@ -66,8 +66,10 @@ Function Get-PSReleaseCurrent { Function Get-PSReleaseSummary { [cmdletbinding()] - [OutputType([System.String])] - Param() + [OutputType([System.String[]])] + Param( + [switch]$AsMarkdown + ) Begin { Write-Verbose "[BEGIN ] Starting: $($MyInvocation.Mycommand)" @@ -82,23 +84,43 @@ Function Get-PSReleaseSummary { $dl = $data.assets | Select-Object @{Name = "Filename"; Expression = {$_.name}}, @{Name = "Updated"; Expression = {$_.updated_at -as [datetime]}}, - @{Name = "SizeMB"; Expression = {$_.size / 1MB -as [int]}} | Out-String + @{Name = "SizeMB"; Expression = {$_.size / 1MB -as [int]}} - #create a here string for the details - $out = @" + if ($AsMarkdown) { + #create a markdown table from download data + $tbl = (($DL | Convertto-CSV -notypeInformation -delimiter "|").Replace('"','') -Replace '^',"|") -replace "$","|`n" + + $out = @" +# $($data.Name.trim()) + +$($data.body.trim()) + +## Downloads + +$($tbl[0])|---|---|---| +$($tbl[1..$($tbl.count)]) +Published: $($data.Published_At -as [datetime]) +"@ + + } + else { + #create a here string for the details + $out = @" + ----------------------------------------------------------- -Release : $($data.Tag_Name) +$($data.Name) Published: $($data.Published_At -as [datetime]) ----------------------------------------------------------- $($data.body) - + ------------- | Downloads | ------------- -$DL - +$($DL | Out-String) + "@ + } #write the string to the pipeline $out @@ -114,6 +136,8 @@ $DL Function Save-PSReleaseAsset { [cmdletbinding(DefaultParameterSetName = "All", SupportsShouldProcess)] + [OutputType([System.IO.FileInfo])] + Param( [Parameter(Position = 0, HelpMessage = "Where do you want to save the files?")] [ValidateScript( { @@ -253,7 +277,8 @@ Function Get-PSReleaseAsset { [OutputType("PSCustomObject")] Param( [ValidateSet("Rhel", "Raspbian", "Ubuntu", "Debian", "Windows", "AppImage", "Arm", "MacOS")] - [string[]]$Family + [string[]]$Family, + [switch]$Only64Bit ) Begin { @@ -280,7 +305,7 @@ Function Get-PSReleaseAsset { Write-Verbose "[PROCESS] Found $($data.assets.count) downloads" $assets = $data.assets | - Select-Object @{Name = "FileName"; Expression = {$_.Name}}, + Select-Object @{Name = "FileName"; Expression = {$_.Name}}, @{Name = "Family"; Expression = { Switch -regex ($_.name) { "Win-x\d{2}" {"Windows"} @@ -306,11 +331,17 @@ Function Get-PSReleaseAsset { @{Name = "DownloadCount"; Expression = {$_.download_count}} if ($Family) { - $assets.where( {$_.family -match $($family -join "|")}) - } - else { - $assets - } + Write-Verbose "[PROCESS] Filtering by family" + $assets = $assets.where( {$_.family -match $($family -join "|")}) + } + if ($Only64Bit) { + Write-Verbose "[PROCESS] Filtering for 64bit" + $assets = ($assets).where( {$_.filename -match "(x|amd)64"}) + } + + #write the results to the pipeline + $assets + } #Try catch { Throw $_ @@ -327,4 +358,3 @@ Function Get-PSReleaseAsset { #configure TLS settings for GitHub [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -Export-ModuleMember -Function 'Get-PSReleaseAsset', 'Get-PSReleaseSummary', 'Save-PSReleaseAsset', 'Get-PSReleaseCurrent'