@@ -158,9 +158,9 @@ function Get-Version {
158
158
Updates the CHANGELOG file with PRs merged since the last release.
159
159
. DESCRIPTION
160
160
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
162
162
checked out. Handles any merge option for PRs, but is a little slow as it
163
- queries all closed PRs.
163
+ queries all PRs.
164
164
#>
165
165
function Update-Changelog {
166
166
[CmdletBinding (SupportsShouldProcess )]
@@ -178,13 +178,15 @@ function Update-Changelog {
178
178
179
179
# Get the repo object, latest release, and commits since its tag.
180
180
$Repo = Get-GitHubRepository - OwnerName PowerShell - RepositoryName $RepositoryName
181
+ # TODO: Handle pre-releases (i.e. treat as latest).
181
182
$Release = $Repo | Get-GitHubRelease - Latest
182
183
$Commits = git rev- list " $ ( $Release.tag_name ) ..."
183
184
184
185
# NOTE: This is a slow API as it gets all PRs, and then filters.
185
186
$Bullets = $Repo | Get-GitHubPullRequest - State All |
186
187
Where-Object { $_.merge_commit_sha -in $Commits } |
187
188
Where-Object { -not $_.user.UserName.EndsWith (" [bot]" ) } |
189
+ Where-Object { " Include" -notin $_.labels.LabelName } |
188
190
Where-Object { -not $_.title.StartsWith (" [Ignore]" ) } |
189
191
Where-Object { -not $_.title.StartsWith (" Update CHANGELOG" ) } |
190
192
Where-Object { -not $_.title.StartsWith (" Bump version" ) } |
@@ -193,10 +195,12 @@ function Update-Changelog {
193
195
$NewSection = switch ($RepositoryName ) {
194
196
" vscode-powershell" {
195
197
@ (
196
- " #### [vscode-powershell](https://github.com/PowerShell/vscode-powershell)`n "
198
+ " #### [vscode-powershell](https://github.com/PowerShell/vscode-powershell)"
199
+ " "
197
200
$Bullets
198
201
" "
199
- " #### [PowerShellEditorServices](https://github.com/PowerShell/PowerShellEditorServices)`n "
202
+ " #### [PowerShellEditorServices](https://github.com/PowerShell/PowerShellEditorServices)"
203
+ " "
200
204
(Get-NewChangelog - RepositoryName " PowerShellEditorServices" ).Where ({ $_.StartsWith (" - " ) }, " SkipUntil" )
201
205
)
202
206
}
@@ -210,8 +214,10 @@ function Update-Changelog {
210
214
@ (
211
215
$CurrentChangelog [0 .. 1 ]
212
216
" ## $Version "
213
- " ### $ ( [datetime ]::Now.ToString(' dddd, MMMM dd, yyyy' )) `n "
217
+ " ### $ ( [datetime ]::Now.ToString(' dddd, MMMM dd, yyyy' )) "
218
+ " "
214
219
$NewSection
220
+ " "
215
221
$CurrentChangelog [2 .. $CurrentChangelog.Length ]
216
222
) | Set-Content - Encoding utf8NoBOM - Path $ChangelogFile
217
223
@@ -309,20 +315,16 @@ function Update-Version {
309
315
git commit - m " Bump version to v$Version "
310
316
}
311
317
312
- if ($PSCmdlet.ShouldProcess (" $RepositoryName /v$Version " , " git tag" )) {
313
- git tag " v$Version "
314
- }
315
-
316
318
Pop-Location
317
319
}
318
320
319
321
<#
320
322
. 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.
322
324
. DESCRIPTION
323
325
Requires that the changelog has been updated first as it pulls the release
324
326
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.
326
328
#>
327
329
function New-DraftRelease {
328
330
[CmdletBinding (SupportsShouldProcess )]
@@ -341,6 +343,18 @@ function New-DraftRelease {
341
343
PreRelease = [bool ]$Version.PreReleaseLabel
342
344
# TODO: Pass -WhatIf and -Confirm parameters correctly.
343
345
}
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
+
344
358
Get-GitHubRepository - OwnerName PowerShell - RepositoryName $RepositoryName |
345
359
New-GitHubRelease @ReleaseParams
346
360
}
0 commit comments