Skip to content

Commit f049538

Browse files
committed
split publsh into its own step
1 parent 14c670a commit f049538

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

build/templates/publish.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,30 @@ steps:
5757
5858
# Assumes files already present at $(Build.ArtifactStagingDirectory)/publishFolder
5959

60+
# Step 1: Acquire token only (store secret variable MarketplaceAADToken)
6061
- task: AzureCLI@2
61-
displayName: Acquire token & publish extension
62+
displayName: Acquire Marketplace AAD token
6263
inputs:
6364
azureSubscription: ${{ parameters.azureSubscription }}
6465
scriptType: pscore
6566
scriptLocation: inlineScript
6667
inlineScript: |
67-
# Hardcoded Azure DevOps Marketplace resource GUID
6868
$resource = "499b84ac-1321-427f-aa17-267ca6975798"
6969
Write-Host "Acquiring AAD token for resource: $resource"
7070
az rest -u https://app.vssps.visualstudio.com/_apis/profile/profiles/me --resource $resource | Out-Null
7171
$aadToken = az account get-access-token --query accessToken --resource $resource -o tsv
7272
if (-not $aadToken) { Write-Error 'Failed to acquire AAD token.'; exit 1 }
73+
Write-Host "##vso[task.setvariable variable=MarketplaceAADToken;isSecret=true]$aadToken"
74+
Write-Host "Token stored in secret variable MarketplaceAADToken"
75+
76+
# Step 2: Validate artifacts & publish
77+
- task: PowerShell@2
78+
displayName: Publish extension (vsce)
79+
inputs:
80+
targetType: inline
81+
script: |
82+
$aadToken = "$(MarketplaceAADToken)"
83+
if (-not $aadToken) { Write-Error 'MarketplaceAADToken is empty (token acquisition failed).'; exit 1 }
7384
7485
$root = "$(Build.ArtifactStagingDirectory)/${{ parameters.publishFolder }}"
7586
$vsixPath = Join-Path $root "${{ parameters.vsixName }}"
@@ -92,19 +103,19 @@ steps:
92103
93104
if ('${{ parameters.preRelease }}' -eq 'True') {
94105
Write-Host 'Publishing as pre-release'
95-
# disable for now
96-
#npx @vscode/vsce@latest publish --pat $aadToken --packagePath $vsixPath --manifestPath $manifestPath --signaturePath $signaturePath $extraFlags --pre-release
106+
# disabled for now; uncomment when ready
107+
# vsce publish --pat $aadToken --packagePath $vsixPath --manifestPath $manifestPath --signaturePath $signaturePath $extraFlags --pre-release
97108
} else {
98109
Write-Host 'Publishing as stable release'
99-
# disable for now
100-
#npx @vscode/vsce@latest publish --pat $aadToken --packagePath $vsixPath --manifestPath $manifestPath --signaturePath $signaturePath $extraFlags
110+
# disabled for now; uncomment when ready
111+
# vsce publish --pat $aadToken --packagePath $vsixPath --manifestPath $manifestPath --signaturePath $signaturePath $extraFlags
101112
}
102113
103114
if ($LASTEXITCODE -ne 0) {
104115
Write-Error "vsce publish failed with exit code $LASTEXITCODE"
105116
exit $LASTEXITCODE
106117
}
107-
Write-Host 'Publish succeeded ✅'
118+
Write-Host 'Publish step completed (publish command currently disabled).'
108119
109120
- task: PowerShell@2
110121
displayName: Post-publish summary

0 commit comments

Comments
 (0)