@@ -37,10 +37,13 @@ function Get-Bullets {
37
37
' TylerLeonhardt'
38
38
)
39
39
40
- $LabelEmoji = @ {
40
+ $IssueEmojis = @ {
41
41
' Issue-Enhancement' = ' ✨'
42
42
' Issue-Bug' = ' 🐛'
43
43
' Issue-Performance' = ' ⚡️'
44
+ }
45
+
46
+ $AreaEmojis = @ {
44
47
' Area-Build & Release' = ' 👷'
45
48
' Area-Code Formatting' = ' 💎'
46
49
' Area-Configuration' = ' 🔧'
@@ -81,12 +84,9 @@ function Get-Bullets {
81
84
process {
82
85
$PullRequests | ForEach-Object {
83
86
# Map all the labels to emoji (or use a default).
84
- # NOTE: Whitespacing here is weird.
85
- $emoji = if ($_.labels ) {
86
- $LabelEmoji [$_.labels.LabelName ] -join " "
87
- } else {
88
- ' #️⃣ 🙏'
89
- }
87
+ $labels = if ($_.labels ) { $_.labels.LabelName } else { " " }
88
+ $issueEmoji = $IssueEmojis [$labels ] + " #️⃣" | Select-Object - First 1
89
+ $areaEmoji = $AreaEmojis [$labels ] + " 🙏" | Select-Object - First 1
90
90
91
91
# Get a linked issue number if it exists (or use the PR).
92
92
$link = if ($_.body -match $IssueRegex ) {
@@ -105,7 +105,7 @@ function Get-Bullets {
105
105
}
106
106
107
107
# Put the bullet point together.
108
- (" -" , $emoji , " [$link ]($ ( $_.html_url ) )" , " -" , " $ ( $_.title ) ." , $thanks -join " " ).Trim()
108
+ (" -" , $issueEmoji , $areaEmoji , " [$link ]($ ( $_.html_url ) )" , " -" , " $ ( $_.title ) ." , $thanks -join " " ).Trim()
109
109
}
110
110
}
111
111
}
@@ -139,13 +139,17 @@ function Get-FirstChangelog {
139
139
Creates and checks out `release/v<version>` if not already on it.
140
140
#>
141
141
function Update-Branch {
142
+ [CmdletBinding (SupportsShouldProcess )]
142
143
param (
143
144
[Parameter (Mandatory )]
144
145
[string ]$Version
145
146
)
146
- $branch = git branch -- show-current
147
- if ($branch -ne " release/v$Version " ) {
148
- git checkout - b " release/v$Version "
147
+ $Branch = git branch -- show-current
148
+ $NewBranch = " release/v$Version "
149
+ if ($Branch -ne $NewBranch ) {
150
+ if ($PSCmdlet.ShouldProcess ($NewBranch , " git checkout -b" )) {
151
+ git checkout - b $NewBranch
152
+ }
149
153
}
150
154
}
151
155
@@ -202,8 +206,7 @@ function Update-Changelog {
202
206
Where-Object { -not $_.user.UserName.EndsWith (" [bot]" ) } |
203
207
Where-Object { " Ignore" -notin $_.labels.LabelName } |
204
208
Where-Object { -not $_.title.StartsWith (" [Ignore]" ) } |
205
- Where-Object { -not $_.title.StartsWith (" Update CHANGELOG" ) } |
206
- Where-Object { -not $_.title.StartsWith (" Bump version" ) } |
209
+ Where-Object { -not $_.title.StartsWith (" Release `` v" ) } |
207
210
Get-Bullets - RepositoryName $RepositoryName
208
211
209
212
$NewSection = switch ($RepositoryName ) {
@@ -235,12 +238,15 @@ function Update-Changelog {
235
238
$CurrentChangelog [2 .. $CurrentChangelog.Length ]
236
239
) | Set-Content - Encoding utf8NoBOM - Path $ChangelogFile
237
240
238
- if ($PSCmdlet.ShouldProcess (" $RepositoryName /$ChangelogFile " , " git" )) {
239
- Update-Branch - Version $Version.Substring (1 ) # Has "v" prefix
241
+ Update-Branch - Version $Version.Substring (1 ) # Has "v" prefix
242
+
243
+ if ($PSCmdlet.ShouldProcess (" $RepositoryName /$ChangelogFile " , " git commit" )) {
240
244
git add $ChangelogFile
241
245
git commit - m " Update CHANGELOG for `` $Version `` "
242
246
}
243
247
248
+ Update-Version - RepositoryName $RepositoryName
249
+
244
250
Pop-Location
245
251
}
246
252
@@ -250,18 +256,18 @@ function Update-Changelog {
250
256
. DESCRIPTION
251
257
Note that our Git tags and changelog prefix all versions with `v`.
252
258
253
- PowerShellEditorServices: version is `x.y.z -preview.d `
259
+ PowerShellEditorServices: version is `X.Y.Z -preview`
254
260
255
261
- PowerShellEditorServices.psd1:
256
- - `ModuleVersion` variable with `'x.y.z '` string, no pre-release info
262
+ - `ModuleVersion` variable with `'X.Y.Z '` string, no pre-release info
257
263
- PowerShellEditorServices.Common.props:
258
- - `VersionPrefix` field with `x.y.z `
264
+ - `VersionPrefix` field with `X.Y.Z `
259
265
- `VersionSuffix` field with pre-release portion excluding hyphen
260
266
261
- vscode-powershell: version is `yyyy.mm.x -preview`
267
+ vscode-powershell: version is `YYYY.M.X -preview`
262
268
263
269
- package.json:
264
- - `version` field with `"x.y.z "` and no prefix or suffix
270
+ - `version` field with `"X.Y.Z "` and no prefix or suffix
265
271
- `preview` field set to `true` or `false` if version is a preview
266
272
- `name` field has `-preview` appended similarly
267
273
- `displayName` field has ` Preview` appended similarly
@@ -322,11 +328,62 @@ function Update-Version {
322
328
}
323
329
}
324
330
331
+ Update-Branch - Version $Version
332
+
325
333
if ($PSCmdlet.ShouldProcess (" $RepositoryName /v$Version " , " git commit" )) {
326
- Update-Branch - Version $Version
327
334
git commit - m " Bump version to `` v$Version `` "
335
+ } # TODO: Git reset to unstage
336
+
337
+ New-ReleasePR - RepositoryName $RepositoryName
338
+
339
+ Pop-Location
340
+ }
341
+
342
+ <#
343
+ . SYNOPSIS
344
+ Creates a new draft GitHub PR from the release branch.
345
+ . DESCRIPTION
346
+ Pushes the release branch to `origin` and then opens a draft PR.
347
+ #>
348
+ function New-ReleasePR {
349
+ [CmdletBinding (SupportsShouldProcess )]
350
+ param (
351
+ [Parameter (Mandatory )]
352
+ [ValidateSet ([RepoNames ])]
353
+ [string ]$RepositoryName
354
+ )
355
+ # NOTE: This a side effect neccesary for Git operations to work.
356
+ Push-Location - Path " $PSScriptRoot /../../$RepositoryName "
357
+
358
+ $Version = Get-Version - RepositoryName $RepositoryName
359
+ $Branch = " release/v$Version "
360
+
361
+ Update-Branch - Version $Version
362
+
363
+ if ($PSCmdlet.ShouldProcess (" $RepositoryName /$Branch " , " git push" )) {
364
+ Write-Host " Pushing branch `` $Branch `` ..."
365
+ git push origin $Branch
328
366
}
329
367
368
+ $LabelParams = @ {
369
+ OwnerName = " PowerShell"
370
+ RepositoryName = $RepositoryName
371
+ Label = " Ignore"
372
+ }
373
+
374
+ $PRParams = @ {
375
+ Head = $Branch
376
+ Base = " master"
377
+ Draft = $true
378
+ Title = " Release `` v$Version `` "
379
+ Body = " Automated PR for new release!"
380
+ WhatIf = $WhatIfPreference
381
+ Confirm = $ConfirmPreference
382
+ }
383
+
384
+ $PR = Get-GitHubLabel @LabelParams | New-GitHubPullRequest @PRParams
385
+ Write-Host " Draft PR URL: $ ( $PR.html_url ) "
386
+
330
387
Pop-Location
331
388
}
332
389
@@ -339,28 +396,35 @@ function Update-Version {
339
396
are prefixed with a `v`. Creates a Git tag if it does not already exist.
340
397
#>
341
398
function New-DraftRelease {
399
+ [CmdletBinding (SupportsShouldProcess )]
342
400
param (
343
401
[Parameter (Mandatory )]
344
402
[ValidateSet ([RepoNames ])]
345
403
[string ]$RepositoryName ,
346
404
347
- [Parameter (ValueFromPipeline )]
405
+ [Parameter ()]
348
406
[string []]$Assets
349
407
)
350
408
$Version = Get-Version - RepositoryName $RepositoryName
351
409
$Changelog = (Get-FirstChangelog - RepositoryName $RepositoryName ) -join " `n "
352
410
$ReleaseParams = @ {
353
- Draft = $true
354
411
# NOTE: We rely on GitHub to create the tag at that branch.
355
- Tag = " v$Version "
356
- Committish = " release/v$Version "
357
- Name = " v$Version "
358
- Body = $ChangeLog
359
- PreRelease = [bool ]$Version.PreReleaseLabel
360
- OwnerName = " PowerShell"
412
+ Tag = " v$Version "
413
+ Committish = " release/v$Version "
414
+ Name = " v$Version "
415
+ Body = $ChangeLog
416
+ Draft = $true
417
+ PreRelease = [bool ]$Version.PreReleaseLabel
418
+ OwnerName = " PowerShell"
361
419
RepositoryName = $RepositoryName
420
+ WhatIf = $WhatIfPreference
421
+ Confirm = $ConfirmPreference
362
422
}
363
423
364
424
$Release = New-GitHubRelease @ReleaseParams
365
- $Assets | New-GitHubReleaseAsset - Release $Release.Id
425
+ if ($Release ) {
426
+ Write-Host " Draft release URL: $ ( $Release.html_url ) "
427
+ Write-Host " Uploading assets..."
428
+ $Assets | New-GitHubReleaseAsset - Release $Release.Id
429
+ }
366
430
}
0 commit comments