Skip to content

Commit

Permalink
Merge e2fa0e4 into e3aaa5a
Browse files Browse the repository at this point in the history
  • Loading branch information
ckairen authored Mar 12, 2024
2 parents e3aaa5a + e2fa0e4 commit 057517f
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 23 deletions.
21 changes: 7 additions & 14 deletions eng/pipelines/templates/stages/archetype-js-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,9 @@ stages:
npm install $(Package.Archive)
displayName: Validating package can be installed
condition: succeeded()
- task: PowerShell@2
displayName: Publish to npmjs.org
inputs:
targetType: filePath
filePath: eng/tools/publish-to-npm.ps1
arguments: -pathToArtifacts $(Package.Archive) -accessLevel "public" -tag "$(Tag)" -additionalTag "$(AdditionalTag)" -registry ${{parameters.Registry}} -npmToken $(azure-sdk-npm-token)
pwsh: true
condition: succeeded()
- template: /eng/pipelines/templates/steps/npm-release-task.yml
parameters:
Registry: ${{parameters.Registry}}
- pwsh: >
write-host "$(Package.Archive)"
Expand Down Expand Up @@ -246,12 +241,10 @@ stages:
echo "##vso[task.setvariable variable=NpmToken]$npmToken"
echo "##vso[task.setvariable variable=Registry]$registry"
displayName: Detecting package archive_${{artifact.name}}
- task: PowerShell@2
displayName: Publish_${{artifact.name}} to dev feed
inputs:
targetType: filePath
filePath: eng/tools/publish-to-npm.ps1
arguments: -pathToArtifacts $(Package.Archive) -accessLevel "public" -tag "dev" -registry "$(Registry)" -npmToken "$(NpmToken)"
- template: /eng/pipelines/templates/steps/npm-release-task.yml
parameters:
Registry: ${{parameters.Registry}}

- job: PublishDocsToNightlyBranch
condition: or(eq(variables['SetDevVersion'], 'true'), and(eq(variables['Build.Reason'],'Schedule'), eq(variables['System.TeamProject'], 'internal'), ne(variables['Skip.PublishDocs'], 'true')))
dependsOn: PublishPackages
Expand Down
55 changes: 55 additions & 0 deletions eng/pipelines/templates/steps/npm-release-task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
parameters:
Registry: ''

steps:
- template: /eng/common/pipelines/templates/steps/set-default-branch.yml
- ${{if eq(parameters.Registry, 'https://registry.npmjs.org/')}}:
- task: PowerShell@2
displayName: Get package list
inputs:
targetType: filePath
filePath: eng/tools/publish-to-npm.ps1
arguments: -pathToArtifacts $(Package.Archive) -accessLevel "public" -tag "$(Tag)" -additionalTag "$(AdditionalTag)" -registry ${{parameters.Registry}} -npmToken $(azure-sdk-npm-token)
pwsh: true
condition: succeeded()
- ${{ each package in split(variables.NpmPublishList, ',') }}:
- task: EsrpRelease@6
inputs:
displayName: 'Publish ${{package}} to ESRP'
ConnectedServiceName: 'ESRP Release Service'
Intent: 'PackageDistribution'
ContentType: 'npm'
FolderLocation: ${{package}}
Owners: $(Build.RequestedForEmail)
Approvers: '[email protected]'
ServiceEndpointUrl: 'https://api.esrp.microsoft.com'
MainPublisher: 'ESRPRELPACMANTEST'
DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47'
ProductStateField: $(Tag)

- pwsh: >
$regAuth=$registry.replace("https:","")
$filterPackageList= $filterArg -split "," | % { return $_.trim() }
$packageList = @()
foreach ($p in $(dir $pathToArtifacts -r -i *.tgz)) {
foreach($filterItem in $filterPackageList) {
if($p.BaseName.contains($filterItem)) {
$packageList += extractPackage $p
}
}
}
foreach ($p in $packageList) {
if($p.Publish) {
$(Build.SourcesDirectory)/eng/scripts/npm-admin-tasks.ps1 -taskType AddTag -packageName $p.Project.name -pkgVersion $p.Project.version -tagName "$(AdditionalTag)" -npmToken "$(azure-sdk-npm-token)"
}
}
- ${{ else }}:
- task: PowerShell@2
displayName: Publish to dev feed
inputs:
targetType: filePath
filePath: eng/tools/publish-to-npm.ps1
arguments: -pathToArtifacts $(Package.Archive) -accessLevel "public" -tag "$(Tag)" -additionalTag "$(AdditionalTag)" -registry ${{parameters.Registry}} -npmToken $(azure-sdk-npm-token)
pwsh: true
condition: succeeded()
25 changes: 16 additions & 9 deletions eng/tools/publish-to-npm.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,10 @@ try {
}
}

$publishToNpm = $false
if(!$basicDeployment) {
if($registry -eq 'https://registry.npmjs.org/'){
Write-Host "Choosing AuthToken Deployment"
$env:NPM_TOKEN=$npmToken
npm config set $regAuth`:_authToken=`$`{NPM_TOKEN`}
$publishToNpm = $true
}
else{
Write-Host "Choosing Private Devops Feed Deployment"
Expand All @@ -123,16 +122,18 @@ try {
npm config set $regAuth`:email=not_set
}

$publishList = @()
foreach ($p in $packageList) {
if($p.Publish) {
if($p.Publish -and !$publishToNpm) {
# Publishing to private feed
if ($tag) {
Write-Host "npm publish $($p.TarGz) --access=$accessLevel --registry=$registry --always-auth=true --tag=$tag"
npm publish $p.TarGz --access=$accessLevel --registry=$registry --always-auth=true --tag=$tag
Write-Host "npm publish $($p.TarGz) --access=$accessLevel --registry=$registry --always-auth=true --tag=$tag"
npm publish $p.TarGz --access=$accessLevel --registry=$registry --always-auth=true --tag=$tag
}
else {
Write-Host "Tag is empty"
Write-Host "npm publish $($p.TarGz) --access=$accessLevel --registry=$registry --always-auth=true"
npm publish $p.TarGz --access=$accessLevel --registry=$registry --always-auth=true
Write-Host "Tag is empty"
Write-Host "npm publish $($p.TarGz) --access=$accessLevel --registry=$registry --always-auth=true"
npm publish $p.TarGz --access=$accessLevel --registry=$registry --always-auth=true
}

if ($LastExitCode -ne 0) {
Expand All @@ -151,10 +152,16 @@ try {
exit 1
}
}
elseif ($p.Publish -and $publishToNpm) {
$publishList += $p.TarGz
}
else{
Write-Host "Skipping package publish $($p.TarGz)"
}
}
if ($publishToNpm) {
Write-Host "##vso[task.setvariable variable=NpmPublishList;]$($publishList)"
}
}
finally
{
Expand Down

0 comments on commit 057517f

Please sign in to comment.