From 511e07cd166c473bc724889d841b388bb9796ad6 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Tue, 3 Aug 2021 16:48:13 -0700 Subject: [PATCH 1/6] Add `New-Release` to `ReleaseTools` module --- docs/development.md | 5 ++--- tools/ReleaseTools.psm1 | 44 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/docs/development.md b/docs/development.md index 1960249d75..0d4180dc83 100644 --- a/docs/development.md +++ b/docs/development.md @@ -65,9 +65,8 @@ Microsoft. The comments are manual steps. ```powershell Import-Module ./tools/ReleaseTools.psm1 -Update-Changelog -RepositoryName PowerShellEditorServices -Version -Update-Changelog -RepositoryName vscode-powershell -Version -# Amend changelog as necessary, open PR +New-Release -PsesVersion -VsceVersion +# Amend changelog as necessary # Push release branches to ADO # Permit both pipelines to draft GitHub releases # Download and test assets diff --git a/tools/ReleaseTools.psm1 b/tools/ReleaseTools.psm1 index b2ffed0519..f6460a3a92 100644 --- a/tools/ReleaseTools.psm1 +++ b/tools/ReleaseTools.psm1 @@ -278,8 +278,6 @@ function Update-Changelog { git commit -m "Update CHANGELOG for ``$Version``" } } - - Update-Version -RepositoryName $RepositoryName } <# @@ -304,6 +302,7 @@ function Update-Changelog { - `name` field has `-preview` appended similarly - `displayName` field has ` Preview` appended similarly - `description` field has `(Preview) ` prepended similarly + - `icon` field has `_Preview ` inserted similarly #> function Update-Version { [CmdletBinding(SupportsShouldProcess)] @@ -369,8 +368,6 @@ function Update-Version { git commit -m "Bump version to ``v$Version``" } # TODO: Git reset to unstage } - - New-ReleasePR -RepositoryName $RepositoryName } <# @@ -416,6 +413,45 @@ function New-ReleasePR { $Repo | Add-GitHubIssueLabel -Issue $PR.PullRequestNumber -LabelName "Ignore" } +<# +.SYNOPSIS + Kicks off the whole release process. +.DESCRIPTION + This first updates the changelog (which creates and checks out the `release` + branch), commits the changes, updates the version (and commits), pushes the + branch, and then creates a GitHub PR for the release for both repositories. + + This is the function meant to be called by a maintainer as the first manual + step to creating a release: it calls the correct functions in order to prepare + the release. Each repository's release branch then needs to be pushed to the + internal Azure DevOps mirror, at which point the automatic release pipeline + will build and sign the assets, and queue up draft GitHub releases (using + `New-DraftRelease` below). Those releases need to be manually validated and + approved, and finally the last step is to approve the pipeline to publish the + assets to the marketplace and gallery. +#> +function New-Release { + [CmdletBinding(SupportsShouldProcess)] + param( + [Parameter(Mandatory)] + [ValidateScript({ $_.StartsWith("v") })] + [string]$PsesVersion, + + [Parameter(Mandatory)] + [ValidateScript({ $_.StartsWith("v") })] + [string]$VsceVersion + ) + "PowerShellEditorServices", "vscode-powershell" | ForEach-Object { + $Version = switch ($_) { + "PowerShellEditorServices" { $PsesVersion } + "vscode-powershell" { $VsceVersion } + } + Update-Changelog -RepositoryName $_ -Version $Version + Update-Version -RepositoryName $_ + New-ReleasePR -RepositoryName $_ + } +} + <# .SYNOPSIS Creates a new draft GitHub release and Git tag from the updated changelog. From caef019868d09e13f32bf0e04ecd2d313dfc0dbb Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Tue, 3 Aug 2021 17:02:26 -0700 Subject: [PATCH 2/6] Fix more bugs in `ReleaseTools` Missed this change to the branch name. --- tools/ReleaseTools.psm1 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/ReleaseTools.psm1 b/tools/ReleaseTools.psm1 index f6460a3a92..f414c19c37 100644 --- a/tools/ReleaseTools.psm1 +++ b/tools/ReleaseTools.psm1 @@ -384,20 +384,19 @@ function New-ReleasePR { [string]$RepositoryName ) $Version = Get-Version -RepositoryName $RepositoryName - $Branch = "release/v$Version" Update-Branch -RepositoryName $RepositoryName Use-Repository -RepositoryName $RepositoryName -Script { - if ($PSCmdlet.ShouldProcess("$RepositoryName/$Branch", "git push")) { - Write-Host "Pushing branch ``$Branch``..." - git push origin $Branch + if ($PSCmdlet.ShouldProcess("$RepositoryName/release", "git push")) { + Write-Host "Pushing release branch..." + git push --force-with-lease origin release } } $Repo = Get-GitHubRepository -OwnerName PowerShell -RepositoryName $RepositoryName $Params = @{ - Head = $Branch + Head = "release" Base = "master" Draft = $true Title = "Release ``v$Version``" From 0f904d5f8074abfabb8bb0723a13f94032697b2b Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Tue, 3 Aug 2021 17:17:17 -0700 Subject: [PATCH 3/6] Update CHANGELOG for `v2021.8.0-preview` --- CHANGELOG.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f977f47ba..b9a4b5eb87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # PowerShell Extension Release History +## v2021.8.0-preview +### Tuesday, August 03, 2021 + +#### [vscode-powershell](https://github.com/PowerShell/vscode-powershell) + +- ✨ 📺 [vscode-powershell #3422](https://github.com/PowerShell/vscode-powershell/pull/3493) - Update extension icon (and use a special preview icon). +- ✨ 👷 [vscode-powershell #2286](https://github.com/PowerShell/vscode-powershell/pull/3461) - Pipeline-ify entire release process. + +#### [PowerShellEditorServices](https://github.com/PowerShell/PowerShellEditorServices) + +- ✨ 🔍 [PowerShellEditorServices #1533](https://github.com/PowerShell/PowerShellEditorServices/pull/1533) - Enable and fix many .NET Code Analysis warnings. +- ✨ 👷 [PowerShellEditorServices #1530](https://github.com/PowerShell/PowerShellEditorServices/pull/1530) - Update release and CI pipelines. +- ✨ 👷 [PowerShellEditorServices #1528](https://github.com/PowerShell/PowerShellEditorServices/pull/1528) - Automate entire release process. +- ✨ 🛫 [PowerShellEditorServices #1527](https://github.com/PowerShell/PowerShellEditorServices/pull/1527) - Add stack trace to resolve event handler on debug. +- ✨ 🛫 [PowerShellEditorServices #1523](https://github.com/PowerShell/PowerShellEditorServices/pull/1526) - Initialize runspaces with `InitialSessionState` object. + + ## v2021.7.0-preview ### Thursday, July 15, 2021 From c868fe4b5ac5a7f01680c6e726f3dd986cbcb104 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Tue, 3 Aug 2021 17:17:18 -0700 Subject: [PATCH 4/6] Bump version to `v2021.8.0-preview` --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e7dc42c095..58835850e8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "powershell-preview", "displayName": "PowerShell Preview", - "version": "2021.7.0", + "version": "2021.8.0", "preview": true, "publisher": "ms-vscode", "description": "(Preview) Develop PowerShell modules, commands and scripts in Visual Studio Code!", @@ -16,7 +16,7 @@ "Snippets", "Linters" ], - "icon": "media/PowerShell_Icon.png", + "icon": "media/PowerShell_Preview_Icon.png", "galleryBanner": { "color": "#ACD1EC", "theme": "light" From 64c3163e12e838b8abcf27544f72e2f321c6cbbd Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Wed, 4 Aug 2021 10:08:38 -0700 Subject: [PATCH 5/6] Fix bug in release pipeline --- .vsts-ci/templates/publish-markets.yml | 6 +++--- package.json | 4 +++- vscode-powershell.build.ps1 | 9 ++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.vsts-ci/templates/publish-markets.yml b/.vsts-ci/templates/publish-markets.yml index dcc6366f44..b6996dcca8 100644 --- a/.vsts-ci/templates/publish-markets.yml +++ b/.vsts-ci/templates/publish-markets.yml @@ -6,12 +6,12 @@ steps: displayName: Download signed artifacts - pwsh: | - npm install -g vsce - vsce publish --packagePath $(Pipeline.Workspace)/powershell-*.vsix --pat $(VsceToken) + npm ci --loglevel=error + npm run publish -- --packagePath $(Pipeline.Workspace)/vscode-powershell/powershell-*.vsix --pat $(VsceToken) displayName: Publishing VSIX to VS Code Marketplace # NOTE: We rarely update this script, so we can ignore errors from the gallery # caused by us trying to re-publish an updated script. - pwsh: | - Publish-Script -Path $(Pipeline.Workspace)/Install-VSCode.ps1 -ErrorAction Continue -NuGetApiKey $(GalleryToken) + Publish-Script -Path $(Pipeline.Workspace)/vscode-powershell/Install-VSCode.ps1 -ErrorAction Continue -NuGetApiKey $(GalleryToken) displayName: Publishing Install-VSCode.ps1 to PowerShell Gallery diff --git a/package.json b/package.json index 58835850e8..53ad6b536b 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,9 @@ "scripts": { "compile": "tsc -v && tsc -p ./ && tslint -p ./", "compile-watch": "tsc -watch -p ./", - "test": "node ./out/test/runTests.js" + "test": "node ./out/test/runTests.js", + "package": "vsce package --no-gitHubIssueLinking", + "publish": "vsce publish" }, "contributes": { "breakpoints": [ diff --git a/vscode-powershell.build.ps1 b/vscode-powershell.build.ps1 index 5b7b8cac5c..1904c1376c 100644 --- a/vscode-powershell.build.ps1 +++ b/vscode-powershell.build.ps1 @@ -27,8 +27,11 @@ task Restore -If { !(Test-Path "$PSScriptRoot/node_modules") } { Write-Host "`n### Restoring vscode-powershell dependencies`n" -ForegroundColor Green # When in a CI build use the --loglevel=error parameter so that # package install warnings don't cause PowerShell to throw up - $logLevelParam = if ($env:TF_BUILD) { "--loglevel=error" } else { "" } - exec { & npm install $logLevelParam } + if ($env:TF_BUILD) { + exec { & npm ci --loglevel=error } + } else { + exec { & npm install } + } } @@ -106,7 +109,7 @@ task UpdateReadme -If { $script:IsPreviewExtension } { task Package UpdateReadme, { assert { Test-Path ./modules/PowerShellEditorServices } Write-Host "`n### Packaging $($script:PackageJson.name)-$($script:PackageJson.version).vsix`n" -ForegroundColor Green - exec { & node ./node_modules/vsce/out/vsce package --no-gitHubIssueLinking } + exec { & npm run package } } #endregion From f7942d2c2fa7d8811ec411177f469b21435362bb Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Wed, 4 Aug 2021 17:18:05 -0700 Subject: [PATCH 6/6] Correctly ignore failure from re-publishing `Install-VSCode.ps1` We actually need to ignore the task's failure, not the failure in the script. --- .vsts-ci/templates/publish-markets.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vsts-ci/templates/publish-markets.yml b/.vsts-ci/templates/publish-markets.yml index b6996dcca8..e7d278754b 100644 --- a/.vsts-ci/templates/publish-markets.yml +++ b/.vsts-ci/templates/publish-markets.yml @@ -13,5 +13,6 @@ steps: # NOTE: We rarely update this script, so we can ignore errors from the gallery # caused by us trying to re-publish an updated script. - pwsh: | - Publish-Script -Path $(Pipeline.Workspace)/vscode-powershell/Install-VSCode.ps1 -ErrorAction Continue -NuGetApiKey $(GalleryToken) + Publish-Script -Path $(Pipeline.Workspace)/vscode-powershell/Install-VSCode.ps1 -NuGetApiKey $(GalleryToken) displayName: Publishing Install-VSCode.ps1 to PowerShell Gallery + continueOnError: true