|
| 1 | +name: $(Date:yyyyMMdd)$(Rev:.r) |
| 2 | + |
| 3 | +trigger: none |
| 4 | +pr: none |
| 5 | + |
| 6 | +resources: |
| 7 | + repositories: |
| 8 | + - repository: MicroBuildTemplate |
| 9 | + type: git |
| 10 | + name: 1ESPipelineTemplates/MicroBuildTemplate |
| 11 | + ref: refs/tags/release |
| 12 | + |
| 13 | +parameters: |
| 14 | + - name: quality |
| 15 | + displayName: 📦 Release Quality |
| 16 | + type: string |
| 17 | + default: stable |
| 18 | + values: |
| 19 | + - stable |
| 20 | + - preview |
| 21 | + |
| 22 | + - name: publishPackage |
| 23 | + displayName: 🚀 Publish npm |
| 24 | + type: boolean |
| 25 | + default: false |
| 26 | + |
| 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 | + |
| 52 | +variables: |
| 53 | + - name: TeamName |
| 54 | + value: vscode-python-environments |
| 55 | + - name: PackageName |
| 56 | + value: '@vscode/python-environments' |
| 57 | + - name: PackageDir |
| 58 | + value: pythonEnvironmentsApi |
| 59 | + - name: npmTag |
| 60 | + ${{ if eq(parameters.quality, 'preview') }}: |
| 61 | + value: next |
| 62 | + ${{ else }}: |
| 63 | + 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/' |
| 76 | + |
| 77 | +extends: |
| 78 | + template: azure-pipelines/MicroBuild.1ES.Official.yml@MicroBuildTemplate |
| 79 | + parameters: |
| 80 | + sdl: |
| 81 | + sourceAnalysisPool: VSEngSS-MicroBuild2022-1ES |
| 82 | + codeSignValidation: |
| 83 | + enabled: true |
| 84 | + sbom: |
| 85 | + enabled: true |
| 86 | + pool: |
| 87 | + name: AzurePipelines-EO |
| 88 | + image: 1ESPT-Ubuntu22.04 |
| 89 | + os: linux |
| 90 | + |
| 91 | + customBuildTags: |
| 92 | + - ES365AIMigrationTooling |
| 93 | + |
| 94 | + stages: |
| 95 | + - stage: Build |
| 96 | + displayName: Build & Pack |
| 97 | + jobs: |
| 98 | + - job: BuildPackage |
| 99 | + displayName: Build npm package |
| 100 | + templateContext: |
| 101 | + outputs: |
| 102 | + - output: pipelineArtifact |
| 103 | + targetPath: $(Build.ArtifactStagingDirectory) |
| 104 | + artifactName: npm-package |
| 105 | + steps: |
| 106 | + - ${{ each step in parameters.buildSteps }}: |
| 107 | + - ${{ step }} |
| 108 | + |
| 109 | + - task: CopyFiles@2 |
| 110 | + displayName: Copy package tarball to staging |
| 111 | + inputs: |
| 112 | + sourceFolder: $(Build.SourcesDirectory)/pythonEnvironmentsApi |
| 113 | + contents: '*.tgz' |
| 114 | + targetFolder: $(Build.ArtifactStagingDirectory) |
| 115 | + |
| 116 | + - stage: Publish |
| 117 | + displayName: Publish to Azure Artifacts |
| 118 | + dependsOn: Build |
| 119 | + condition: and(succeeded(), eq('${{ parameters.publishPackage }}', 'true')) |
| 120 | + jobs: |
| 121 | + - 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 |
| 130 | + 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 |
0 commit comments