Skip to content

Commit 0f30118

Browse files
committed
Add Publish-Assets function to ReleaseTools module
1 parent afbfa18 commit 0f30118

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
#>
@@ -428,3 +428,42 @@ function New-DraftRelease {
428428
$Assets | New-GitHubReleaseAsset -Release $Release.Id
429429
}
430430
}
431+
432+
<#
433+
.SYNOPSIS
434+
Uploads VSIX and PS1 binaries to their respective marketplaces.
435+
.DESCRIPTION
436+
The VSIX is uploaded to the Visual Studio Code Marketplace using the `vsce`
437+
tool and the `VsceToken` parameter:
438+
https://marketplace.visualstudio.com/VSCode
439+
440+
The PS1 is uploaded to the PowerShell Gallery using the `Publish-Script`
441+
cmdlet and the `GalleryToken` parameter: https://www.powershellgallery.com
442+
443+
This function is primarily used by ADO pipelines, but could be used manually.
444+
#>
445+
function Publish-Assets {
446+
param(
447+
[Parameter(Mandatory)]
448+
[string[]]$Assets,
449+
450+
[Parameter()]
451+
[string]$VsceToken,
452+
453+
[Parameter()]
454+
[string]$GalleryToken
455+
)
456+
switch ($Assets) {
457+
{ $_.EndsWith(".vsix") } {
458+
Write-Host "Uploading VSIX..."
459+
vsce publish --packagePath $_ --pat $VsceToken
460+
}
461+
{ $_.EndsWith(".ps1") } {
462+
Write-Host "Uploading PS1..."
463+
Publish-Script -Path $_ -NuGetApiKey $GalleryToken
464+
}
465+
default {
466+
Write-Error "Unsupported file: $_"
467+
}
468+
}
469+
}

0 commit comments

Comments
 (0)