Skip to content

Commit 2a6f1e5

Browse files
authored
Update release pipeline to publish vsix to marketplace (#5929)
* Squash all the commits * Add emoji
1 parent f0b3dd0 commit 2a6f1e5

File tree

1 file changed

+59
-33
lines changed

1 file changed

+59
-33
lines changed

azure-pipelines/release.yml

Lines changed: 59 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,71 @@
1-
trigger: none # We only want to trigger manually or based on resources
1+
trigger: none
22
pr: none
33

4-
resources:
5-
pipelines:
6-
- pipeline: CI
7-
source: vscode-csharp-next
8-
trigger:
9-
tags:
10-
- auto-release
4+
parameters:
5+
- name: test-run
6+
type: boolean
7+
default: true
8+
- name: branch
9+
type: string
10+
default: prerelease
11+
values:
12+
- prerelease
13+
- release
1114

1215
variables:
13-
- group: VisualStudioMarketplace # Expected to provide VisualStudioMarketplacePAT (https://code.visualstudio.com/api/working-with-extensions/publishing-extension#get-a-personal-access-token)
16+
# This is expected to provide VisualStudioMarketplacePAT to the release (https://code.visualstudio.com/api/working-with-extensions/publishing-extension#get-a-personal-access-token)
17+
- group: vscode-csharp release secrets
1418

1519
jobs:
16-
- job: release
20+
- job: PublishToMarketplace
1721
pool:
18-
name: AzurePipelines-EO
19-
vmImage: AzurePipelinesUbuntu20.04compliant
22+
vmImage: ubuntu-latest
2023
steps:
21-
- checkout: none
22-
- powershell: |
23-
Write-Host "##vso[build.updatebuildnumber]$(resources.pipeline.CI.runName)"
24-
if ('$(resources.pipeline.CI.runName)'.Contains('-')) {
25-
Write-Host "##vso[task.setvariable variable=IsPrerelease]true"
26-
} else {
27-
Write-Host "##vso[task.setvariable variable=IsPrerelease]false"
24+
- task: DownloadPipelineArtifact@2
25+
displayName: '📦 Download artifacts from build pipeline.'
26+
inputs:
27+
buildType: 'specific'
28+
project: 'internal'
29+
definition: 1264
30+
buildVersionToDownload: 'latestFromBranch'
31+
branchName: 'refs/heads/${{ parameters.branch }}'
32+
- pwsh: |
33+
npm install --global vsce
34+
displayName: 'Install vsce'
35+
- pwsh: |
36+
# Our build pipeline would generated build based on attempt number. Publishing the latest attempt.
37+
$allArtifacts = Get-ChildItem -Path "VSIXs - Attempt*" | Sort-Object -Descending
38+
if ($allArtifacts.Length -eq 0) {
39+
throw "No Artifacts is downloaded."
2840
}
29-
displayName: ⚙ Set up pipeline
30-
- download: CI
31-
artifact: package
32-
displayName: 🔻 Download package artifact
33-
- pwsh: | # Package publishing to pre-release https://code.visualstudio.com/api/working-with-extensions/publishing-extension#prerelease-extensions
34-
$additionalPublishArgs = 'run','vsce','publish','--skip-duplicate'
35-
if ($env:ISPRERELEASE -ne 'false') {
36-
$additionalPublishArgs += '--pre-release'
41+
42+
$publishArtifacts = $allArtifacts[0]
43+
Write-Host "All artifacts: $($allArtifacts). Publishing $($publishArtifacts)."
44+
45+
$additionalPublishArgs = "publish","--skip-duplicate"
46+
# Artifacts are published to either pre-release or release based on the build branch, https://code.visualstudio.com/api/working-with-extensions/publishing-extension#prerelease-extensions
47+
If ("${{ parameters.branch }}" -eq "prerelease") {
48+
$additionalPublishArgs += "--pre-release"
49+
Write-Host "Publish to pre-release channel."
50+
} ElseIf ("${{ parameters.branch }}" -eq "release") {
51+
Write-Host "Publish to release channel."
52+
} Else {
53+
throw "Unexpected branch name: ${{ parameters.branch }}."
3754
}
55+
3856
$additionalPublishArgs += '--packagePath'
39-
$additionalPublishArgs += Get-ChildItem *.vsix |% { $_.Name }
40-
Write-Host "##[command]yarn $additionalPublishArgs"
41-
yarn @additionalPublishArgs
42-
displayName: 📦 Publish to Marketplace
43-
workingDirectory: $(Pipeline.Workspace)/CI/package
57+
$additionalPublishArgs += Get-ChildItem $publishArtifacts *.vsix
58+
59+
if ($({ parameters.test-run })) {
60+
Write-Host "In test mode, command is printed instead of run."
61+
Write-Host "Command run is: vsce $($additionalPublishArgs)."
62+
Write-Host "🔒 Verify PAT."
63+
vsce verify-pat ms-dotnettools
64+
}
65+
else {
66+
vsce @additionalPublishArgs
67+
}
68+
displayName: 🚀 Publish to Marketplace
69+
workingDirectory: $(Pipeline.Workspace)
4470
env:
45-
VSCE_PAT: $(VisualStudioMarketplacePAT)
71+
VSCE_PAT: $(VSCodeMarketplacePAT)

0 commit comments

Comments
 (0)