Skip to content

Commit 67883ba

Browse files
first copy tgz to $(buildArtifactsPath)/packages
1 parent 580316b commit 67883ba

2 files changed

Lines changed: 49 additions & 1 deletion

File tree

eng/pipelines/publish-typespec-java.yaml

Lines changed: 25 additions & 1 deletion
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,6 +69,28 @@ extends:
6769
env:
6870
GH_TOKEN: $(azuresdk-github-pat)
6971

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+
# Always publish to internal feed
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
7094
- task: EsrpRelease@11
7195
displayName: 'Publish TypeSpec Java to NPM'
7296
inputs:
@@ -78,7 +102,7 @@ extends:
78102
SignCertName: azure-sdk-esrp-release-certificate
79103
Intent: PackageDistribution
80104
ContentType: npm
81-
FolderLocation: $(System.DefaultWorkingDirectory)/typespec-extension
105+
FolderLocation: $(buildArtifactsPath)/packages
82106
Owners: ${{ coalesce(variables['Build.RequestedForEmail'], 'azuresdk@microsoft.com') }}
83107
Approvers: ${{ coalesce(variables['Build.RequestedForEmail'], 'azuresdk@microsoft.com') }}
84108
ServiceEndpointUrl: https://api.esrp.microsoft.com
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)