Skip to content

Commit e90d412

Browse files
eng, use ESRP for typespec-java release (#3324)
1 parent aeb1a8a commit e90d412

2 files changed

Lines changed: 63 additions & 5 deletions

File tree

eng/pipelines/publish-typespec-java.yaml

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ extends:
1515
variables:
1616
- template: /eng/pipelines/variables/globals.yml
1717
- template: /eng/pipelines/variables/image.yml
18+
- name: buildArtifactsPath
19+
value: $(Pipeline.Workspace)/build_artifacts
1820

1921
pool:
2022
name: $(LINUXPOOL)
@@ -67,11 +69,43 @@ extends:
6769
env:
6870
GH_TOKEN: $(azuresdk-github-pat)
6971

70-
- script: |
71-
npm config set //registry.npmjs.org/:_authToken=$(azure-sdk-npm-token)
72-
ls *.tgz | npm publish -0 --access public
73-
npm config delete //registry.npmjs.org/:_authToken
72+
- pwsh: |
73+
New-Item -ItemType Directory -Path "$(buildArtifactsPath)/packages" -Force
74+
Copy-Item -Path "./typespec-extension/*.tgz" -Destination "$(buildArtifactsPath)/packages"
75+
displayName: 'Copy packages to artifacts staging directory'
76+
77+
# create npmrc file with auth
78+
- template: /eng/pipelines/templates/steps/create-authenticated-npmrc.yml
79+
parameters:
80+
npmrcPath: $(buildArtifactsPath)/packages/.npmrc
81+
registryUrl: https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js/npm/registry/
82+
83+
# publish to devops feed
84+
- pwsh: |
85+
$packageFiles = Get-ChildItem -Path . -Filter '*.tgz'
86+
foreach ($file in $packageFiles.Name) {
87+
Write-Host "npm publish $file --verbose --access public"
88+
npm publish $file --verbose --access public
89+
}
90+
displayName: Publish to DevOps feed
91+
workingDirectory: $(buildArtifactsPath)/packages
92+
93+
# publish to npmjs.org
94+
- task: EsrpRelease@11
7495
displayName: 'Publish TypeSpec Java to NPM'
75-
workingDirectory: ./typespec-extension
96+
inputs:
97+
ConnectedServiceName: Azure SDK PME Managed Identity
98+
ClientId: 5f81938c-2544-4f1f-9251-dd9de5b8a81b
99+
DomainTenantId: 975f013f-7f24-47e8-a7d3-abc4752bf346
100+
UseManagedIdentity: true
101+
KeyVaultName: kv-azuresdk-codesign
102+
SignCertName: azure-sdk-esrp-release-certificate
103+
Intent: PackageDistribution
104+
ContentType: npm
105+
FolderLocation: $(buildArtifactsPath)/packages
106+
Owners: ${{ coalesce(variables['Build.RequestedForEmail'], 'azuresdk@microsoft.com') }}
107+
Approvers: ${{ coalesce(variables['Build.RequestedForEmail'], 'azuresdk@microsoft.com') }}
108+
ServiceEndpointUrl: https://api.esrp.microsoft.com
109+
MainPublisher: ESRPRELPACMANTEST
76110

77111
- template: /eng/pipelines/steps/cleanup-maven-local-cache.yml
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
parameters:
2+
- name: npmrcPath
3+
type: string
4+
- name: registryUrl
5+
type: string
6+
7+
steps:
8+
- pwsh: |
9+
Write-Host "Creating .npmrc file ${{ parameters.npmrcPath }} for registry ${{ parameters.registryUrl }}"
10+
$parentFolder = Split-Path -Path '${{ parameters.npmrcPath }}' -Parent
11+
12+
if (!(Test-Path $parentFolder)) {
13+
Write-Host "Creating folder $parentFolder"
14+
New-Item -Path $parentFolder -ItemType Directory | Out-Null
15+
}
16+
17+
$content = "registry=${{ parameters.registryUrl }}`n`n" + "always-auth=true"
18+
$content | Out-File '${{ parameters.npmrcPath }}'
19+
displayName: "Create .npmrc"
20+
21+
- task: npmAuthenticate@0
22+
displayName: Authenticate .npmrc
23+
inputs:
24+
workingFile: ${{ parameters.npmrcPath }}

0 commit comments

Comments
 (0)