|
| 1 | +parameters: |
| 2 | + Tag: 'latest' |
| 3 | + ArtifactName: 'packages' |
| 4 | + DependsOn: [] |
| 5 | + Environment: 'package-publish' |
| 6 | + Registry: 'https://registry.npmjs.org/' |
| 7 | + |
| 8 | +jobs: |
| 9 | +- deployment: PublishPackage_${{ parameters.ArtifactName }} |
| 10 | + displayName: 'Publish ${{ parameters.ArtifactName }} to ${{ parameters.Registry }}' |
| 11 | + environment: ${{ parameters.Environment }} |
| 12 | + dependsOn: ${{ parameters.DependsOn }} |
| 13 | + variables: |
| 14 | + - name: ArtifactPath |
| 15 | + value: $(Pipeline.Workspace)/${{ parameters.ArtifactName }} |
| 16 | + |
| 17 | + templateContext: |
| 18 | + type: releaseJob |
| 19 | + isProduction: ${{ eq(parameters.Registry, 'https://registry.npmjs.org/') }} |
| 20 | + inputs: |
| 21 | + - input: pipelineArtifact |
| 22 | + artifactName: ${{ parameters.ArtifactName }} |
| 23 | + itemPattern: '**/*.tgz' |
| 24 | + targetPath: $(ArtifactPath) |
| 25 | + |
| 26 | + pool: |
| 27 | + name: azsdk-pool |
| 28 | + image: ubuntu-24.04 |
| 29 | + os: linux |
| 30 | + |
| 31 | + strategy: |
| 32 | + runOnce: |
| 33 | + deploy: |
| 34 | + steps: |
| 35 | + - pwsh: | |
| 36 | + foreach ($package in (dir $(ArtifactPath) *.tgz -Recurse)) { |
| 37 | + Write-Host "Publishing $package to ${{ parameters.Registry }} with tag ${{ parameters.Tag }}" |
| 38 | + } |
| 39 | + displayName: 'Display packages to be published' |
| 40 | +
|
| 41 | + - ${{ if eq(parameters.Registry, 'https://registry.npmjs.org/') }}: |
| 42 | + - task: EsrpRelease@9 |
| 43 | + displayName: 'Publish ${{ parameters.ArtifactName }} via ESRP' |
| 44 | + inputs: |
| 45 | + ConnectedServiceName: 'Azure SDK PME Managed Identity' |
| 46 | + ClientId: '5f81938c-2544-4f1f-9251-dd9de5b8a81b' |
| 47 | + DomainTenantId: '975f013f-7f24-47e8-a7d3-abc4752bf346' |
| 48 | + Usemanagedidentity: true |
| 49 | + KeyVaultName: 'kv-azuresdk-codesign' |
| 50 | + SignCertName: 'azure-sdk-esrp-release-certificate' |
| 51 | + Intent: 'PackageDistribution' |
| 52 | + ContentType: 'npm' |
| 53 | + FolderLocation: $(ArtifactPath) |
| 54 | + Owners: ${{ coalesce(variables['Build.RequestedForEmail'], 'azuresdk@microsoft.com') }} |
| 55 | + Approvers: ${{ coalesce(variables['Build.RequestedForEmail'], 'azuresdk@microsoft.com') }} |
| 56 | + ServiceEndpointUrl: 'https://api.esrp.microsoft.com' |
| 57 | + MainPublisher: 'ESRPRELPACMANTEST' |
| 58 | + productstate: ${{ parameters.Tag }} |
| 59 | + |
| 60 | + - ${{ else }}: |
| 61 | + - template: /eng/common/pipelines/templates/steps/create-authenticated-npmrc.yml |
| 62 | + parameters: |
| 63 | + npmrcPath: $(ArtifactPath)/.npmrc |
| 64 | + registryUrl: ${{ parameters.Registry }} |
| 65 | + |
| 66 | + - pwsh: | |
| 67 | + foreach ($package in (dir $(ArtifactPath) *.tgz -Recurse)) { |
| 68 | + Write-Host "npm publish $package --verbose --access public --tag ${{ parameters.Tag }} --registry ${{ parameters.Registry }}" |
| 69 | + npm publish $package --verbose --access public --tag ${{ parameters.Tag }} --registry ${{ parameters.Registry }} |
| 70 | + if ($LASTEXITCODE -ne 0) { |
| 71 | + Write-Error "Failed to publish $package to ${{ parameters.Registry }}" |
| 72 | + exit $LASTEXITCODE |
| 73 | + } |
| 74 | + } |
| 75 | + displayName: 'Publish ${{ parameters.ArtifactName }}' |
| 76 | + workingDirectory: $(ArtifactPath) |
| 77 | + |
0 commit comments