|
1 |
| -trigger: none # We only want to trigger manually or based on resources |
| 1 | +trigger: none |
2 | 2 | pr: none
|
3 | 3 |
|
4 |
| -resources: |
5 |
| - pipelines: |
6 |
| - - pipeline: CI |
7 |
| - source: vscode-csharp-next |
8 |
| - trigger: |
9 |
| - tags: |
10 |
| - - auto-release |
| 4 | +parameters: |
| 5 | + - name: test |
| 6 | + type: boolean |
| 7 | + default: true |
| 8 | + - name: branch |
| 9 | + type: string |
| 10 | + default: prerelease |
| 11 | + values: |
| 12 | + - prerelease |
| 13 | + - release |
11 | 14 |
|
12 | 15 | 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 |
14 | 18 |
|
15 | 19 | jobs:
|
16 |
| -- job: release |
| 20 | +- job: PublishToMarketplace |
17 | 21 | pool:
|
18 |
| - name: AzurePipelines-EO |
19 |
| - vmImage: AzurePipelinesUbuntu20.04compliant |
| 22 | + vmImage: ubuntu-latest |
20 | 23 | 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." |
28 | 40 | }
|
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" |
| 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 }}." |
37 | 54 | }
|
38 | 55 | $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 |
| 56 | +
|
| 57 | + $platforms = "arm64", "x64", "ia32" |
| 58 | + $allVsixs = Get-ChildItem $publishArtifacts *.vsix |
| 59 | + foreach ($vsix in $allVsixs) { |
| 60 | + foreach ($plat in $platforms) { |
| 61 | + if ($vsix.Name.Contains($plat)) { |
| 62 | + $additionalPublishArgs += $vsix |
| 63 | + } |
| 64 | + } |
| 65 | + } |
| 66 | +
|
| 67 | + Write-Host "Command run is: vsce $($additionalPublishArgs)." |
| 68 | + If ("${{ parameters.test }}" -eq "true") { |
| 69 | + Write-Host "In test mode, command is printed instead of run." |
| 70 | + Write-Host "🔒 Verify PAT." |
| 71 | + vsce verify-pat ms-dotnettools |
| 72 | + } |
| 73 | + Else { |
| 74 | + vsce @additionalPublishArgs |
| 75 | + } |
| 76 | + displayName: 🚀 Publish to Marketplace |
| 77 | + workingDirectory: $(Pipeline.Workspace) |
44 | 78 | env:
|
45 |
| - VSCE_PAT: $(VisualStudioMarketplacePAT) |
| 79 | + VSCE_PAT: $(VSCodeMarketplacePAT) |
0 commit comments