Skip to content

Commit 07ffdac

Browse files
committed
Add Publish-Assets function to ReleaseTools module
1 parent b7e1cf0 commit 07ffdac

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
@@ -77,9 +77,7 @@ New-DraftRelease -RepositoryName PowerShellEditorServices -Assets "PowerShellEdi
7777
New-DraftRelease -RepositoryName vscode-powershell -Assets "powershell-YYYY.M.X.vsix", "Install-VSCode.ps1"
7878
# Check telemetry for stability before releasing
7979
# Publish draft releases and merge (don't squash!) branches
80-
vsce publish --packagePath ./PowerShell-<version>.vsix
81-
# Update Install-VSCode.ps1 on gallery
82-
Publish-Script -Path ./Install-VSCode.ps1 -NuGetApiKey (Get-Secret "PowerShell Gallery API Key" -AsPlainText)
80+
# Permit release pipeline to publish assets
8381
```
8482

8583
### Versioning
@@ -135,4 +133,3 @@ use the same code which includes dependencies).
135133
* `Update-Changelog` should verify the version is in the correct format
136134
* `Update-Changelog` could be faster by not downloading _every_ PR
137135
* `Update-Version` could be run by `Update-Changelog`
138-
* 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
@@ -151,7 +151,7 @@ function Update-Branch {
151151

152152
<#
153153
.SYNOPSIS
154-
Gets current version from changelog as [semver].
154+
Gets current version from changelog as `[semver]`.
155155
#>
156156
function Get-Version {
157157
param(
@@ -173,7 +173,7 @@ function Get-Version {
173173
Updates the CHANGELOG file with PRs merged since the last release.
174174
.DESCRIPTION
175175
Uses the local Git repositories but does not pull, so ensure HEAD is where
176-
you want it. Creates a new branch at 'release/$Version' if not already
176+
you want it. Creates a new branch at `release/$Version` if not already
177177
checked out. Handles any merge option for PRs, but is a little slow as it
178178
queries all PRs.
179179
#>
@@ -366,3 +366,42 @@ function New-DraftRelease {
366366
Write-Output "Uploading assets..."
367367
$Assets | New-GitHubReleaseAsset -Release $Release.Id
368368
}
369+
370+
<#
371+
.SYNOPSIS
372+
Uploads VSIX and PS1 binaries to their respective marketplaces.
373+
.DESCRIPTION
374+
The VSIX is uploaded to the Visual Studio Code Marketplace using the `vsce`
375+
tool and the `VsceToken` parameter:
376+
https://marketplace.visualstudio.com/VSCode
377+
378+
The PS1 is uploaded to the PowerShell Gallery using the `Publish-Script`
379+
cmdlet and the `GalleryToken` parameter: https://www.powershellgallery.com
380+
381+
This function is primarily used by ADO pipelines, but could be used manually.
382+
#>
383+
function Publish-Assets {
384+
param(
385+
[Parameter(Mandatory)]
386+
[string[]]$Assets,
387+
388+
[Parameter()]
389+
[string]$VsceToken,
390+
391+
[Parameter()]
392+
[string]$GalleryToken
393+
)
394+
switch ($Assets) {
395+
{ $_.EndsWith(".vsix") } {
396+
Write-Output "Uploading VSIX..."
397+
vsce publish --packagePath $_ --pat $VsceToken
398+
}
399+
{ $_.EndsWith(".ps1") } {
400+
Write-Output "Uploading PS1..."
401+
Publish-Script -Path $_ -NuGetApiKey $GalleryToken
402+
}
403+
default {
404+
Write-Error "Unsupported file: $_"
405+
}
406+
}
407+
}

0 commit comments

Comments
 (0)