Skip to content

Commit 9b80082

Browse files
committed
Publish using managed identity
1 parent ff50a24 commit 9b80082

File tree

3 files changed

+56
-55
lines changed

3 files changed

+56
-55
lines changed

azure-pipelines/install-node.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
steps:
2+
- task: NodeTool@0
3+
displayName: 'Install Node.js 20.x'
4+
inputs:
5+
versionSpec: '20.x'

azure-pipelines/prereqs.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ steps:
1111
# The server package is downloaded from NuGet
1212
- task: NuGetAuthenticate@1
1313

14-
- task: NodeTool@0
15-
displayName: 'Install Node.js 20.x'
16-
inputs:
17-
versionSpec: '20.x'
14+
- template: /azure-pipelines/install-node.yml@self
1815

1916
# Some tests use predefined docker images with a specific version of .NET installed.
2017
# So we avoid installing .NET in those cases.

azure-pipelines/release.yml

+50-51
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ parameters:
77
default: true
88

99
variables:
10-
# This is expected to provide VisualStudioMarketplacePAT to the release (https://code.visualstudio.com/api/working-with-extensions/publishing-extension#get-a-personal-access-token)
11-
- group: vscode-csharp release secrets
1210
# This is expected to provide pat to tag release.
1311
- group: DncEng-Partners-Tokens
1412

@@ -55,59 +53,63 @@ extends:
5553
buildVersionToDownload: 'specific'
5654
buildId: '$(resources.pipeline.officialBuildCI.runID)'
5755
branchName: '$(resources.pipeline.officialBuildCI.sourceBranch)'
56+
- template: /azure-pipelines/install-node.yml@self
5857
- pwsh: |
59-
npm install --global vsce
58+
npm install --global @vscode/vsce
6059
displayName: 'Install vsce'
61-
- pwsh: |
62-
# Choose whether to upload to prerelease or release based on the artifacts generated by the build pipeline.
63-
$artifactFolder = ""
64-
$uploadPrerelease = $true
65-
if (Test-Path -Path "VSIX_Prerelease") {
66-
$artifactFolder = "VSIX_Prerelease"
67-
$uploadPrerelease = $true
68-
} elseif (Test-Path -Path "VSIX_Release") {
69-
$artifactFolder = "VSIX_Release"
70-
$uploadPrerelease = $false
71-
} else {
72-
throw "No artifacts are downloaded."
73-
}
60+
- task: AzureCLI@2
61+
displayName: '🚀 Publish to Marketplace'
62+
inputs:
63+
azureSubscription: 'VSCode Marketplace Publishing'
64+
scriptType: "pscore"
65+
scriptLocation: 'inlineScript'
66+
workingDirectory: $(Pipeline.Workspace)
67+
inlineScript: |
68+
# Choose whether to upload to prerelease or release based on the artifacts generated by the build pipeline.
69+
$artifactFolder = ""
70+
$uploadPrerelease = $true
71+
if (Test-Path -Path "VSIX_Prerelease") {
72+
$artifactFolder = "VSIX_Prerelease"
73+
$uploadPrerelease = $true
74+
} elseif (Test-Path -Path "VSIX_Release") {
75+
$artifactFolder = "VSIX_Release"
76+
$uploadPrerelease = $false
77+
} else {
78+
throw "No artifacts are downloaded."
79+
}
7480
75-
Write-Host "Uploading artifacts from $artifactFolder with prerelease=$uploadPrerelease"
81+
Write-Host "Uploading artifacts from $artifactFolder with prerelease=$uploadPrerelease"
7682
77-
# Our build pipeline would generated build based on attempt number. Publishing the latest attempt.
78-
$allArtifacts = Get-ChildItem -Path "$artifactFolder*" | Sort-Object -Descending
79-
if ($allArtifacts.Length -eq 0) {
80-
throw "No artifacts in $artifactFolder"
81-
}
83+
# Our build pipeline would generated build based on attempt number. Publishing the latest attempt.
84+
$allArtifacts = Get-ChildItem -Path "$artifactFolder*" | Sort-Object -Descending
85+
if ($allArtifacts.Length -eq 0) {
86+
throw "No artifacts in $artifactFolder"
87+
}
8288
83-
$publishArtifacts = $allArtifacts[0]
84-
Write-Host "All artifacts: $($allArtifacts). Publishing $($publishArtifacts)."
89+
$publishArtifacts = $allArtifacts[0]
90+
Write-Host "All artifacts: $($allArtifacts). Publishing $($publishArtifacts)."
8591
86-
$basePublishArgs = , "publish"
87-
If ( $uploadPrerelease ) {
88-
$basePublishArgs += "--pre-release"
89-
Write-Host "Publish to pre-release channel."
90-
} Else {
91-
Write-Host "Publish to release channel."
92-
}
93-
$basePublishArgs += '--packagePath'
94-
$publishArgs = $basePublishArgs + (Get-ChildItem $publishArtifacts\*.vsix | Sort-Object Name -Descending |% { $_ })
92+
$basePublishArgs = , "publish --azure-credential"
93+
If ( $uploadPrerelease ) {
94+
$basePublishArgs += "--pre-release"
95+
Write-Host "Publish to pre-release channel."
96+
} Else {
97+
Write-Host "Publish to release channel."
98+
}
99+
$basePublishArgs += '--packagePath'
100+
$publishArgs = $basePublishArgs + (Get-ChildItem $publishArtifacts\*.vsix | Sort-Object Name -Descending |% { $_ })
95101
96-
If ("${{ parameters.test }}" -eq "true") {
97-
Write-Host "In test mode, command is printed instead of run."
98-
Write-Host "##[command]vsce $publishArgs"
102+
If ("${{ parameters.test }}" -eq "true") {
103+
Write-Host "In test mode, command is printed instead of run."
104+
Write-Host "##[command]vsce $publishArgs"
99105
100-
Write-Host "🔒 Verify PAT."
101-
vsce verify-pat ms-dotnettools
102-
}
103-
Else {
104-
Write-Host "##[command]vsce $publishArgs"
105-
vsce @publishArgs
106-
}
107-
displayName: 🚀 Publish to Marketplace
108-
workingDirectory: $(Pipeline.Workspace)
109-
env:
110-
VSCE_PAT: $(VSCodeMarketplacePAT)
106+
Write-Host "🔒 Verify PAT."
107+
vsce verify-pat --azure-credential ms-dotnettools
108+
}
109+
Else {
110+
Write-Host "##[command]vsce $publishArgs"
111+
vsce @publishArgs
112+
}
111113
- stage: 'TagRelease'
112114
displayName: 'Tag release of vscode-csharp'
113115
dependsOn: 'PublishStage'
@@ -119,15 +121,12 @@ extends:
119121
image: 1es-ubuntu-2204
120122
os: linux
121123
steps:
122-
- task: NodeTool@0
123-
displayName: 'Install Node.js 18.x'
124-
inputs:
125-
versionSpec: '18.x'
126124
- checkout: self
127125
clean: true
128126
submodules: true
129127
fetchTags: false
130128
fetchDepth: 0
129+
- template: /azure-pipelines/install-node.yml@self
131130
- pwsh: |
132131
git checkout $(resources.pipeline.officialBuildCI.sourceCommit)
133132
displayName: 'Checkout build source branch'

0 commit comments

Comments
 (0)