Skip to content

Commit 7934504

Browse files
committed
Update version and create PR automatically in ReleaseTools module
1 parent 6bba3ae commit 7934504

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

docs/development.md

-5
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ Import-Module ./tools/ReleaseTools.psm1
6868
Update-Changelog -RepositoryName PowerShellEditorServices -Version <version>
6969
Update-Changelog -RepositoryName vscode-powershell -Version <version>
7070
# Amend changelog as necessary
71-
Update-Version -RepositoryName PowerShellEditorServices
72-
Update-Version -RepositoryName vscode-powershell
73-
# Push branches to GitHub and ADO
74-
# Open PRs for review
7571
# Download and test assets (assert correct PSES is included)
7672
New-DraftRelease -RepositoryName PowerShellEditorServices -Assets "PowerShellEditorServices.zip"
7773
New-DraftRelease -RepositoryName vscode-powershell -Assets "powershell-YYYY.M.X.vsix", "Install-VSCode.ps1"
@@ -134,5 +130,4 @@ use the same code which includes dependencies).
134130

135131
* `Update-Changelog` should verify the version is in the correct format
136132
* `Update-Changelog` could be faster by not downloading _every_ PR
137-
* `Update-Version` could be run by `Update-Changelog`
138133
* A `Publish-Binaries` function could be written to push the binaries out

tools/ReleaseTools.psm1

+46-2
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ function Update-Changelog {
202202
Where-Object { -not $_.user.UserName.EndsWith("[bot]") } |
203203
Where-Object { "Ignore" -notin $_.labels.LabelName } |
204204
Where-Object { -not $_.title.StartsWith("[Ignore]") } |
205-
Where-Object { -not $_.title.StartsWith("Update CHANGELOG") } |
206-
Where-Object { -not $_.title.StartsWith("Bump version") } |
205+
Where-Object { -not $_.title.StartsWith("Release ``v") } |
207206
Get-Bullets -RepositoryName $RepositoryName
208207

209208
$NewSection = switch ($RepositoryName) {
@@ -242,6 +241,8 @@ function Update-Changelog {
242241
}
243242

244243
Pop-Location
244+
245+
Update-Version -RepositoryName $RepositoryName
245246
}
246247

247248
<#
@@ -328,6 +329,49 @@ function Update-Version {
328329
}
329330

330331
Pop-Location
332+
333+
New-ReleasePR -RepositoryName $RepositoryName
334+
}
335+
336+
<#
337+
.SYNOPSIS
338+
Creates a new draft GitHub PR from the release branch.
339+
.DESCRIPTION
340+
Pushes the release branch to `origin` and then opens a draft PR.
341+
#>
342+
function New-ReleasePR {
343+
param(
344+
[Parameter(Mandatory)]
345+
[ValidateSet([RepoNames])]
346+
[string]$RepositoryName
347+
)
348+
# NOTE: This a side effect neccesary for Git operations to work.
349+
Push-Location -Path "$PSScriptRoot/../../$RepositoryName"
350+
351+
$Version = Get-Version -RepositoryName $RepositoryName
352+
$Branch = "release/v$Version"
353+
Update-Branch -Version $Version
354+
Write-Output "Pushing branch ``$Branch``..."
355+
git push origin $Branch
356+
357+
$LabelParams = @{
358+
OwnerName = "PowerShell"
359+
RepositoryName = $RepositoryName
360+
Label = "Ignore"
361+
}
362+
363+
$PRParams = @{
364+
Head = $Branch
365+
Base = "master"
366+
Draft = $true
367+
Title = "Release ``v$Version``"
368+
Body = "Automated PR for new release!"
369+
}
370+
371+
$PR = Get-GitHubLabel @LabelParams | New-GitHubPullRequest @PRParams
372+
Write-Output "Draft PR URL: $($PR.html_url)"
373+
374+
Pop-Location
331375
}
332376

333377
<#

0 commit comments

Comments
 (0)