Skip to content

Commit 5013844

Browse files
committed
Use ESRP for publishing
1 parent c31d45e commit 5013844

10 files changed

Lines changed: 20 additions & 112 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: 18 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ parameters:
3838
displayName: Select Node version
3939

4040
- script: npm install
41-
workingDirectory: $(Build.SourcesDirectory)/pythonEnvironmentsApi
41+
workingDirectory: $(Build.SourcesDirectory)/api
4242
displayName: Install package dependencies
4343

4444
- script: npm run compile
45-
workingDirectory: $(Build.SourcesDirectory)/pythonEnvironmentsApi
45+
workingDirectory: $(Build.SourcesDirectory)/api
4646
displayName: Compile TypeScript
4747

4848
- script: npm pack --ignore-scripts
49-
workingDirectory: $(Build.SourcesDirectory)/pythonEnvironmentsApi
49+
workingDirectory: $(Build.SourcesDirectory)/api
5050
displayName: Pack npm package
5151

5252
variables:
@@ -55,7 +55,7 @@ variables:
5555
- name: PackageName
5656
value: '@vscode/python-environments'
5757
- name: PackageDir
58-
value: pythonEnvironmentsApi
58+
value: api
5959
- name: npmTag
6060
${{ if eq(parameters.quality, 'preview') }}:
6161
value: next
@@ -75,7 +75,7 @@ variables:
7575
value: 'pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/npm/registry/'
7676

7777
extends:
78-
template: azure-pipelines/MicroBuild.1ES.Official.yml@MicroBuildTemplate
78+
template: azure-pipelines/MicroBuild.1ES.Official.Publish.yml@MicroBuildTemplate
7979
parameters:
8080
sdl:
8181
sourceAnalysisPool: VSEngSS-MicroBuild2022-1ES
@@ -109,116 +109,24 @@ extends:
109109
- task: CopyFiles@2
110110
displayName: Copy package tarball to staging
111111
inputs:
112-
sourceFolder: $(Build.SourcesDirectory)/pythonEnvironmentsApi
112+
sourceFolder: $(Build.SourcesDirectory)/api
113113
contents: '*.tgz'
114114
targetFolder: $(Build.ArtifactStagingDirectory)
115115

116-
- stage: Publish
117-
displayName: Publish to Azure Artifacts
116+
- stage: Publish to NPM
117+
displayName: Publish to NPM
118118
dependsOn: Build
119119
condition: and(succeeded(), eq('${{ parameters.publishPackage }}', 'true'))
120120
jobs:
121121
- 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
122+
displayName: Publish npm package
130123
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
124+
- template: MicroBuild.Publish.yml@MicroBuildTemplate
125+
parameters:
126+
intent: 'PackageDistribution'
127+
contentType: 'npm'
128+
contentSource: 'pipelineArtifact'
129+
folderLocation: '$(Build.ArtifactStagingDirectory)'
130+
waitForReleaseCompletion: true
131+
owners: 'plseng@microsoft.com'
132+
approvers: 'eduardovil@microsoft.com;grwheele@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)