diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index f45e749f1c20..1d2fd9094ff8 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -8,7 +8,7 @@ parameters: steps: - template: /eng/common/pipelines/templates/steps/set-default-branch.yml - - ${{if eq(parameters.Registry, 'https://registry.npmjs.org/')}}: + - ${{ if eq(parameters.Registry, 'https://registry.npmjs.org/') }}: - task: EsrpRelease@6 inputs: displayName: 'Publish ${{parameters.Artifact.name}} to ESRP' @@ -22,16 +22,18 @@ steps: MainPublisher: 'ESRPRELPACMANTEST' DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47' ProductStateField: ${{parameters.Tag}} + - pwsh: Write-Host "##vso[task.setvariable variable=additionalTag${{parameters.AdditionalTag}}]" + displayName: Set Additional Tag Variable - - ${{if ne(parameters.AdditionalTag, '')}}: - - task: PowerShell@2 - displayName: Add Additional Tag - inputs: - targetType: filePath - filePath: eng/tools/publish-to-npm.ps1 - arguments: -addTag $true -pathToArtifacts ${{parameters.PathToArtifacts}} -accessLevel "public" -tag "${{parameters.AdditionalTag}}" -registry ${{parameters.Registry}} -npmToken $(azure-sdk-npm-token) - pwsh: true - condition: succeeded() + - ${{ if ne(variables['additionalTag'], '') }}: + - task: PowerShell@2 + displayName: Add Additional Tag + inputs: + targetType: filePath + filePath: eng/tools/publish-to-npm.ps1 + arguments: -addTag $true -pathToArtifacts ${{parameters.PathToArtifacts}} -accessLevel "public" -tag "${{parameters.AdditionalTag}}" -registry ${{parameters.Registry}} -npmToken $(azure-sdk-npm-token) + pwsh: true + condition: succeeded() - ${{ else }}: - task: PowerShell@2 diff --git a/eng/tools/publish-to-npm.ps1 b/eng/tools/publish-to-npm.ps1 index 7141eeb431ee..6f0ecd7cda52 100644 --- a/eng/tools/publish-to-npm.ps1 +++ b/eng/tools/publish-to-npm.ps1 @@ -167,7 +167,9 @@ try { Write-Host "npm dist-tag add $nameAndVersion $tag" npm dist-tag add $nameAndVersion $tag } - if ($additionalTag -ne "" && $additionalTag -ne $tag) { + if (![string]::IsNullOrWhitespace($additionalTag) -and ($additionalTag -ne $tag)) { + Write-Host "Tag: '$tag'" + Write-Host "Additional tag: '$additionalTag'" Write-Host "Adding additional tag for package" Write-Host "npm dist-tag add $nameAndVersion $additionalTag" npm dist-tag add $nameAndVersion $additionalTag