Skip to content

Commit 7c05dd8

Browse files
committed
Add Publish-Assets function to ReleaseTools module
1 parent 87dcac7 commit 7c05dd8

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

docs/development.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ New-DraftRelease -RepositoryName PowerShellEditorServices -Assets "PowerShellEdi
7373
New-DraftRelease -RepositoryName vscode-powershell -Assets "powershell-YYYY.M.X.vsix", "Install-VSCode.ps1"
7474
# Check telemetry for stability before releasing
7575
# Publish draft releases and merge (don't squash!) branches
76-
vsce publish --packagePath ./PowerShell-<version>.vsix
77-
# Update Install-VSCode.ps1 on gallery
78-
Publish-Script -Path ./Install-VSCode.ps1 -NuGetApiKey (Get-Secret "PowerShell Gallery API Key" -AsPlainText)
76+
# Permit release pipeline to publish assets
7977
```
8078

8179
### Versioning
@@ -130,4 +128,3 @@ use the same code which includes dependencies).
130128

131129
* `Update-Changelog` should verify the version is in the correct format
132130
* `Update-Changelog` could be faster by not downloading _every_ PR
133-
* A `Publish-Binaries` function could be written to push the binaries out

tools/ReleaseTools.psm1

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function Update-Branch {
155155

156156
<#
157157
.SYNOPSIS
158-
Gets current version from changelog as [semver].
158+
Gets current version from changelog as `[semver]`.
159159
#>
160160
function Get-Version {
161161
param(
@@ -177,7 +177,7 @@ function Get-Version {
177177
Updates the CHANGELOG file with PRs merged since the last release.
178178
.DESCRIPTION
179179
Uses the local Git repositories but does not pull, so ensure HEAD is where
180-
you want it. Creates a new branch at 'release/$Version' if not already
180+
you want it. Creates a new branch at `release/$Version` if not already
181181
checked out. Handles any merge option for PRs, but is a little slow as it
182182
queries all PRs.
183183
#>
@@ -431,3 +431,42 @@ function New-DraftRelease {
431431
$Assets | ForEach-Object { $Release | New-GitHubReleaseAsset -Path $_ }
432432
}
433433
}
434+
435+
<#
436+
.SYNOPSIS
437+
Uploads VSIX and PS1 binaries to their respective marketplaces.
438+
.DESCRIPTION
439+
The VSIX is uploaded to the Visual Studio Code Marketplace using the `vsce`
440+
tool and the `VsceToken` parameter:
441+
https://marketplace.visualstudio.com/VSCode
442+
443+
The PS1 is uploaded to the PowerShell Gallery using the `Publish-Script`
444+
cmdlet and the `GalleryToken` parameter: https://www.powershellgallery.com
445+
446+
This function is primarily used by ADO pipelines, but could be used manually.
447+
#>
448+
function Publish-Assets {
449+
param(
450+
[Parameter(Mandatory)]
451+
[string[]]$Assets,
452+
453+
[Parameter()]
454+
[string]$VsceToken,
455+
456+
[Parameter()]
457+
[string]$GalleryToken
458+
)
459+
switch ($Assets) {
460+
{ $_.EndsWith(".vsix") } {
461+
Write-Host "Uploading VSIX..."
462+
vsce publish --packagePath $_ --pat $VsceToken
463+
}
464+
{ $_.EndsWith(".ps1") } {
465+
Write-Host "Uploading PS1..."
466+
Publish-Script -Path $_ -NuGetApiKey $GalleryToken
467+
}
468+
default {
469+
Write-Error "Unsupported file: $_"
470+
}
471+
}
472+
}

0 commit comments

Comments
 (0)