Skip to content

Commit 1db132b

Browse files
authored
Publish to NPM instead of custom feed (#1478)
The PythonEnvironmentsAPI is intended to allow other people's codes to communicate with this extensions to leverage its functionality. This includes for example, several Python VSCode Extensions. Hence, it should be easily available to all via the npmjs.com registry. =========== This pull request updates the build and publishing pipeline for the npm package, primarily to reflect the renaming of the package directory from `pythonEnvironmentsApi` to `api` and to simplify the publishing process. The changes also streamline the pipeline by removing legacy steps and variables related to Azure Artifacts and the msft_consumption feed, and by updating the publishing mechanism to use a new template. Key updates include: **Pipeline directory and variable updates:** * All references to the package directory have been updated from `pythonEnvironmentsApi` to `api` in the pipeline configuration and variables, ensuring consistency with the new directory structure. [[1]](diffhunk://#diff-2836c583ae31cc43d5ca54afe3e6130263d83b3661456664e443e25c951e6110L27-R41) [[2]](diffhunk://#diff-2836c583ae31cc43d5ca54afe3e6130263d83b3661456664e443e25c951e6110L106-R113) * The `homepage` field in `api/package.json` is updated to point to the new `api` directory. **Pipeline simplification and publishing changes:** * The pipeline template now uses `MicroBuild.1ES.Official.Publish.yml` instead of the previous template, and the build steps for installing dependencies, compiling, and packaging have been inlined instead of being parameterized. [[1]](diffhunk://#diff-2836c583ae31cc43d5ca54afe3e6130263d83b3661456664e443e25c951e6110L27-R41) [[2]](diffhunk://#diff-2836c583ae31cc43d5ca54afe3e6130263d83b3661456664e443e25c951e6110L106-R113) * The stages and jobs related to publishing to Azure Artifacts and the msft_consumption feed, including managed identity authentication and custom `.npmrc` creation, have been removed. Instead, publishing now uses a standardized MicroBuild template for npm package distribution. These changes help modernize and simplify the build and release process for the npm package.
1 parent c31d45e commit 1db132b

10 files changed

Lines changed: 37 additions & 148 deletions

File tree

File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"vscode": "^1.110.0"
1919
},
2020
"license": "MIT",
21-
"homepage": "https://github.com/microsoft/vscode-python-environments/tree/main/pythonEnvironmentsApi",
21+
"homepage": "https://github.com/microsoft/vscode-python-environments/tree/main/api",
2222
"repository": {
2323
"type": "git",
2424
"url": "https://github.com/microsoft/vscode-python-environments"

build/azure-pipeline.npm.yml

Lines changed: 35 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -24,58 +24,21 @@ parameters:
2424
type: boolean
2525
default: false
2626

27-
- name: publishToConsumptionFeed
28-
displayName: 📡 Publish to msft_consumption feed
29-
type: boolean
30-
default: false
31-
32-
- name: buildSteps
33-
type: stepList
34-
default:
35-
- task: NodeTool@0
36-
inputs:
37-
versionSpec: '22.21.1'
38-
displayName: Select Node version
39-
40-
- script: npm install
41-
workingDirectory: $(Build.SourcesDirectory)/pythonEnvironmentsApi
42-
displayName: Install package dependencies
43-
44-
- script: npm run compile
45-
workingDirectory: $(Build.SourcesDirectory)/pythonEnvironmentsApi
46-
displayName: Compile TypeScript
47-
48-
- script: npm pack --ignore-scripts
49-
workingDirectory: $(Build.SourcesDirectory)/pythonEnvironmentsApi
50-
displayName: Pack npm package
51-
5227
variables:
5328
- name: TeamName
5429
value: vscode-python-environments
5530
- name: PackageName
5631
value: '@vscode/python-environments'
5732
- name: PackageDir
58-
value: pythonEnvironmentsApi
33+
value: api
5934
- name: npmTag
6035
${{ if eq(parameters.quality, 'preview') }}:
6136
value: next
6237
${{ else }}:
6338
value: latest
64-
- name: AzureArtifactsFeedUrl
65-
value: 'https://pkgs.dev.azure.com/azure-public/vside/_packaging/python-environments/npm/registry/'
66-
# Same URL without the https:// prefix (used in .npmrc auth lines)
67-
- name: AzureArtifactsFeedUrlNoProtocol
68-
value: 'pkgs.dev.azure.com/azure-public/vside/_packaging/python-environments/npm/registry/'
69-
# Managed Identity service connection for Azure Artifacts auth (shared with Pylance)
70-
- name: AzureServiceConnection
71-
value: 'PylanceSecureVsIdePublishWithManagedIdentity'
72-
- name: ConsumptionFeedUrl
73-
value: 'https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/npm/registry/'
74-
- name: ConsumptionFeedUrlNoProtocol
75-
value: 'pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/npm/registry/'
7639

7740
extends:
78-
template: azure-pipelines/MicroBuild.1ES.Official.yml@MicroBuildTemplate
41+
template: azure-pipelines/MicroBuild.1ES.Official.Publish.yml@MicroBuildTemplate
7942
parameters:
8043
sdl:
8144
sourceAnalysisPool: VSEngSS-MicroBuild2022-1ES
@@ -103,122 +66,48 @@ extends:
10366
targetPath: $(Build.ArtifactStagingDirectory)
10467
artifactName: npm-package
10568
steps:
106-
- ${{ each step in parameters.buildSteps }}:
107-
- ${{ step }}
69+
- task: NodeTool@0
70+
inputs:
71+
versionSpec: '22.21.1'
72+
displayName: Select Node version
73+
74+
- script: npm install
75+
workingDirectory: $(Build.SourcesDirectory)/api
76+
displayName: Install package dependencies
77+
78+
- script: npm run compile
79+
workingDirectory: $(Build.SourcesDirectory)/api
80+
displayName: Compile TypeScript
81+
82+
- script: npm pack --ignore-scripts
83+
workingDirectory: $(Build.SourcesDirectory)/api
84+
displayName: Pack npm package
10885

10986
- task: CopyFiles@2
11087
displayName: Copy package tarball to staging
11188
inputs:
112-
sourceFolder: $(Build.SourcesDirectory)/pythonEnvironmentsApi
89+
sourceFolder: $(Build.SourcesDirectory)/api
11390
contents: '*.tgz'
11491
targetFolder: $(Build.ArtifactStagingDirectory)
11592

116-
- stage: Publish
117-
displayName: Publish to Azure Artifacts
93+
- stage: PublishNPM
94+
displayName: Publish to NPM
11895
dependsOn: Build
11996
condition: and(succeeded(), eq('${{ parameters.publishPackage }}', 'true'))
12097
jobs:
12198
- job: PublishPackage
122-
displayName: Publish $(PackageName)
123-
templateContext:
124-
type: releaseJob
125-
isProduction: true
126-
inputs:
127-
- input: pipelineArtifact
128-
artifactName: npm-package
129-
targetPath: $(Pipeline.Workspace)/npm-package
99+
displayName: Publish npm package
130100
steps:
131-
- checkout: none
132-
133-
- task: NodeTool@0
134-
inputs:
135-
versionSpec: '22.21.1'
136-
displayName: Select Node version
137-
138-
# Acquire a short-lived AAD token via Managed Identity (no stored secrets)
139-
# SEE https://eng.ms/docs/cloud-ai-platform/devdiv/one-engineering-system-1es/1es-docs/1es-security-configuration/configuration-guides/pat-burndown-guidance
140-
- task: AzureCLI@2
141-
displayName: Acquire AAD token via Managed Identity
142-
inputs:
143-
azureSubscription: '$(AzureServiceConnection)'
144-
scriptType: 'pscore'
145-
scriptLocation: 'inlineScript'
146-
inlineScript: |
147-
$token = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv
148-
Write-Host "##vso[task.setvariable variable=AzdoToken;issecret=true]$token"
149-
150-
- powershell: |
151-
@"
152-
registry=$(AzureArtifactsFeedUrl)
153-
always-auth=true
154-
"@ | Out-File -FilePath .npmrc
155-
156-
@"
157-
; begin auth token
158-
//$(AzureArtifactsFeedUrlNoProtocol):username=VssSessionToken
159-
//$(AzureArtifactsFeedUrlNoProtocol):_authToken=$env:AZDO_TOKEN
160-
//$(AzureArtifactsFeedUrlNoProtocol):email=not-used@example.com
161-
; end auth token
162-
"@ | Out-File -FilePath $HOME/.npmrc
163-
env:
164-
AZDO_TOKEN: $(AzdoToken)
165-
displayName: Create .npmrc files
166-
167-
- powershell: |
168-
$tgz = Get-ChildItem "$(Pipeline.Workspace)/npm-package/*.tgz" | Select-Object -First 1
169-
if (-not $tgz) {
170-
Write-Error "No .tgz file found in $(Pipeline.Workspace)/npm-package/"
171-
exit 1
172-
}
173-
Write-Host "Publishing: $($tgz.FullName)"
174-
if ("$(npmTag)" -eq "next") {
175-
npm publish $tgz.FullName --registry $(AzureArtifactsFeedUrl) --tag next --ignore-scripts
176-
} else {
177-
npm publish $tgz.FullName --registry $(AzureArtifactsFeedUrl) --ignore-scripts
178-
}
179-
displayName: npm publish (${{ parameters.quality }})
180-
181-
- stage: PublishConsumption
182-
displayName: Publish package to msft_consumption feed
183-
dependsOn: Publish
184-
condition: and(not(failed()), eq('${{ parameters.publishToConsumptionFeed }}', 'true'))
185-
jobs:
186-
- job: PullToConsumption
187-
displayName: Pull $(PackageName) to msft_consumption
188-
steps:
189-
- checkout: none
190-
191-
- task: NodeTool@0
192-
inputs:
193-
versionSpec: '22.21.1'
194-
displayName: Select Node version
195-
196-
- task: AzureCLI@2
197-
displayName: Acquire AAD token via Managed Identity
198-
inputs:
199-
azureSubscription: '$(AzureServiceConnection)'
200-
scriptType: 'pscore'
201-
scriptLocation: 'inlineScript'
202-
inlineScript: |
203-
$token = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv
204-
Write-Host "##vso[task.setvariable variable=AzdoToken;issecret=true]$token"
205-
206-
- powershell: |
207-
@"
208-
registry=$(ConsumptionFeedUrl)
209-
always-auth=true
210-
"@ | Out-File -FilePath .npmrc
211-
212-
@"
213-
; begin auth token
214-
//$(ConsumptionFeedUrlNoProtocol):username=VssSessionToken
215-
//$(ConsumptionFeedUrlNoProtocol):_authToken=$env:AZDO_TOKEN
216-
//$(ConsumptionFeedUrlNoProtocol):email=not-used@example.com
217-
; end auth token
218-
"@ | Out-File -FilePath $HOME/.npmrc
219-
env:
220-
AZDO_TOKEN: $(AzdoToken)
221-
displayName: Create .npmrc files
222-
223-
- script: npm i -g $(PackageName)@$(npmTag) --registry $(ConsumptionFeedUrl)
224-
displayName: Pull to msft_consumption
101+
- download: current
102+
artifact: npm-package
103+
displayName: Download npm-package artifact
104+
105+
- template: MicroBuild.Publish.yml@MicroBuildTemplate
106+
parameters:
107+
intent: 'PackageDistribution'
108+
contentType: 'npm'
109+
contentSource: 'Folder'
110+
folderLocation: '$(Pipeline.Workspace)/npm-package'
111+
waitForReleaseCompletion: true
112+
owners: 'grwheele@microsoft.com'
113+
approvers: 'eduardovil@microsoft.com'

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
"resolveJsonModule": true,
1818
"removeComments": true
1919
},
20-
"exclude": ["examples", "pythonEnvironmentsApi"]
20+
"exclude": ["examples", "api"]
2121
}

0 commit comments

Comments
 (0)