Skip to content

Commit 6fcf7bc

Browse files
authored
convet to azuredev pipelines (#488)
1 parent e500662 commit 6fcf7bc

37 files changed

+545
-2
lines changed

.npmrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Force public npm registry to avoid CI auth (E401) when no token is provided
2+
registry=https://registry.npmjs.org/
3+
# Do not require auth for public installs
4+
always-auth=false

.vscodeignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ noxfile.py
2424
**/requirements.txt
2525
**/requirements.in
2626
build/**
27-
**/tool/_debug_server.py
27+
**/tool/_debug_server.py
28+
packages.config
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Run on a schedule
2+
trigger: none
3+
pr: none
4+
5+
schedules:
6+
- cron: '0 10 * * 1-5' # 10AM UTC (2AM PDT) MON-FRI (VS Code Pre-release builds at 9PM PDT)
7+
displayName: Nightly Pre-Release Schedule
8+
always: false # only run if there are source code changes
9+
branches:
10+
include:
11+
- main
12+
13+
resources:
14+
repositories:
15+
- repository: MicroBuildTemplate
16+
type: git
17+
name: 1ESPipelineTemplates/MicroBuildTemplate
18+
ref: refs/tags/release
19+
variables:
20+
- name: TeamName
21+
value: VSCode-isort
22+
- name: VsixName
23+
value: isort.vsix
24+
- name: AZURE_ARTIFACTS_FEED
25+
value: 'https://devdiv.pkgs.visualstudio.com/DevDiv/_packaging/Pylance_PublicPackages/npm/registry/'
26+
parameters:
27+
- name: publishExtension
28+
displayName: 🚀 Publish Extension
29+
type: boolean
30+
default: false
31+
32+
extends:
33+
template: azure-pipelines/MicroBuild.1ES.Official.yml@MicroBuildTemplate
34+
parameters:
35+
sdl:
36+
sourceAnalysisPool: VSEngSS-MicroBuild2022-1ES
37+
codeSignValidation:
38+
enabled: true
39+
sbom:
40+
enabled: false # Disable global SBOM generation; we'll enable selectively per artifact output
41+
pool:
42+
name: AzurePipelines-EO
43+
os: windows
44+
45+
customBuildTags:
46+
- ES365AIMigrationTooling
47+
stages:
48+
- stage: Build
49+
displayName: Build & Package Extension
50+
jobs:
51+
- job: Build
52+
displayName: Build Job
53+
pool:
54+
name: VSEngSS-MicroBuild2022-1ES # use windows for codesigning to make things easier https://dev.azure.com/devdiv/DevDiv/_wiki/wikis/DevDiv.wiki/650/MicroBuild-Signing
55+
os: windows
56+
templateContext:
57+
mb:
58+
signing:
59+
enabled: true
60+
signType: real
61+
signWithProd: true
62+
outputs:
63+
- output: pipelineArtifact
64+
displayName: 'Publish Drop Artifact'
65+
targetPath: '$(Build.StagingDirectory)\drop'
66+
artifactName: drop
67+
sbomEnabled: true
68+
steps:
69+
- task: npmAuthenticate@0
70+
inputs:
71+
workingFile: .npmrc
72+
73+
- script: npm config get registry
74+
displayName: Verify NPM Registry
75+
76+
- task: NodeTool@0
77+
inputs:
78+
versionSpec: '22.x'
79+
checkLatest: true
80+
displayName: Select Node 22 LTS
81+
82+
- task: UsePythonVersion@0
83+
inputs:
84+
versionSpec: '3.9' # note Install Python dependencies step below relies on Python 3.9
85+
addToPath: true
86+
architecture: 'x64'
87+
displayName: Select Python version
88+
89+
- script: npm ci
90+
displayName: Install NPM dependencies
91+
92+
- script: python -m pip install -U pip
93+
displayName: Upgrade pip
94+
95+
- script: python -m pip install wheel
96+
displayName: Install wheel
97+
98+
- script: python -m pip install nox
99+
displayName: Install nox
100+
101+
- script: python -m nox --session install_bundled_libs
102+
displayName: Install Python dependencies
103+
104+
- script: python ./build/update_ext_version.py --for-publishing
105+
displayName: Update build number
106+
107+
- script: npm run vsce-package
108+
displayName: Build VSIX
109+
110+
- powershell: |
111+
New-Item -ItemType Directory -Path "$(Build.StagingDirectory)\drop" -Force | Out-Null; Copy-Item "$(Build.SourcesDirectory)\$(VsixName)" "$(Build.StagingDirectory)\drop\$(VsixName)" -Force; if (!(Test-Path "$(Build.StagingDirectory)\drop\$(VsixName)")) { Write-Error 'VSIX copy failed'; exit 1 }; Get-Item "$(Build.StagingDirectory)\drop\$(VsixName)" | Format-Table Name,Length,LastWriteTime -AutoSize
112+
displayName: Copy VSIX into drop
113+
114+
- script: npx vsce generate-manifest -i "$(Build.StagingDirectory)\drop\$(VsixName)" -o "$(Build.StagingDirectory)\drop\extension.manifest"
115+
displayName: Generate extension manifest
116+
117+
- template: build/templates/sign.yml@self
118+
parameters:
119+
vsixName: $(VsixName)
120+
workingDirectory: $(Build.StagingDirectory)\drop
121+
signType: real
122+
verifySignature: true
123+
124+
- ${{ if eq(parameters.publishExtension, true) }}:
125+
- template: build/templates/publish.yml@self
126+
parameters:
127+
azureSubscription: PylancePublishPipelineSecureConnectionWithManagedIdentity
128+
vsixName: $(VsixName)
129+
manifestName: extension.manifest
130+
signatureName: extension.signature.p7s
131+
publishFolder: drop
132+
preRelease: true
133+
noVerify: true
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Publish Release
2+
trigger:
3+
branches:
4+
include:
5+
- refs/tags/*
6+
7+
resources:
8+
repositories:
9+
- repository: MicroBuildTemplate
10+
type: git
11+
name: 1ESPipelineTemplates/MicroBuildTemplate
12+
ref: refs/tags/release
13+
variables:
14+
- name: TeamName
15+
value: VSCode-isort
16+
- name: VsixName
17+
value: isort.vsix
18+
19+
parameters:
20+
- name: publishExtension
21+
displayName: 🚀 Publish Extension
22+
type: boolean
23+
default: false
24+
25+
extends:
26+
template: azure-pipelines/MicroBuild.1ES.Official.yml@MicroBuildTemplate
27+
parameters:
28+
sdl:
29+
sourceAnalysisPool: VSEngSS-MicroBuild2022-1ES
30+
codeSignValidation:
31+
enabled: true
32+
sbom:
33+
enabled: false # Disable global SBOM generation; we'll enable selectively per artifact output
34+
pool:
35+
name: AzurePipelines-EO
36+
os: windows
37+
38+
customBuildTags:
39+
- ES365AIMigrationTooling
40+
stages:
41+
- stage: Build
42+
displayName: Build & Package Extension
43+
jobs:
44+
- job: Build
45+
displayName: Build Job
46+
pool:
47+
name: VSEngSS-MicroBuild2022-1ES # use windows for codesigning to make things easier https://dev.azure.com/devdiv/DevDiv/_wiki/wikis/DevDiv.wiki/650/MicroBuild-Signing
48+
os: windows
49+
templateContext:
50+
mb:
51+
signing:
52+
enabled: true
53+
signType: real
54+
signWithProd: true
55+
outputs:
56+
- output: pipelineArtifact
57+
displayName: 'Publish Drop Artifact'
58+
targetPath: '$(Build.StagingDirectory)\drop'
59+
artifactName: drop
60+
sbomEnabled: true
61+
steps:
62+
- task: NodeTool@0
63+
inputs:
64+
versionSpec: '22.x'
65+
checkLatest: true
66+
displayName: Select Node 22 LTS
67+
- task: UsePythonVersion@0
68+
inputs:
69+
versionSpec: '3.9' # note Install Python dependencies step below relies on Python 3.9
70+
addToPath: true
71+
architecture: 'x64'
72+
displayName: Select Python version
73+
74+
- script: npm ci
75+
displayName: Install NPM dependencies
76+
77+
- script: python -m pip install -U pip
78+
displayName: Upgrade pip
79+
80+
- script: python -m pip install wheel
81+
displayName: Install wheel
82+
83+
- script: python -m pip install nox
84+
displayName: Install nox
85+
86+
- script: python -m nox --session install_bundled_libs
87+
displayName: Install Python dependencies
88+
89+
- script: python ./build/update_ext_version.py --release --for-publishing
90+
displayName: Update build number
91+
92+
- script: npm run vsce-package
93+
displayName: Build VSIX
94+
95+
- powershell: |
96+
New-Item -ItemType Directory -Path "$(Build.StagingDirectory)\drop" -Force | Out-Null; Copy-Item "$(Build.SourcesDirectory)\$(VsixName)" "$(Build.StagingDirectory)\drop\$(VsixName)" -Force; if (!(Test-Path "$(Build.StagingDirectory)\drop\$(VsixName)")) { Write-Error 'VSIX copy failed'; exit 1 }; Get-Item "$(Build.StagingDirectory)\drop\$(VsixName)" | Format-Table Name,Length,LastWriteTime -AutoSize
97+
displayName: Copy VSIX into drop
98+
99+
- script: npx vsce generate-manifest -i "$(Build.StagingDirectory)\drop\$(VsixName)" -o "$(Build.StagingDirectory)\drop\extension.manifest"
100+
displayName: Generate extension manifest
101+
102+
- template: build/templates/sign.yml@self
103+
parameters:
104+
vsixName: $(VsixName)
105+
workingDirectory: $(Build.StagingDirectory)\drop
106+
signType: real
107+
verifySignature: true
108+
109+
- ${{ if eq(parameters.publishExtension, true) }}:
110+
- template: build/templates/publish.yml@self
111+
parameters:
112+
azureSubscription: PylancePublishPipelineSecureConnectionWithManagedIdentity
113+
vsixName: $(VsixName)
114+
manifestName: extension.manifest
115+
signatureName: extension.signature.p7s
116+
publishFolder: drop
117+
preRelease: false
118+
noVerify: true
119+

build/templates/publish.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Template (steps): PublishMarketplace for autopep8 extension
2+
# Expects working directory already populated (or artifact previously downloaded) with: autopep8.vsix, extension.manifest, extension.signature.p7s
3+
# Provides optional prerelease publishing via parameter.
4+
#
5+
# Usage (example inside a stage job):
6+
# steps:
7+
# - template: build/templates/publish.yml@self
8+
# parameters:
9+
# azureSubscription: Autopep8PublishServiceConnection
10+
# artifactName: drop
11+
# vsixName: autopep8.vsix
12+
# manifestName: extension.manifest
13+
# signatureName: extension.signature.p7s
14+
# publishFolder: vscode-autopep8
15+
# preRelease: true
16+
# noVerify: true
17+
#
18+
# Notes:
19+
# - Azure DevOps Marketplace resource GUID (499b84ac-1321-427f-aa17-267ca6975798) is hardcoded in publish script.
20+
# - This uses Managed Identity via AzureCLI@2 to acquire an AAD token and passes it as a PAT.
21+
# - Requires extension artifacts already signed (signature file present).
22+
# - Node & vsce expected to be prepared by parent pipeline; omit local installation here.
23+
24+
parameters:
25+
- name: azureSubscription
26+
type: string
27+
- name: vsixName
28+
type: string
29+
default: autopep8.vsix
30+
- name: manifestName
31+
type: string
32+
default: extension.manifest
33+
- name: signatureName
34+
type: string
35+
default: extension.signature.p7s
36+
- name: publishFolder
37+
type: string
38+
default: vscode-autopep8
39+
- name: preRelease
40+
type: boolean
41+
default: false
42+
- name: noVerify
43+
type: boolean
44+
default: true
45+
46+
steps:
47+
# Node & vsce expected to be prepared by parent pipeline; omit local installation.
48+
49+
# Assumes files already present at $(Build.ArtifactStagingDirectory)/publishFolder
50+
51+
# Step 1: Acquire token only (store secret variable MarketplaceAADToken)
52+
- task: AzureCLI@2
53+
displayName: Acquire Marketplace AAD token
54+
inputs:
55+
azureSubscription: ${{ parameters.azureSubscription }}
56+
scriptType: pscore
57+
scriptLocation: inlineScript
58+
inlineScript: |
59+
$resource = "499b84ac-1321-427f-aa17-267ca6975798"
60+
Write-Host "Acquiring AAD token for resource: $resource"
61+
az rest -u https://app.vssps.visualstudio.com/_apis/profile/profiles/me --resource $resource | Out-Null
62+
$aadToken = az account get-access-token --query accessToken --resource $resource -o tsv
63+
if (-not $aadToken) { Write-Error 'Failed to acquire AAD token.'; exit 1 }
64+
Write-Host "##vso[task.setvariable variable=MarketplaceAADToken;isSecret=true]$aadToken"
65+
Write-Host "Token stored in secret variable MarketplaceAADToken"
66+
67+
# Step 2: Validate artifacts & publish
68+
- task: PowerShell@2
69+
displayName: Publish extension (vsce)
70+
inputs:
71+
targetType: inline
72+
script: |
73+
$aadToken = "$(MarketplaceAADToken)"
74+
if (-not $aadToken) { Write-Error 'MarketplaceAADToken is empty (token acquisition failed).'; exit 1 }
75+
76+
$root = "$(Build.ArtifactStagingDirectory)/${{ parameters.publishFolder }}"
77+
$vsixPath = Join-Path $root "${{ parameters.vsixName }}"
78+
$manifestPath = Join-Path $root "${{ parameters.manifestName }}"
79+
$signaturePath = Join-Path $root "${{ parameters.signatureName }}"
80+
81+
Write-Host "VSIX Path: $vsixPath"
82+
Write-Host "Manifest Path: $manifestPath"
83+
Write-Host "Signature Path: $signaturePath"
84+
85+
if (-not (Test-Path $vsixPath)) { Write-Error "VSIX file not found: $vsixPath"; exit 1 }
86+
if (-not (Test-Path $manifestPath)) { Write-Error "Manifest file not found: $manifestPath"; exit 1 }
87+
if (-not (Test-Path $signaturePath)) { Write-Error "Signature file not found: $signaturePath"; exit 1 }
88+
89+
Write-Host "Listing publish folder contents: $root"
90+
Get-ChildItem -Recurse $root | Select-Object FullName,Length | Format-Table -AutoSize
91+
92+
$extraFlags = ''
93+
if ('${{ parameters.noVerify }}' -eq 'True') { $extraFlags = "$extraFlags --noVerify" }
94+
95+
if ('${{ parameters.preRelease }}' -eq 'True') {
96+
Write-Host 'Publishing as pre-release'
97+
# disabled for now; uncomment when ready
98+
npx vsce publish --pat $aadToken --packagePath $vsixPath --manifestPath $manifestPath --signaturePath $signaturePath $extraFlags --pre-release
99+
} else {
100+
Write-Host 'Publishing as stable release'
101+
# disabled for now; uncomment when ready
102+
npx vsce publish --pat $aadToken --packagePath $vsixPath --manifestPath $manifestPath --signaturePath $signaturePath $extraFlags
103+
}
104+
105+
if ($LASTEXITCODE -ne 0) {
106+
Write-Error "vsce publish failed with exit code $LASTEXITCODE"
107+
exit $LASTEXITCODE
108+
}
109+
Write-Host 'Publish step completed (publish command currently disabled).'
110+
111+
- task: PowerShell@2
112+
displayName: Post-publish summary
113+
inputs:
114+
targetType: inline
115+
script: |
116+
Write-Host 'Published extension artifacts:'
117+
Get-ChildItem "$(Build.ArtifactStagingDirectory)/${{ parameters.publishFolder }}" -File | Select-Object Name,Length | Format-Table -AutoSize
118+
Write-Host "Pre-release parameter: ${{ parameters.preRelease }}"

0 commit comments

Comments
 (0)