@@ -158,9 +158,9 @@ function Get-Version {
158158 Updates the CHANGELOG file with PRs merged since the last release.
159159. DESCRIPTION
160160 Uses the local Git repositories but does not pull, so ensure HEAD is where
161- you want it. Creates a new branch at release/$Version if not already
161+ you want it. Creates a new branch at ' release/$Version' if not already
162162 checked out. Handles any merge option for PRs, but is a little slow as it
163- queries all closed PRs.
163+ queries all PRs.
164164#>
165165function Update-Changelog {
166166 [CmdletBinding (SupportsShouldProcess )]
@@ -178,13 +178,15 @@ function Update-Changelog {
178178
179179 # Get the repo object, latest release, and commits since its tag.
180180 $Repo = Get-GitHubRepository - OwnerName PowerShell - RepositoryName $RepositoryName
181+ # TODO: Handle pre-releases (i.e. treat as latest).
181182 $Release = $Repo | Get-GitHubRelease - Latest
182183 $Commits = git rev- list " $ ( $Release.tag_name ) ..."
183184
184185 # NOTE: This is a slow API as it gets all PRs, and then filters.
185186 $Bullets = $Repo | Get-GitHubPullRequest - State All |
186187 Where-Object { $_.merge_commit_sha -in $Commits } |
187188 Where-Object { -not $_.user.UserName.EndsWith (" [bot]" ) } |
189+ Where-Object { " Include" -notin $_.labels.LabelName } |
188190 Where-Object { -not $_.title.StartsWith (" [Ignore]" ) } |
189191 Where-Object { -not $_.title.StartsWith (" Update CHANGELOG" ) } |
190192 Where-Object { -not $_.title.StartsWith (" Bump version" ) } |
@@ -193,10 +195,12 @@ function Update-Changelog {
193195 $NewSection = switch ($RepositoryName ) {
194196 " vscode-powershell" {
195197 @ (
196- " #### [vscode-powershell](https://github.com/PowerShell/vscode-powershell)`n "
198+ " #### [vscode-powershell](https://github.com/PowerShell/vscode-powershell)"
199+ " "
197200 $Bullets
198201 " "
199- " #### [PowerShellEditorServices](https://github.com/PowerShell/PowerShellEditorServices)`n "
202+ " #### [PowerShellEditorServices](https://github.com/PowerShell/PowerShellEditorServices)"
203+ " "
200204 (Get-NewChangelog - RepositoryName " PowerShellEditorServices" ).Where ({ $_.StartsWith (" - " ) }, " SkipUntil" )
201205 )
202206 }
@@ -210,8 +214,10 @@ function Update-Changelog {
210214 @ (
211215 $CurrentChangelog [0 .. 1 ]
212216 " ## $Version "
213- " ### $ ( [datetime ]::Now.ToString(' dddd, MMMM dd, yyyy' )) `n "
217+ " ### $ ( [datetime ]::Now.ToString(' dddd, MMMM dd, yyyy' )) "
218+ " "
214219 $NewSection
220+ " "
215221 $CurrentChangelog [2 .. $CurrentChangelog.Length ]
216222 ) | Set-Content - Encoding utf8NoBOM - Path $ChangelogFile
217223
@@ -309,20 +315,16 @@ function Update-Version {
309315 git commit - m " Bump version to v$Version "
310316 }
311317
312- if ($PSCmdlet.ShouldProcess (" $RepositoryName /v$Version " , " git tag" )) {
313- git tag " v$Version "
314- }
315-
316318 Pop-Location
317319}
318320
319321<#
320322. SYNOPSIS
321- Creates a new draft GitHub release from the updated changelog.
323+ Creates a new draft GitHub release and Git tag from the updated changelog.
322324. DESCRIPTION
323325 Requires that the changelog has been updated first as it pulls the release
324326 content and new version number from it. Note that our tags and version name
325- are prefixed with a `v`.
327+ are prefixed with a `v`. Creates a Git tag if it does not already exist.
326328#>
327329function New-DraftRelease {
328330 [CmdletBinding (SupportsShouldProcess )]
@@ -341,6 +343,18 @@ function New-DraftRelease {
341343 PreRelease = [bool ]$Version.PreReleaseLabel
342344 # TODO: Pass -WhatIf and -Confirm parameters correctly.
343345 }
346+
347+ if ($PSCmdlet.ShouldProcess (" $RepositoryName /v$Version " , " git tag" )) {
348+ # NOTE: This a side effect neccesary for Git operations to work.
349+ Push-Location - Path " $PSScriptRoot /../../$RepositoryName "
350+ if (-not (git show-ref -- tags " v$Version " )) {
351+ git tag " v$Version "
352+ } else {
353+ Write-Warning " git tag $RepositoryName /v$Version already exists!"
354+ }
355+ Pop-Location
356+ }
357+
344358 Get-GitHubRepository - OwnerName PowerShell - RepositoryName $RepositoryName |
345359 New-GitHubRelease @ReleaseParams
346360}
0 commit comments