Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion tools/releaseTools.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,20 @@ function Get-ChangeLog
[Parameter(Mandatory = $true)]
[string]$ThisReleaseTag,

[Parameter(Mandatory)]
[Parameter(Mandatory = $false)]
[string]$Token,

[Parameter()]
[switch]$HasCherryPick
)

if(-not $Token) {
$Token = Get-GHDefaultAuthToken
if(-not $Token) {
throw "No GitHub Auth Token provided"
}
}

$tag_hash = git rev-parse "$LastReleaseTag^0"
$format = '%H||%P||%aN||%aE||%s'
$header = @{"Authorization"="token $Token"}
Expand Down Expand Up @@ -361,6 +368,29 @@ function Get-ChangeLog
Write-Output "[${version}]: https://github.com/PowerShell/PowerShell/compare/${LastReleaseTag}...${ThisReleaseTag}`n"
}

function Get-GHDefaultAuthToken {
$IsGHCLIInstalled = $false
if (Get-command -CommandType Application -Name gh -ErrorAction SilentlyContinue) {
$IsGHCLIInstalled = $true
} else {
Write-Error -Message "GitHub CLI is not installed. Please install it from https://cli.github.com/" -ErrorAction Stop
}

if ($IsGHCLIInstalled) {
try {
$Token = & gh auth token
} catch {
Write-Error -Message "Please login to GitHub CLI using 'gh auth login'"
}
}

if (-not $Token) {
$Token = Read-Host -Prompt "Enter GitHub Auth Token"
}

return $Token
}

function PrintChangeLog($clSection, $sectionTitle, [switch] $Compress) {
if ($clSection.Count -gt 0) {
"### $sectionTitle`n"
Expand Down