From 40b63dd66ee669c9ed68f3636f55826251b2a28c Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 12 Mar 2024 11:22:19 -0700 Subject: [PATCH 01/49] release task --- .../templates/steps/npm-release-task.yml | 44 +++++++++++++++++++ eng/tools/publish-to-npm.ps1 | 25 +++++++---- 2 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 eng/pipelines/templates/steps/npm-release-task.yml diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml new file mode 100644 index 000000000000..c61194e17623 --- /dev/null +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -0,0 +1,44 @@ +parameters: + pathToArtifacts: '' + accessLevel: '' + tag: '' + additionalTag: '' + Registry: '' + npmToken: '' + filterArg: '' + basicDeployment: false + devopsFeed: false + skipDiff: false + +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@4 + displayName: 'Publish ${{package}} to ESRP' + ConnectedServiceName: 'ESRP Release Service' + Intent: 'PackageDistribution' + ContentType: 'npm' + FolderLocation: ${{package}} + Owners: $(Build.RequestedForEmail) + Approvers: 'wesh@microsoft.com' + ServiceEndpointUrl: 'https://api.esrp.microsoft.com' + MainPublisher: 'ESRPRELPACMANTEST' + DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47' + -${{ 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() diff --git a/eng/tools/publish-to-npm.ps1 b/eng/tools/publish-to-npm.ps1 index 21baddeb899a..f0e5bde69109 100644 --- a/eng/tools/publish-to-npm.ps1 +++ b/eng/tools/publish-to-npm.ps1 @@ -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" @@ -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) { @@ -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 { From 4146d5124ba3d55acd5c2924c8891dfffcf29bb4 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 12 Mar 2024 11:54:02 -0700 Subject: [PATCH 02/49] additional tag --- .../templates/stages/archetype-js-release.yml | 20 +++++--------- .../templates/steps/npm-release-task.yml | 26 ++++++++++++------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/eng/pipelines/templates/stages/archetype-js-release.yml b/eng/pipelines/templates/stages/archetype-js-release.yml index a357ec660dda..dd8bd611f83f 100644 --- a/eng/pipelines/templates/stages/archetype-js-release.yml +++ b/eng/pipelines/templates/stages/archetype-js-release.yml @@ -98,13 +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 + - template: /eng/pipelines/templates/steps/npm-release-task.yml + parameters: + Registry: ${{parameters.Registry}} condition: succeeded() - pwsh: > write-host "$(Package.Archive)" @@ -246,12 +242,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 diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index c61194e17623..73fe9bf2ce14 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -1,14 +1,5 @@ parameters: - pathToArtifacts: '' - accessLevel: '' - tag: '' - additionalTag: '' Registry: '' - npmToken: '' - filterArg: '' - basicDeployment: false - devopsFeed: false - skipDiff: false steps: - template: /eng/common/pipelines/templates/steps/set-default-branch.yml @@ -33,6 +24,23 @@ steps: ServiceEndpointUrl: 'https://api.esrp.microsoft.com' MainPublisher: 'ESRPRELPACMANTEST' DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47' + - 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 From 54d5b679f74b756eace1b01ffe91c56ef48579fd Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 12 Mar 2024 11:58:00 -0700 Subject: [PATCH 03/49] tag --- eng/pipelines/templates/steps/npm-release-task.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 73fe9bf2ce14..45cc9bf012d7 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -13,7 +13,7 @@ steps: pwsh: true condition: succeeded() - ${{ each package in split(variables.NpmPublishList, ',') }}: - - task: EsrpRelease@4 + - task: EsrpRelease@6 displayName: 'Publish ${{package}} to ESRP' ConnectedServiceName: 'ESRP Release Service' Intent: 'PackageDistribution' @@ -24,6 +24,7 @@ steps: ServiceEndpointUrl: 'https://api.esrp.microsoft.com' MainPublisher: 'ESRPRELPACMANTEST' DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47' + ProductState: $(Tag) - pwsh: > $regAuth=$registry.replace("https:","") $filterPackageList= $filterArg -split "," | % { return $_.trim() } From 205171197ad04a1ad6bbde085c2eb5fc4bb0685d Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 12 Mar 2024 12:21:09 -0700 Subject: [PATCH 04/49] pipeline condition --- eng/pipelines/templates/stages/archetype-js-release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/eng/pipelines/templates/stages/archetype-js-release.yml b/eng/pipelines/templates/stages/archetype-js-release.yml index dd8bd611f83f..aa9c27b22ba8 100644 --- a/eng/pipelines/templates/stages/archetype-js-release.yml +++ b/eng/pipelines/templates/stages/archetype-js-release.yml @@ -101,7 +101,6 @@ stages: - template: /eng/pipelines/templates/steps/npm-release-task.yml parameters: Registry: ${{parameters.Registry}} - condition: succeeded() - pwsh: > write-host "$(Package.Archive)" From 8a518c9cd442ada442c961ed58e6b51c1652ed0c Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 12 Mar 2024 12:25:41 -0700 Subject: [PATCH 05/49] dash --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 45cc9bf012d7..f025ff4ab47f 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -42,7 +42,7 @@ steps: } } - -${{ else }}: + - ${{ else }}: - task: PowerShell@2 displayName: Publish to dev feed inputs: From 0f834fafb77a4a45519f8d61dc54a1fd4e5809d3 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 12 Mar 2024 12:28:21 -0700 Subject: [PATCH 06/49] esrp task --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index f025ff4ab47f..6c86de04736a 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -13,7 +13,7 @@ steps: pwsh: true condition: succeeded() - ${{ each package in split(variables.NpmPublishList, ',') }}: - - task: EsrpRelease@6 + - task: SFP.release-tasks.custom-build-release-task.EsrpRelease@6 displayName: 'Publish ${{package}} to ESRP' ConnectedServiceName: 'ESRP Release Service' Intent: 'PackageDistribution' From e546ce7889495d3ecaa28bc2e5f058fc06b4de21 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 12 Mar 2024 12:31:10 -0700 Subject: [PATCH 07/49] product state --- eng/pipelines/templates/steps/npm-release-task.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 6c86de04736a..77c2c2412dfa 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -24,7 +24,8 @@ steps: ServiceEndpointUrl: 'https://api.esrp.microsoft.com' MainPublisher: 'ESRPRELPACMANTEST' DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47' - ProductState: $(Tag) + ProductStateField: $(Tag) + - pwsh: > $regAuth=$registry.replace("https:","") $filterPackageList= $filterArg -split "," | % { return $_.trim() } From 1aa482698e5488e9fdefe3b7677c29e0d0c0c21d Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 12 Mar 2024 12:31:51 -0700 Subject: [PATCH 08/49] product state --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 77c2c2412dfa..1cfeb10d4284 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -13,7 +13,7 @@ steps: pwsh: true condition: succeeded() - ${{ each package in split(variables.NpmPublishList, ',') }}: - - task: SFP.release-tasks.custom-build-release-task.EsrpRelease@6 + - task: EsrpRelease@6 displayName: 'Publish ${{package}} to ESRP' ConnectedServiceName: 'ESRP Release Service' Intent: 'PackageDistribution' From e2fa0e40b35b7c95148ecae817f4f92c8c025d86 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 12 Mar 2024 12:34:26 -0700 Subject: [PATCH 09/49] task indentation --- .../templates/steps/npm-release-task.yml | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 1cfeb10d4284..9445887f9cdc 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -14,17 +14,18 @@ steps: condition: succeeded() - ${{ each package in split(variables.NpmPublishList, ',') }}: - task: EsrpRelease@6 - displayName: 'Publish ${{package}} to ESRP' - ConnectedServiceName: 'ESRP Release Service' - Intent: 'PackageDistribution' - ContentType: 'npm' - FolderLocation: ${{package}} - Owners: $(Build.RequestedForEmail) - Approvers: 'wesh@microsoft.com' - ServiceEndpointUrl: 'https://api.esrp.microsoft.com' - MainPublisher: 'ESRPRELPACMANTEST' - DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47' - ProductStateField: $(Tag) + inputs: + displayName: 'Publish ${{package}} to ESRP' + ConnectedServiceName: 'ESRP Release Service' + Intent: 'PackageDistribution' + ContentType: 'npm' + FolderLocation: ${{package}} + Owners: $(Build.RequestedForEmail) + Approvers: 'wesh@microsoft.com' + ServiceEndpointUrl: 'https://api.esrp.microsoft.com' + MainPublisher: 'ESRPRELPACMANTEST' + DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47' + ProductStateField: $(Tag) - pwsh: > $regAuth=$registry.replace("https:","") From f17a22ed68a70b0b33af7fb3b22420fe05914b3b Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 12 Mar 2024 13:19:32 -0700 Subject: [PATCH 10/49] test --- eng/pipelines/templates/steps/npm-release-task.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 9445887f9cdc..f9e4691db942 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -13,6 +13,7 @@ steps: pwsh: true condition: succeeded() - ${{ each package in split(variables.NpmPublishList, ',') }}: + - pwsh: write-host ${{package}}; write-host ${{variables.NpmPublishList}} - task: EsrpRelease@6 inputs: displayName: 'Publish ${{package}} to ESRP' From 7eb34b636cedb03e9033c606b34c68d0b0b5b463 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 12 Mar 2024 14:11:43 -0700 Subject: [PATCH 11/49] variable access --- eng/pipelines/templates/steps/npm-release-task.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index f9e4691db942..d569fbc8d10d 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -12,8 +12,8 @@ steps: 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, ',') }}: - - pwsh: write-host ${{package}}; write-host ${{variables.NpmPublishList}} + - ${{ each package in split($(NpmPublishList), ',') }}: + - pwsh: write-host ${{package}}; write-host $(NpmPublishList) - task: EsrpRelease@6 inputs: displayName: 'Publish ${{package}} to ESRP' From 907d130cf5817ee26e7394a709fc92e09ceb09dd Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 12 Mar 2024 14:22:03 -0700 Subject: [PATCH 12/49] variable access --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index d569fbc8d10d..a6b2a8df6770 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -12,7 +12,7 @@ steps: 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($(NpmPublishList), ',') }}: + - ${{ each package in split(variables.NpmPublishList, ',') }}: - pwsh: write-host ${{package}}; write-host $(NpmPublishList) - task: EsrpRelease@6 inputs: From 0615b457045472897b3c26bc303d1f9b029c2288 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 12 Mar 2024 17:01:06 -0700 Subject: [PATCH 13/49] change loop --- .../templates/stages/archetype-js-release.yml | 1 + .../templates/steps/npm-release-task.yml | 33 ++++++++----------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/eng/pipelines/templates/stages/archetype-js-release.yml b/eng/pipelines/templates/stages/archetype-js-release.yml index aa9c27b22ba8..006661635c69 100644 --- a/eng/pipelines/templates/stages/archetype-js-release.yml +++ b/eng/pipelines/templates/stages/archetype-js-release.yml @@ -243,6 +243,7 @@ stages: displayName: Detecting package archive_${{artifact.name}} - template: /eng/pipelines/templates/steps/npm-release-task.yml parameters: + Artifact: ${{artifact}} Registry: ${{parameters.Registry}} - job: PublishDocsToNightlyBranch diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index a6b2a8df6770..3b00763901a4 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -1,4 +1,5 @@ parameters: + Artifact: {} Registry: '' steps: @@ -12,38 +13,32 @@ steps: 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, ',') }}: + - ${{ if contains(variables.NpmPublishList, parameters.Artifact.name) }}: - pwsh: write-host ${{package}}; write-host $(NpmPublishList) - task: EsrpRelease@6 inputs: - displayName: 'Publish ${{package}} to ESRP' + displayName: 'Publish ${{parameters.Artifact.name}} to ESRP' ConnectedServiceName: 'ESRP Release Service' Intent: 'PackageDistribution' ContentType: 'npm' - FolderLocation: ${{package}} + FolderLocation: $(Package.Archive) Owners: $(Build.RequestedForEmail) - Approvers: 'wesh@microsoft.com' + Approvers: 'azuresdk@microsoft.com' 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)" - } + - pwsh: > + $packageList = @() + foreach ($p in $(dir $(Package.Archive) -r -i *.tgz)) { + $packageList += extractPackage $p + } + foreach ($p in $packageList) { + if($p.Publish && $(AdditionalTag) && $(AdditionalTag) -ne $(Tag)) { + $(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 From 6a5ac59fde51dc3a935dd7d2bc5272f8bdcd72b8 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 12 Mar 2024 17:05:12 -0700 Subject: [PATCH 14/49] telem --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 3b00763901a4..02b629d7798a 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -14,7 +14,7 @@ steps: pwsh: true condition: succeeded() - ${{ if contains(variables.NpmPublishList, parameters.Artifact.name) }}: - - pwsh: write-host ${{package}}; write-host $(NpmPublishList) + - pwsh: write-host ${{parameters.Artifact.name}}; write-host $(NpmPublishList) - task: EsrpRelease@6 inputs: displayName: 'Publish ${{parameters.Artifact.name}} to ESRP' From 18bbe622a955f6d6e135a7c95baca0a50b61eca8 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 12 Mar 2024 17:57:10 -0700 Subject: [PATCH 15/49] artifact folder --- eng/pipelines/templates/steps/npm-release-task.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 02b629d7798a..35dd4fb9ce7a 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -13,6 +13,9 @@ steps: arguments: -pathToArtifacts $(Package.Archive) -accessLevel "public" -tag "$(Tag)" -additionalTag "$(AdditionalTag)" -registry ${{parameters.Registry}} -npmToken $(azure-sdk-npm-token) pwsh: true condition: succeeded() + - pwsh: > + $artifactFolder = $(Package.Archive) -replace '[^\/]+$', '' + Write-Host "##vso[task.setvariable variable=artifactFolder;]$artifactFolder" - ${{ if contains(variables.NpmPublishList, parameters.Artifact.name) }}: - pwsh: write-host ${{parameters.Artifact.name}}; write-host $(NpmPublishList) - task: EsrpRelease@6 @@ -21,7 +24,7 @@ steps: ConnectedServiceName: 'ESRP Release Service' Intent: 'PackageDistribution' ContentType: 'npm' - FolderLocation: $(Package.Archive) + FolderLocation: $(artifactFolder) Owners: $(Build.RequestedForEmail) Approvers: 'azuresdk@microsoft.com' ServiceEndpointUrl: 'https://api.esrp.microsoft.com' From f1e5ca7ae1846f8f42a46f2f827149582f79bea9 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 12 Mar 2024 19:05:27 -0700 Subject: [PATCH 16/49] test --- eng/pipelines/templates/steps/npm-release-task.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 35dd4fb9ce7a..4b7c3e641313 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -15,6 +15,10 @@ steps: condition: succeeded() - pwsh: > $artifactFolder = $(Package.Archive) -replace '[^\/]+$', '' + Write-Host "archive" + write-host $(Package.Archive) + write-host "artifact folder" + write-host $artifactFolder Write-Host "##vso[task.setvariable variable=artifactFolder;]$artifactFolder" - ${{ if contains(variables.NpmPublishList, parameters.Artifact.name) }}: - pwsh: write-host ${{parameters.Artifact.name}}; write-host $(NpmPublishList) From 533d217cd239b50df05cd1bf2d0f20842d3dc02b Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 12 Mar 2024 23:34:39 -0700 Subject: [PATCH 17/49] stringify --- eng/pipelines/templates/steps/npm-release-task.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 4b7c3e641313..da8d2b356ad7 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -14,9 +14,9 @@ steps: pwsh: true condition: succeeded() - pwsh: > - $artifactFolder = $(Package.Archive) -replace '[^\/]+$', '' + $artifactFolder = "$(Package.Archive)" -replace '[^\/]+$', '' Write-Host "archive" - write-host $(Package.Archive) + write-host "$(Package.Archive)" write-host "artifact folder" write-host $artifactFolder Write-Host "##vso[task.setvariable variable=artifactFolder;]$artifactFolder" From c3cb131011d57235ec2474e310c0fdb415aff5ad Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 13 Mar 2024 11:28:05 -0700 Subject: [PATCH 18/49] stringify --- eng/pipelines/templates/steps/npm-release-task.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index da8d2b356ad7..e163407ec4b8 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -14,7 +14,8 @@ steps: pwsh: true condition: succeeded() - pwsh: > - $artifactFolder = "$(Package.Archive)" -replace '[^\/]+$', '' + write-host "$(Package.Archive)" + $artifactFolder = "$(Package.Archive)".Replace('[^\/]+$', '') Write-Host "archive" write-host "$(Package.Archive)" write-host "artifact folder" From 8d31ac0b1876a7a63bd8632bbc5f83aaaf03b6b1 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 13 Mar 2024 12:56:13 -0700 Subject: [PATCH 19/49] stringify --- eng/pipelines/templates/steps/npm-release-task.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index e163407ec4b8..4757aeef47c0 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -13,7 +13,7 @@ steps: arguments: -pathToArtifacts $(Package.Archive) -accessLevel "public" -tag "$(Tag)" -additionalTag "$(AdditionalTag)" -registry ${{parameters.Registry}} -npmToken $(azure-sdk-npm-token) pwsh: true condition: succeeded() - - pwsh: > + - pwsh: | write-host "$(Package.Archive)" $artifactFolder = "$(Package.Archive)".Replace('[^\/]+$', '') Write-Host "archive" @@ -22,7 +22,9 @@ steps: write-host $artifactFolder Write-Host "##vso[task.setvariable variable=artifactFolder;]$artifactFolder" - ${{ if contains(variables.NpmPublishList, parameters.Artifact.name) }}: - - pwsh: write-host ${{parameters.Artifact.name}}; write-host $(NpmPublishList) + - pwsh: | + write-host ${{parameters.Artifact.name}} + write-host $(NpmPublishList) - task: EsrpRelease@6 inputs: displayName: 'Publish ${{parameters.Artifact.name}} to ESRP' @@ -37,7 +39,7 @@ steps: DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47' ProductStateField: $(Tag) - - pwsh: > + - pwsh: | $packageList = @() foreach ($p in $(dir $(Package.Archive) -r -i *.tgz)) { $packageList += extractPackage $p From f1fac099917a81566594c2ad217d171af375b0eb Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 13 Mar 2024 21:26:32 -0700 Subject: [PATCH 20/49] replace --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 4757aeef47c0..99e45b1f66b2 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -15,7 +15,7 @@ steps: condition: succeeded() - pwsh: | write-host "$(Package.Archive)" - $artifactFolder = "$(Package.Archive)".Replace('[^\/]+$', '') + $artifactFolder = "$(Package.Archive)" -Replace '[^\/]+$', '' Write-Host "archive" write-host "$(Package.Archive)" write-host "artifact folder" From 6169c75b7c1ea7d2e1f3d876f379333004931d08 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 14 Mar 2024 11:04:36 -0700 Subject: [PATCH 21/49] temp publish folder --- .../templates/stages/archetype-js-release.yml | 3 ++ .../templates/steps/npm-release-task.yml | 38 +++++++++---------- eng/tools/publish-to-npm.ps1 | 7 ++-- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/eng/pipelines/templates/stages/archetype-js-release.yml b/eng/pipelines/templates/stages/archetype-js-release.yml index 006661635c69..c0c5ec04c413 100644 --- a/eng/pipelines/templates/stages/archetype-js-release.yml +++ b/eng/pipelines/templates/stages/archetype-js-release.yml @@ -100,6 +100,8 @@ stages: condition: succeeded() - template: /eng/pipelines/templates/steps/npm-release-task.yml parameters: + ArtifactName: ${{parameters.ArtifactName}} + Artifact: ${{artifact}} Registry: ${{parameters.Registry}} - pwsh: > write-host "$(Package.Archive)" @@ -243,6 +245,7 @@ stages: displayName: Detecting package archive_${{artifact.name}} - template: /eng/pipelines/templates/steps/npm-release-task.yml parameters: + ArtifactName: ${{parameters.ArtifactName}} Artifact: ${{artifact}} Registry: ${{parameters.Registry}} diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 99e45b1f66b2..1d361fd61c53 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -1,4 +1,5 @@ parameters: + ArtifactName: '' Artifact: {} Registry: '' @@ -6,7 +7,7 @@ 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 + displayName: Create publish package directory inputs: targetType: filePath filePath: eng/tools/publish-to-npm.ps1 @@ -21,23 +22,19 @@ steps: write-host "artifact folder" write-host $artifactFolder Write-Host "##vso[task.setvariable variable=artifactFolder;]$artifactFolder" - - ${{ if contains(variables.NpmPublishList, parameters.Artifact.name) }}: - - pwsh: | - write-host ${{parameters.Artifact.name}} - write-host $(NpmPublishList) - - task: EsrpRelease@6 - inputs: - displayName: 'Publish ${{parameters.Artifact.name}} to ESRP' - ConnectedServiceName: 'ESRP Release Service' - Intent: 'PackageDistribution' - ContentType: 'npm' - FolderLocation: $(artifactFolder) - Owners: $(Build.RequestedForEmail) - Approvers: 'azuresdk@microsoft.com' - ServiceEndpointUrl: 'https://api.esrp.microsoft.com' - MainPublisher: 'ESRPRELPACMANTEST' - DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47' - ProductStateField: $(Tag) + - task: EsrpRelease@6 + inputs: + displayName: 'Publish ${{parameters.Artifact.name}} to ESRP' + ConnectedServiceName: 'ESRP Release Service' + Intent: 'PackageDistribution' + ContentType: 'npm' + FolderLocation: $(System.DefaultWorkingDirectory)/temp/${{parameters.ArtifactName}}/${{parameters.artifact.name}} + Owners: $(Build.RequestedForEmail) + Approvers: 'azuresdk@microsoft.com' + ServiceEndpointUrl: 'https://api.esrp.microsoft.com' + MainPublisher: 'ESRPRELPACMANTEST' + DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47' + ProductStateField: $(Tag) - pwsh: | $packageList = @() @@ -50,9 +47,12 @@ steps: } } + Remove-Item $(System.DefaultWorkingDirectory)/temp/${{parameters.ArtifactName}} -Recurse + displayName: Add Additional Tags + - ${{ else }}: - task: PowerShell@2 - displayName: Publish to dev feed + displayName: Publish to Dev Feed inputs: targetType: filePath filePath: eng/tools/publish-to-npm.ps1 diff --git a/eng/tools/publish-to-npm.ps1 b/eng/tools/publish-to-npm.ps1 index f0e5bde69109..5b221be47454 100644 --- a/eng/tools/publish-to-npm.ps1 +++ b/eng/tools/publish-to-npm.ps1 @@ -153,15 +153,14 @@ try { } } elseif ($p.Publish -and $publishToNpm) { - $publishList += $p.TarGz + $artifactSubPath = $pathToArtifacts -replace '$(Pipeline.Workspace)\/', '' + write-host "Copy $($p.TarGz) to $artifactSubPath" + Copy-Item -Path $($p.TarGz) -Destination "$(System.DefaultWorkingDirectory)/temp/$artifactSubPath" } else{ Write-Host "Skipping package publish $($p.TarGz)" } } - if ($publishToNpm) { - Write-Host "##vso[task.setvariable variable=NpmPublishList;]$($publishList)" - } } finally { From c77f4d08b1280b5055eaa9449a667c1ccb8e2ebe Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 14 Mar 2024 11:53:00 -0700 Subject: [PATCH 22/49] temp publish folder --- eng/pipelines/templates/steps/npm-release-task.yml | 1 + eng/tools/publish-to-npm.ps1 | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 1d361fd61c53..13c062424bc3 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -8,6 +8,7 @@ steps: - ${{if eq(parameters.Registry, 'https://registry.npmjs.org/')}}: - task: PowerShell@2 displayName: Create publish package directory + WorkingDirectory: $(System.DefaultWorkingDirectory) inputs: targetType: filePath filePath: eng/tools/publish-to-npm.ps1 diff --git a/eng/tools/publish-to-npm.ps1 b/eng/tools/publish-to-npm.ps1 index 5b221be47454..457698b76d3a 100644 --- a/eng/tools/publish-to-npm.ps1 +++ b/eng/tools/publish-to-npm.ps1 @@ -155,7 +155,7 @@ try { elseif ($p.Publish -and $publishToNpm) { $artifactSubPath = $pathToArtifacts -replace '$(Pipeline.Workspace)\/', '' write-host "Copy $($p.TarGz) to $artifactSubPath" - Copy-Item -Path $($p.TarGz) -Destination "$(System.DefaultWorkingDirectory)/temp/$artifactSubPath" + Copy-Item -Path $($p.TarGz) -Destination "temp/$artifactSubPath" } else{ Write-Host "Skipping package publish $($p.TarGz)" From 95e0bdb972faad347b9593c1c6cf08b0b21ffabd Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 14 Mar 2024 12:16:13 -0700 Subject: [PATCH 23/49] working directory --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 13c062424bc3..8873bc1d8a80 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -8,13 +8,13 @@ steps: - ${{if eq(parameters.Registry, 'https://registry.npmjs.org/')}}: - task: PowerShell@2 displayName: Create publish package directory - WorkingDirectory: $(System.DefaultWorkingDirectory) 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() + workingDirectory: $(System.DefaultWorkingDirectory) - pwsh: | write-host "$(Package.Archive)" $artifactFolder = "$(Package.Archive)" -Replace '[^\/]+$', '' From 5c08f62f16de37c418631960069470f3d2b5b1b9 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 14 Mar 2024 12:18:04 -0700 Subject: [PATCH 24/49] working directory --- eng/pipelines/templates/steps/npm-release-task.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 8873bc1d8a80..1d361fd61c53 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -14,7 +14,6 @@ steps: arguments: -pathToArtifacts $(Package.Archive) -accessLevel "public" -tag "$(Tag)" -additionalTag "$(AdditionalTag)" -registry ${{parameters.Registry}} -npmToken $(azure-sdk-npm-token) pwsh: true condition: succeeded() - workingDirectory: $(System.DefaultWorkingDirectory) - pwsh: | write-host "$(Package.Archive)" $artifactFolder = "$(Package.Archive)" -Replace '[^\/]+$', '' From 274e9a4066d19f50664444e645fb8a01c7096e75 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 18 Mar 2024 07:55:37 -0700 Subject: [PATCH 25/49] ls --- eng/tools/publish-to-npm.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/tools/publish-to-npm.ps1 b/eng/tools/publish-to-npm.ps1 index 457698b76d3a..f3fb95c2028a 100644 --- a/eng/tools/publish-to-npm.ps1 +++ b/eng/tools/publish-to-npm.ps1 @@ -154,6 +154,7 @@ try { } elseif ($p.Publish -and $publishToNpm) { $artifactSubPath = $pathToArtifacts -replace '$(Pipeline.Workspace)\/', '' + ls -r $(Pipeline.Workspace) write-host "Copy $($p.TarGz) to $artifactSubPath" Copy-Item -Path $($p.TarGz) -Destination "temp/$artifactSubPath" } From b30a077b3c35994bcb077591a71bafdc7a275442 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 18 Mar 2024 07:57:28 -0700 Subject: [PATCH 26/49] force --- eng/tools/publish-to-npm.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/tools/publish-to-npm.ps1 b/eng/tools/publish-to-npm.ps1 index f3fb95c2028a..ac99444d445b 100644 --- a/eng/tools/publish-to-npm.ps1 +++ b/eng/tools/publish-to-npm.ps1 @@ -156,7 +156,7 @@ try { $artifactSubPath = $pathToArtifacts -replace '$(Pipeline.Workspace)\/', '' ls -r $(Pipeline.Workspace) write-host "Copy $($p.TarGz) to $artifactSubPath" - Copy-Item -Path $($p.TarGz) -Destination "temp/$artifactSubPath" + Copy-Item -Path $($p.TarGz) -Destination "temp/$artifactSubPath" -Force } else{ Write-Host "Skipping package publish $($p.TarGz)" From ac4748403e1025d90eb6707f70b341ba49c4face Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 18 Mar 2024 08:07:47 -0700 Subject: [PATCH 27/49] temp remove unit test --- eng/pipelines/templates/stages/archetype-sdk-client.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/stages/archetype-sdk-client.yml b/eng/pipelines/templates/stages/archetype-sdk-client.yml index 1811aba459a4..b5c9df3e4036 100644 --- a/eng/pipelines/templates/stages/archetype-sdk-client.yml +++ b/eng/pipelines/templates/stages/archetype-sdk-client.yml @@ -80,7 +80,7 @@ extends: Artifacts: ${{ parameters.Artifacts }} ${{ if eq(parameters.ServiceDirectory, 'template') }}: TestPipeline: true - RunUnitTests: ${{ parameters.RunUnitTests }} + RunUnitTests: false MatrixConfigs: - ${{ each config in parameters.MatrixConfigs }}: - ${{ config }} From b9b903ae6c1bda3507ab55f920965375391b736a Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 18 Mar 2024 08:33:49 -0700 Subject: [PATCH 28/49] env var --- eng/tools/publish-to-npm.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eng/tools/publish-to-npm.ps1 b/eng/tools/publish-to-npm.ps1 index ac99444d445b..d0fb355b6d73 100644 --- a/eng/tools/publish-to-npm.ps1 +++ b/eng/tools/publish-to-npm.ps1 @@ -153,7 +153,10 @@ try { } } elseif ($p.Publish -and $publishToNpm) { - $artifactSubPath = $pathToArtifacts -replace '$(Pipeline.Workspace)\/', '' + write-host $env:Pipeline.Workspace + write-host "XxxxxxxxxxxxxxxX" + write-host $env:PipelineWorkspace + $artifactSubPath = $pathToArtifacts -replace '$env:Pipeline.Workspace\/', '' ls -r $(Pipeline.Workspace) write-host "Copy $($p.TarGz) to $artifactSubPath" Copy-Item -Path $($p.TarGz) -Destination "temp/$artifactSubPath" -Force From 7c19bf3a15f8a9176d2dbe61745ec2320e12315d Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 18 Mar 2024 08:54:13 -0700 Subject: [PATCH 29/49] pipeline workspace --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- eng/tools/publish-to-npm.ps1 | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 1d361fd61c53..8ad88f1d7d7d 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -11,7 +11,7 @@ steps: 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) + arguments: -pathToArtifacts $(Package.Archive) -accessLevel "public" -tag "$(Tag)" -additionalTag "$(AdditionalTag)" -registry ${{parameters.Registry}} -npmToken $(azure-sdk-npm-token) -pipelineWorkspace $(Pipeline.Workspace) pwsh: true condition: succeeded() - pwsh: | diff --git a/eng/tools/publish-to-npm.ps1 b/eng/tools/publish-to-npm.ps1 index d0fb355b6d73..ee9050821106 100644 --- a/eng/tools/publish-to-npm.ps1 +++ b/eng/tools/publish-to-npm.ps1 @@ -8,7 +8,8 @@ param ( $filterArg="", $basicDeployment=$false, $devopsFeed=$false, - $skipDiff=$false + $skipDiff=$false, + $pipelineWorkspace ) function replaceText($oldText,$newText,$filePath){ @@ -153,11 +154,9 @@ try { } } elseif ($p.Publish -and $publishToNpm) { - write-host $env:Pipeline.Workspace - write-host "XxxxxxxxxxxxxxxX" - write-host $env:PipelineWorkspace - $artifactSubPath = $pathToArtifacts -replace '$env:Pipeline.Workspace\/', '' - ls -r $(Pipeline.Workspace) + write-host $pipelineWorkspace + $artifactSubPath = $pathToArtifacts -replace '$pipelineWorkspace\/', '' + ls -r $pipelineWorkspace write-host "Copy $($p.TarGz) to $artifactSubPath" Copy-Item -Path $($p.TarGz) -Destination "temp/$artifactSubPath" -Force } From 12a84e8638661b5554163b89aa87615d8e17a7a3 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 18 Mar 2024 09:21:17 -0700 Subject: [PATCH 30/49] path --- eng/tools/publish-to-npm.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eng/tools/publish-to-npm.ps1 b/eng/tools/publish-to-npm.ps1 index ee9050821106..9acc5fffd00d 100644 --- a/eng/tools/publish-to-npm.ps1 +++ b/eng/tools/publish-to-npm.ps1 @@ -156,8 +156,9 @@ try { elseif ($p.Publish -and $publishToNpm) { write-host $pipelineWorkspace $artifactSubPath = $pathToArtifacts -replace '$pipelineWorkspace\/', '' - ls -r $pipelineWorkspace write-host "Copy $($p.TarGz) to $artifactSubPath" + ls -Recurse $pathToArtifacts + ls $($p.TarGz) Copy-Item -Path $($p.TarGz) -Destination "temp/$artifactSubPath" -Force } else{ From e9420f064b2e0a906f76f701561f17d474780355 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 18 Mar 2024 11:38:06 -0700 Subject: [PATCH 31/49] path update --- eng/tools/publish-to-npm.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/tools/publish-to-npm.ps1 b/eng/tools/publish-to-npm.ps1 index 9acc5fffd00d..6192365e5031 100644 --- a/eng/tools/publish-to-npm.ps1 +++ b/eng/tools/publish-to-npm.ps1 @@ -155,11 +155,11 @@ try { } elseif ($p.Publish -and $publishToNpm) { write-host $pipelineWorkspace - $artifactSubPath = $pathToArtifacts -replace '$pipelineWorkspace\/', '' + $artifactSubPath = $pathToArtifacts -replace $pipelineWorkspace, '' write-host "Copy $($p.TarGz) to $artifactSubPath" ls -Recurse $pathToArtifacts ls $($p.TarGz) - Copy-Item -Path $($p.TarGz) -Destination "temp/$artifactSubPath" -Force + Copy-Item -Path $($p.TarGz) -Destination "temp$artifactSubPath" -Force } else{ Write-Host "Skipping package publish $($p.TarGz)" From 9726694a4a720d9bbb94700de322e32169af6dc1 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 18 Mar 2024 12:06:12 -0700 Subject: [PATCH 32/49] path update --- eng/tools/publish-to-npm.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eng/tools/publish-to-npm.ps1 b/eng/tools/publish-to-npm.ps1 index 6192365e5031..bde34744bcfa 100644 --- a/eng/tools/publish-to-npm.ps1 +++ b/eng/tools/publish-to-npm.ps1 @@ -158,8 +158,11 @@ try { $artifactSubPath = $pathToArtifacts -replace $pipelineWorkspace, '' write-host "Copy $($p.TarGz) to $artifactSubPath" ls -Recurse $pathToArtifacts + $destination = "$($pipelineWorkspace)temp$artifactSubPath" ls $($p.TarGz) - Copy-Item -Path $($p.TarGz) -Destination "temp$artifactSubPath" -Force + write-host $destination + New-Item -ItemType File -Path $destination -Force + Copy-Item -Path $($p.TarGz) -Destination $destination -Force } else{ Write-Host "Skipping package publish $($p.TarGz)" From 343b760b6fe4ffeb9105c06e9858a2718db378e8 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 18 Mar 2024 12:34:50 -0700 Subject: [PATCH 33/49] esrp publish --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- eng/tools/publish-to-npm.ps1 | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 8ad88f1d7d7d..84ef7aebdba2 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -28,7 +28,7 @@ steps: ConnectedServiceName: 'ESRP Release Service' Intent: 'PackageDistribution' ContentType: 'npm' - FolderLocation: $(System.DefaultWorkingDirectory)/temp/${{parameters.ArtifactName}}/${{parameters.artifact.name}} + FolderLocation: $(Pipeline.Workspace)/temp/packages/${{parameters.ArtifactName}} Owners: $(Build.RequestedForEmail) Approvers: 'azuresdk@microsoft.com' ServiceEndpointUrl: 'https://api.esrp.microsoft.com' diff --git a/eng/tools/publish-to-npm.ps1 b/eng/tools/publish-to-npm.ps1 index bde34744bcfa..e40c0e45e45b 100644 --- a/eng/tools/publish-to-npm.ps1 +++ b/eng/tools/publish-to-npm.ps1 @@ -154,13 +154,9 @@ try { } } elseif ($p.Publish -and $publishToNpm) { - write-host $pipelineWorkspace $artifactSubPath = $pathToArtifacts -replace $pipelineWorkspace, '' - write-host "Copy $($p.TarGz) to $artifactSubPath" - ls -Recurse $pathToArtifacts - $destination = "$($pipelineWorkspace)temp$artifactSubPath" - ls $($p.TarGz) - write-host $destination + $destination = "$pipelineWorkspace/temp$artifactSubPath" + write-host "Copy $($p.TarGz) to $destination" New-Item -ItemType File -Path $destination -Force Copy-Item -Path $($p.TarGz) -Destination $destination -Force } From d431242273d00756491128c6c91efb1711e43584 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 18 Mar 2024 12:56:58 -0700 Subject: [PATCH 34/49] package name --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 84ef7aebdba2..5e8feac62371 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -28,7 +28,7 @@ steps: ConnectedServiceName: 'ESRP Release Service' Intent: 'PackageDistribution' ContentType: 'npm' - FolderLocation: $(Pipeline.Workspace)/temp/packages/${{parameters.ArtifactName}} + FolderLocation: $(Pipeline.Workspace)/temp/${{parameters.ArtifactName}}/${{parameters.artifact.name}} Owners: $(Build.RequestedForEmail) Approvers: 'azuresdk@microsoft.com' ServiceEndpointUrl: 'https://api.esrp.microsoft.com' From 0a2180c85c31d2665ef65df3bb0b9615fc7d43d9 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 18 Mar 2024 13:22:50 -0700 Subject: [PATCH 35/49] import function --- eng/pipelines/templates/steps/npm-release-task.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 5e8feac62371..cbcc82d5e157 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -14,14 +14,6 @@ steps: arguments: -pathToArtifacts $(Package.Archive) -accessLevel "public" -tag "$(Tag)" -additionalTag "$(AdditionalTag)" -registry ${{parameters.Registry}} -npmToken $(azure-sdk-npm-token) -pipelineWorkspace $(Pipeline.Workspace) pwsh: true condition: succeeded() - - pwsh: | - write-host "$(Package.Archive)" - $artifactFolder = "$(Package.Archive)" -Replace '[^\/]+$', '' - Write-Host "archive" - write-host "$(Package.Archive)" - write-host "artifact folder" - write-host $artifactFolder - Write-Host "##vso[task.setvariable variable=artifactFolder;]$artifactFolder" - task: EsrpRelease@6 inputs: displayName: 'Publish ${{parameters.Artifact.name}} to ESRP' @@ -37,6 +29,7 @@ steps: ProductStateField: $(Tag) - pwsh: | + . .eng/tools/publish-to-npm.ps1 $packageList = @() foreach ($p in $(dir $(Package.Archive) -r -i *.tgz)) { $packageList += extractPackage $p From 745cd6f0b9feaa86567e7b5a37e65a79c9a08fa7 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 18 Mar 2024 13:47:27 -0700 Subject: [PATCH 36/49] import function --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index cbcc82d5e157..0f792bed4ea8 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -29,7 +29,7 @@ steps: ProductStateField: $(Tag) - pwsh: | - . .eng/tools/publish-to-npm.ps1 + . ./eng/tools/publish-to-npm.ps1 $packageList = @() foreach ($p in $(dir $(Package.Archive) -r -i *.tgz)) { $packageList += extractPackage $p From dfcd4fd13ec7eccc10eb27f8e85b14f6d25f43e0 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 18 Mar 2024 20:52:52 -0700 Subject: [PATCH 37/49] import without execution --- eng/tools/publish-to-npm.ps1 | 156 ++++++++++++++++++----------------- 1 file changed, 79 insertions(+), 77 deletions(-) diff --git a/eng/tools/publish-to-npm.ps1 b/eng/tools/publish-to-npm.ps1 index e40c0e45e45b..53cae1d0670e 100644 --- a/eng/tools/publish-to-npm.ps1 +++ b/eng/tools/publish-to-npm.ps1 @@ -86,90 +86,92 @@ function containsProductCodeDiff($currentDevPackage,$lastDevPackage) { return $false } -try { - $regAuth=$registry.replace("https:","") - $filterPackageList= $filterArg -split "," | % { return $_.trim() } - $packageList = @() - #We need to run the npm pack before we set NPM_TOKEN in npmrc so that the npmrc file is in default (empty) state - foreach ($p in $(dir $pathToArtifacts -r -i *.tgz)) { - foreach($filterItem in $filterPackageList) { - if($p.BaseName.contains($filterItem)) { - $packageList += extractPackage $p +if ($MyInvocation.InvocationName -ne ".") { + try { + $regAuth=$registry.replace("https:","") + $filterPackageList= $filterArg -split "," | % { return $_.trim() } + $packageList = @() + #We need to run the npm pack before we set NPM_TOKEN in npmrc so that the npmrc file is in default (empty) state + foreach ($p in $(dir $pathToArtifacts -r -i *.tgz)) { + foreach($filterItem in $filterPackageList) { + if($p.BaseName.contains($filterItem)) { + $packageList += extractPackage $p + } } } - } - $publishToNpm = $false - if(!$basicDeployment) { - if($registry -eq 'https://registry.npmjs.org/'){ - $publishToNpm = $true - } - else{ - Write-Host "Choosing Private Devops Feed Deployment" - $npmReg = $regAuth.replace("registry/",""); - $env:NPM_TOKEN=$npmToken - npm config set $regAuth`:username=azure-sdk - npm config set $regAuth`:_password=`$`{NPM_TOKEN`} - npm config set $regAuth`:email=not_set - npm config set $npmReg`:username=azure-sdk - npm config set $npmReg`:_password=`$`{NPM_TOKEN`} - npm config set $npmReg`:email=not_set - } - } - else { - Write-Host "Choosing BasicAuth Deployment" - npm config set $regAuth`:username=pat_will_be_used - npm config set $regAuth`:_password=$npmToken - npm config set $regAuth`:email=not_set - } + $publishToNpm = $false + if(!$basicDeployment) { + if($registry -eq 'https://registry.npmjs.org/'){ + $publishToNpm = $true + } + else{ + Write-Host "Choosing Private Devops Feed Deployment" + $npmReg = $regAuth.replace("registry/",""); + $env:NPM_TOKEN=$npmToken + npm config set $regAuth`:username=azure-sdk + npm config set $regAuth`:_password=`$`{NPM_TOKEN`} + npm config set $regAuth`:email=not_set + npm config set $npmReg`:username=azure-sdk + npm config set $npmReg`:_password=`$`{NPM_TOKEN`} + npm config set $npmReg`:email=not_set + } + } + else { + Write-Host "Choosing BasicAuth Deployment" + npm config set $regAuth`:username=pat_will_be_used + npm config set $regAuth`:_password=$npmToken + npm config set $regAuth`:email=not_set + } - $publishList = @() - foreach ($p in $packageList) { - 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 - } - 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 + $publishList = @() + foreach ($p in $packageList) { + 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 + } + 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 + } + + if ($LastExitCode -ne 0) { + Write-Host "npm publish failed with exit code $LastExitCode" + exit 1 + } + $addTagCheck = 0 + if(($additionalTag) -and ($additionalTag -ne $tag)) { + $nameAndVersion = $p.Project.name + "@" + $p.Project.version + Write-Host "npm dist-tag add $($nameAndVersion) $additionalTag" + npm dist-tag add $nameAndVersion $additionalTag + $addTagCheck = $LastExitCode + } + if ($addTagCheck -ne 0) { + Write-Host "npm dist-tag add failed with exit code $addTagCheck" + exit 1 + } } - - if ($LastExitCode -ne 0) { - Write-Host "npm publish failed with exit code $LastExitCode" - exit 1 + elseif ($p.Publish -and $publishToNpm) { + $artifactSubPath = $pathToArtifacts -replace $pipelineWorkspace, '' + $destination = "$pipelineWorkspace/temp$artifactSubPath" + write-host "Copy $($p.TarGz) to $destination" + New-Item -ItemType File -Path $destination -Force + Copy-Item -Path $($p.TarGz) -Destination $destination -Force } - $addTagCheck = 0 - if(($additionalTag) -and ($additionalTag -ne $tag)) { - $nameAndVersion = $p.Project.name + "@" + $p.Project.version - Write-Host "npm dist-tag add $($nameAndVersion) $additionalTag" - npm dist-tag add $nameAndVersion $additionalTag - $addTagCheck = $LastExitCode + else{ + Write-Host "Skipping package publish $($p.TarGz)" } - if ($addTagCheck -ne 0) { - Write-Host "npm dist-tag add failed with exit code $addTagCheck" - exit 1 - } - } - elseif ($p.Publish -and $publishToNpm) { - $artifactSubPath = $pathToArtifacts -replace $pipelineWorkspace, '' - $destination = "$pipelineWorkspace/temp$artifactSubPath" - write-host "Copy $($p.TarGz) to $destination" - New-Item -ItemType File -Path $destination -Force - Copy-Item -Path $($p.TarGz) -Destination $destination -Force - } - else{ - Write-Host "Skipping package publish $($p.TarGz)" } } -} -finally -{ - npm config delete $regAuth`:_authToken - npm config delete $regAuth`:_password - npm config delete $regAuth`:email - npm config delete $regAuth`:username - $env:NPM_TOKEN="" + finally + { + npm config delete $regAuth`:_authToken + npm config delete $regAuth`:_password + npm config delete $regAuth`:email + npm config delete $regAuth`:username + $env:NPM_TOKEN="" + } } From d9134a33e86b8f91c0f9d307272fc0036a1dfe0a Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 19 Mar 2024 07:54:47 -0700 Subject: [PATCH 38/49] import module --- .../templates/steps/npm-release-task.yml | 2 +- eng/tools/publish-to-npm.ps1 | 156 +++++++++--------- 2 files changed, 78 insertions(+), 80 deletions(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 0f792bed4ea8..385d074d1fcd 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -29,7 +29,7 @@ steps: ProductStateField: $(Tag) - pwsh: | - . ./eng/tools/publish-to-npm.ps1 + Import-Module eng/tools/publish-to-npm.ps1 -Function extractPackage -Force $packageList = @() foreach ($p in $(dir $(Package.Archive) -r -i *.tgz)) { $packageList += extractPackage $p diff --git a/eng/tools/publish-to-npm.ps1 b/eng/tools/publish-to-npm.ps1 index 53cae1d0670e..d19097d75d62 100644 --- a/eng/tools/publish-to-npm.ps1 +++ b/eng/tools/publish-to-npm.ps1 @@ -86,92 +86,90 @@ function containsProductCodeDiff($currentDevPackage,$lastDevPackage) { return $false } -if ($MyInvocation.InvocationName -ne ".") { - try { - $regAuth=$registry.replace("https:","") - $filterPackageList= $filterArg -split "," | % { return $_.trim() } - $packageList = @() - #We need to run the npm pack before we set NPM_TOKEN in npmrc so that the npmrc file is in default (empty) state - foreach ($p in $(dir $pathToArtifacts -r -i *.tgz)) { - foreach($filterItem in $filterPackageList) { - if($p.BaseName.contains($filterItem)) { - $packageList += extractPackage $p - } +try { + $regAuth=$registry.replace("https:","") + $filterPackageList= $filterArg -split "," | % { return $_.trim() } + $packageList = @() + #We need to run the npm pack before we set NPM_TOKEN in npmrc so that the npmrc file is in default (empty) state + foreach ($p in $(dir $pathToArtifacts -r -i *.tgz)) { + foreach($filterItem in $filterPackageList) { + if($p.BaseName.contains($filterItem)) { + $packageList += extractPackage $p } } + } - $publishToNpm = $false - if(!$basicDeployment) { - if($registry -eq 'https://registry.npmjs.org/'){ - $publishToNpm = $true - } - else{ - Write-Host "Choosing Private Devops Feed Deployment" - $npmReg = $regAuth.replace("registry/",""); - $env:NPM_TOKEN=$npmToken - npm config set $regAuth`:username=azure-sdk - npm config set $regAuth`:_password=`$`{NPM_TOKEN`} - npm config set $regAuth`:email=not_set - npm config set $npmReg`:username=azure-sdk - npm config set $npmReg`:_password=`$`{NPM_TOKEN`} - npm config set $npmReg`:email=not_set - } - } - else { - Write-Host "Choosing BasicAuth Deployment" - npm config set $regAuth`:username=pat_will_be_used - npm config set $regAuth`:_password=$npmToken - npm config set $regAuth`:email=not_set - } + $publishToNpm = $false + if(!$basicDeployment) { + if($registry -eq 'https://registry.npmjs.org/'){ + $publishToNpm = $true + } + else{ + Write-Host "Choosing Private Devops Feed Deployment" + $npmReg = $regAuth.replace("registry/",""); + $env:NPM_TOKEN=$npmToken + npm config set $regAuth`:username=azure-sdk + npm config set $regAuth`:_password=`$`{NPM_TOKEN`} + npm config set $regAuth`:email=not_set + npm config set $npmReg`:username=azure-sdk + npm config set $npmReg`:_password=`$`{NPM_TOKEN`} + npm config set $npmReg`:email=not_set + } + } + else { + Write-Host "Choosing BasicAuth Deployment" + npm config set $regAuth`:username=pat_will_be_used + npm config set $regAuth`:_password=$npmToken + npm config set $regAuth`:email=not_set + } - $publishList = @() - foreach ($p in $packageList) { - 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 - } - 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 - } - - if ($LastExitCode -ne 0) { - Write-Host "npm publish failed with exit code $LastExitCode" - exit 1 - } - $addTagCheck = 0 - if(($additionalTag) -and ($additionalTag -ne $tag)) { - $nameAndVersion = $p.Project.name + "@" + $p.Project.version - Write-Host "npm dist-tag add $($nameAndVersion) $additionalTag" - npm dist-tag add $nameAndVersion $additionalTag - $addTagCheck = $LastExitCode - } - if ($addTagCheck -ne 0) { - Write-Host "npm dist-tag add failed with exit code $addTagCheck" - exit 1 - } + $publishList = @() + foreach ($p in $packageList) { + 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 + } + 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 } - elseif ($p.Publish -and $publishToNpm) { - $artifactSubPath = $pathToArtifacts -replace $pipelineWorkspace, '' - $destination = "$pipelineWorkspace/temp$artifactSubPath" - write-host "Copy $($p.TarGz) to $destination" - New-Item -ItemType File -Path $destination -Force - Copy-Item -Path $($p.TarGz) -Destination $destination -Force + + if ($LastExitCode -ne 0) { + Write-Host "npm publish failed with exit code $LastExitCode" + exit 1 } - else{ - Write-Host "Skipping package publish $($p.TarGz)" + $addTagCheck = 0 + if(($additionalTag) -and ($additionalTag -ne $tag)) { + $nameAndVersion = $p.Project.name + "@" + $p.Project.version + Write-Host "npm dist-tag add $($nameAndVersion) $additionalTag" + npm dist-tag add $nameAndVersion $additionalTag + $addTagCheck = $LastExitCode + } + if ($addTagCheck -ne 0) { + Write-Host "npm dist-tag add failed with exit code $addTagCheck" + exit 1 } } + elseif ($p.Publish -and $publishToNpm) { + $artifactSubPath = $pathToArtifacts -replace $pipelineWorkspace, '' + $destination = "$pipelineWorkspace/temp$artifactSubPath" + write-host "Copy $($p.TarGz) to $destination" + New-Item -ItemType File -Path $destination -Force + Copy-Item -Path $($p.TarGz) -Destination $destination -Force + } + else{ + Write-Host "Skipping package publish $($p.TarGz)" + } } - finally - { - npm config delete $regAuth`:_authToken - npm config delete $regAuth`:_password - npm config delete $regAuth`:email - npm config delete $regAuth`:username - $env:NPM_TOKEN="" - } +} +finally +{ + npm config delete $regAuth`:_authToken + npm config delete $regAuth`:_password + npm config delete $regAuth`:email + npm config delete $regAuth`:username + $env:NPM_TOKEN="" } From db632670e81ebeec4a6091b71702078c044251c1 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 19 Mar 2024 08:37:13 -0700 Subject: [PATCH 39/49] import module path --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 385d074d1fcd..ffe9eeceffce 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -29,7 +29,7 @@ steps: ProductStateField: $(Tag) - pwsh: | - Import-Module eng/tools/publish-to-npm.ps1 -Function extractPackage -Force + Import-Module $(Build.SourcesDirectory)/eng/tools/publish-to-npm.ps1 -Function extractPackage -Force $packageList = @() foreach ($p in $(dir $(Package.Archive) -r -i *.tgz)) { $packageList += extractPackage $p From a89010e3a0f31d905355bb312bfff7953cecea6a Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 21 Mar 2024 11:20:36 -0700 Subject: [PATCH 40/49] parameter changes --- .../templates/stages/archetype-js-release.yml | 2 ++ .../templates/steps/npm-release-task.yml | 17 ++++++++++------- eng/tools/publish-to-npm.ps1 | 10 ++++------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/eng/pipelines/templates/stages/archetype-js-release.yml b/eng/pipelines/templates/stages/archetype-js-release.yml index c0c5ec04c413..2e3b556e3b9a 100644 --- a/eng/pipelines/templates/stages/archetype-js-release.yml +++ b/eng/pipelines/templates/stages/archetype-js-release.yml @@ -103,6 +103,7 @@ stages: ArtifactName: ${{parameters.ArtifactName}} Artifact: ${{artifact}} Registry: ${{parameters.Registry}} + PathToArtifacts: $(Package.Archive) - pwsh: > write-host "$(Package.Archive)" @@ -248,6 +249,7 @@ stages: ArtifactName: ${{parameters.ArtifactName}} Artifact: ${{artifact}} Registry: ${{parameters.Registry}} + PathToArtifacts: $(Package.Archive) - job: PublishDocsToNightlyBranch condition: or(eq(variables['SetDevVersion'], 'true'), and(eq(variables['Build.Reason'],'Schedule'), eq(variables['System.TeamProject'], 'internal'), ne(variables['Skip.PublishDocs'], 'true'))) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index ffe9eeceffce..e308cfff103b 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -2,6 +2,9 @@ parameters: ArtifactName: '' Artifact: {} Registry: '' + PathToArtifacts: '' + Tag: '' + AdditionalTag: '' steps: - template: /eng/common/pipelines/templates/steps/set-default-branch.yml @@ -11,7 +14,7 @@ steps: 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) -pipelineWorkspace $(Pipeline.Workspace) + arguments: -pathToArtifacts ${{parameters.PathToArtifacts}} -accessLevel "public" -tag "${{parameters.Tag}}" -additionalTag "${{parameters.AdditionalTag}}" -registry ${{parameters.Registry}} -npmToken $(azure-sdk-npm-token) -packagesToPublishPath "$(Pipeline.Workspace)/temp/${{parameters.ArtifactName}}" pwsh: true condition: succeeded() - task: EsrpRelease@6 @@ -20,23 +23,23 @@ steps: ConnectedServiceName: 'ESRP Release Service' Intent: 'PackageDistribution' ContentType: 'npm' - FolderLocation: $(Pipeline.Workspace)/temp/${{parameters.ArtifactName}}/${{parameters.artifact.name}} + FolderLocation: $(Pipeline.Workspace)/temp/${{parameters.ArtifactName}} Owners: $(Build.RequestedForEmail) Approvers: 'azuresdk@microsoft.com' ServiceEndpointUrl: 'https://api.esrp.microsoft.com' MainPublisher: 'ESRPRELPACMANTEST' DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47' - ProductStateField: $(Tag) + ProductStateField: ${{parameters.Tag}} - pwsh: | Import-Module $(Build.SourcesDirectory)/eng/tools/publish-to-npm.ps1 -Function extractPackage -Force $packageList = @() - foreach ($p in $(dir $(Package.Archive) -r -i *.tgz)) { + foreach ($p in $(dir ${{parameters.PathToArtifacts}} -r -i *.tgz)) { $packageList += extractPackage $p } foreach ($p in $packageList) { - if($p.Publish && $(AdditionalTag) && $(AdditionalTag) -ne $(Tag)) { - $(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)" + if($p.Publish && ${{parameters.AdditionalTag}} && ${{parameters.AdditionalTag}} -ne ${{parameters.Tag}}) { + $(Build.SourcesDirectory)/eng/scripts/npm-admin-tasks.ps1 -taskType AddTag -packageName $p.Project.name -pkgVersion $p.Project.version -tagName "${{parameters.AdditionalTag}}" -npmToken "$(azure-sdk-npm-token)" } } @@ -49,6 +52,6 @@ steps: 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) + arguments: -pathToArtifacts ${{parameters.PathToArtifacts}} -accessLevel "public" -tag "${{parameters.Tag}}" -additionalTag "${{parameters.AdditionalTag}}" -registry ${{parameters.Registry}} -npmToken $(azure-sdk-npm-token) pwsh: true condition: succeeded() diff --git a/eng/tools/publish-to-npm.ps1 b/eng/tools/publish-to-npm.ps1 index d19097d75d62..428647f4c3cc 100644 --- a/eng/tools/publish-to-npm.ps1 +++ b/eng/tools/publish-to-npm.ps1 @@ -9,7 +9,7 @@ param ( $basicDeployment=$false, $devopsFeed=$false, $skipDiff=$false, - $pipelineWorkspace + $packagesToPublishPath ) function replaceText($oldText,$newText,$filePath){ @@ -154,11 +154,9 @@ try { } } elseif ($p.Publish -and $publishToNpm) { - $artifactSubPath = $pathToArtifacts -replace $pipelineWorkspace, '' - $destination = "$pipelineWorkspace/temp$artifactSubPath" - write-host "Copy $($p.TarGz) to $destination" - New-Item -ItemType File -Path $destination -Force - Copy-Item -Path $($p.TarGz) -Destination $destination -Force + write-host "Copy $($p.TarGz) to $pipelineWorkspace" + New-Item -ItemType File -Path $pipelineWorkspace -Force + Copy-Item -Path $($p.TarGz) -Destination $pipelineWorkspace -Force } else{ Write-Host "Skipping package publish $($p.TarGz)" From b824a87f16b698f524dada007c53c550027e2f50 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 21 Mar 2024 11:50:10 -0700 Subject: [PATCH 41/49] pwsh loop adjustment --- .../templates/steps/npm-release-task.yml | 23 ++++++++----------- eng/tools/publish-to-npm.ps1 | 11 ++++++--- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index e308cfff103b..4ecb15b299f9 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -14,7 +14,7 @@ steps: inputs: targetType: filePath filePath: eng/tools/publish-to-npm.ps1 - arguments: -pathToArtifacts ${{parameters.PathToArtifacts}} -accessLevel "public" -tag "${{parameters.Tag}}" -additionalTag "${{parameters.AdditionalTag}}" -registry ${{parameters.Registry}} -npmToken $(azure-sdk-npm-token) -packagesToPublishPath "$(Pipeline.Workspace)/temp/${{parameters.ArtifactName}}" + arguments: -pathToArtifacts ${{parameters.PathToArtifacts}} -accessLevel "public" -tag "${{parameters.Tag}}" -registry ${{parameters.Registry}} -npmToken $(azure-sdk-npm-token) -packagesToPublishPath "$(Pipeline.Workspace)/temp/${{parameters.ArtifactName}}" pwsh: true condition: succeeded() - task: EsrpRelease@6 @@ -31,20 +31,17 @@ steps: DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47' ProductStateField: ${{parameters.Tag}} + - task: PowerShell@2 + displayName: Add Additional Tag + inputs: + targetType: filePath + filePath: eng/tools/publish-to-npm.ps1 + arguments: -pathToArtifacts ${{parameters.PathToArtifacts}} -accessLevel "public" -tag "${{parameters.Tag}}" -additionalTag "${{parameters.AdditionalTag}}" -registry ${{parameters.Registry}} -npmToken $(azure-sdk-npm-token) + pwsh: true + condition: succeeded() - pwsh: | - Import-Module $(Build.SourcesDirectory)/eng/tools/publish-to-npm.ps1 -Function extractPackage -Force - $packageList = @() - foreach ($p in $(dir ${{parameters.PathToArtifacts}} -r -i *.tgz)) { - $packageList += extractPackage $p - } - foreach ($p in $packageList) { - if($p.Publish && ${{parameters.AdditionalTag}} && ${{parameters.AdditionalTag}} -ne ${{parameters.Tag}}) { - $(Build.SourcesDirectory)/eng/scripts/npm-admin-tasks.ps1 -taskType AddTag -packageName $p.Project.name -pkgVersion $p.Project.version -tagName "${{parameters.AdditionalTag}}" -npmToken "$(azure-sdk-npm-token)" - } - } - Remove-Item $(System.DefaultWorkingDirectory)/temp/${{parameters.ArtifactName}} -Recurse - displayName: Add Additional Tags + displayName: Remove Temp Packages Publish Directory - ${{ else }}: - task: PowerShell@2 diff --git a/eng/tools/publish-to-npm.ps1 b/eng/tools/publish-to-npm.ps1 index 428647f4c3cc..3cf2d93a515e 100644 --- a/eng/tools/publish-to-npm.ps1 +++ b/eng/tools/publish-to-npm.ps1 @@ -154,9 +154,14 @@ try { } } elseif ($p.Publish -and $publishToNpm) { - write-host "Copy $($p.TarGz) to $pipelineWorkspace" - New-Item -ItemType File -Path $pipelineWorkspace -Force - Copy-Item -Path $($p.TarGz) -Destination $pipelineWorkspace -Force + if ($additionalTag -eq "") { + write-host "Copy $($p.TarGz) to $pipelineWorkspace" + New-Item -ItemType File -Path $pipelineWorkspace -Force + Copy-Item -Path $($p.TarGz) -Destination $pipelineWorkspace -Force + } elseif ($additionalTag -ne $tag) { + npm dist-tag add "$($p.Project.name)@$($p.Project)" $additionalTag + .$(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{ Write-Host "Skipping package publish $($p.TarGz)" From 158098c02bb0795ce27ef692929aa1c28670ec21 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 21 Mar 2024 12:00:22 -0700 Subject: [PATCH 42/49] parameter changes --- eng/tools/publish-to-npm.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/tools/publish-to-npm.ps1 b/eng/tools/publish-to-npm.ps1 index 3cf2d93a515e..7b2e57f511b9 100644 --- a/eng/tools/publish-to-npm.ps1 +++ b/eng/tools/publish-to-npm.ps1 @@ -155,9 +155,9 @@ try { } elseif ($p.Publish -and $publishToNpm) { if ($additionalTag -eq "") { - write-host "Copy $($p.TarGz) to $pipelineWorkspace" - New-Item -ItemType File -Path $pipelineWorkspace -Force - Copy-Item -Path $($p.TarGz) -Destination $pipelineWorkspace -Force + write-host "Copy $($p.TarGz) to $packagesToPublishPath" + New-Item -ItemType File -Path $packagesToPublishPath -Force + Copy-Item -Path $($p.TarGz) -Destination $packagesToPublishPath -Force } elseif ($additionalTag -ne $tag) { npm dist-tag add "$($p.Project.name)@$($p.Project)" $additionalTag .$(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) From 96fc8c1489230ee38b9864cfe887ef535bbd0742 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 21 Mar 2024 12:57:52 -0700 Subject: [PATCH 43/49] add directory --- eng/tools/publish-to-npm.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/tools/publish-to-npm.ps1 b/eng/tools/publish-to-npm.ps1 index 7b2e57f511b9..42dc61f532f2 100644 --- a/eng/tools/publish-to-npm.ps1 +++ b/eng/tools/publish-to-npm.ps1 @@ -156,7 +156,7 @@ try { elseif ($p.Publish -and $publishToNpm) { if ($additionalTag -eq "") { write-host "Copy $($p.TarGz) to $packagesToPublishPath" - New-Item -ItemType File -Path $packagesToPublishPath -Force + New-Item -ItemType Directory -Path $packagesToPublishPath -Force Copy-Item -Path $($p.TarGz) -Destination $packagesToPublishPath -Force } elseif ($additionalTag -ne $tag) { npm dist-tag add "$($p.Project.name)@$($p.Project)" $additionalTag From 85c9a5fabf753eb6762deb3dc6e6a2e44e55ecee Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 21 Mar 2024 14:01:27 -0700 Subject: [PATCH 44/49] if for additional tag --- .../templates/steps/npm-release-task.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 4ecb15b299f9..3c87c455b9d9 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -31,14 +31,15 @@ steps: DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47' ProductStateField: ${{parameters.Tag}} - - task: PowerShell@2 - displayName: Add Additional Tag - inputs: - targetType: filePath - filePath: eng/tools/publish-to-npm.ps1 - arguments: -pathToArtifacts ${{parameters.PathToArtifacts}} -accessLevel "public" -tag "${{parameters.Tag}}" -additionalTag "${{parameters.AdditionalTag}}" -registry ${{parameters.Registry}} -npmToken $(azure-sdk-npm-token) - pwsh: true - condition: succeeded() + - ${{if ne(parameters.AdditionalTag, '')}}: + - task: PowerShell@2 + displayName: Add Additional Tag + inputs: + targetType: filePath + filePath: eng/tools/publish-to-npm.ps1 + arguments: -pathToArtifacts ${{parameters.PathToArtifacts}} -accessLevel "public" -tag "${{parameters.Tag}}" -additionalTag "${{parameters.AdditionalTag}}" -registry ${{parameters.Registry}} -npmToken $(azure-sdk-npm-token) + pwsh: true + condition: succeeded() - pwsh: | Remove-Item $(System.DefaultWorkingDirectory)/temp/${{parameters.ArtifactName}} -Recurse displayName: Remove Temp Packages Publish Directory From f3feee501dc6a46d57d098d8c21c5d3b65787552 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 21 Mar 2024 14:44:54 -0700 Subject: [PATCH 45/49] remove temp package --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 3c87c455b9d9..6048ee7cfa69 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -41,7 +41,7 @@ steps: pwsh: true condition: succeeded() - pwsh: | - Remove-Item $(System.DefaultWorkingDirectory)/temp/${{parameters.ArtifactName}} -Recurse + Remove-Item $(Pipeline.Workspace)/temp/${{parameters.ArtifactName}} -Recurse displayName: Remove Temp Packages Publish Directory - ${{ else }}: From 06e5c4895f5aa39f4cc26b4a5a8668555138df0d Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 25 Mar 2024 10:06:55 -0700 Subject: [PATCH 46/49] spacing --- eng/tools/publish-to-npm.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/tools/publish-to-npm.ps1 b/eng/tools/publish-to-npm.ps1 index 42dc61f532f2..719b8056a890 100644 --- a/eng/tools/publish-to-npm.ps1 +++ b/eng/tools/publish-to-npm.ps1 @@ -159,8 +159,8 @@ try { New-Item -ItemType Directory -Path $packagesToPublishPath -Force Copy-Item -Path $($p.TarGz) -Destination $packagesToPublishPath -Force } elseif ($additionalTag -ne $tag) { - npm dist-tag add "$($p.Project.name)@$($p.Project)" $additionalTag - .$(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) + npm dist-tag add "$($p.Project.name)@$($p.Project)" $additionalTag + . $(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{ From c1a93b966af0aac16e8d0c64bbef480762b84730 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 25 Mar 2024 10:10:36 -0700 Subject: [PATCH 47/49] error action --- eng/tools/publish-to-npm.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eng/tools/publish-to-npm.ps1 b/eng/tools/publish-to-npm.ps1 index 719b8056a890..432d9ed25fd0 100644 --- a/eng/tools/publish-to-npm.ps1 +++ b/eng/tools/publish-to-npm.ps1 @@ -86,6 +86,9 @@ function containsProductCodeDiff($currentDevPackage,$lastDevPackage) { return $false } +$ErrorActionPreference = "Stop" +$PSNativeCommandUseErrorActionPreference = $true + try { $regAuth=$registry.replace("https:","") $filterPackageList= $filterArg -split "," | % { return $_.trim() } From aaaa46d2a331e6545f954ad5443d9fb955d59daa Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 25 Mar 2024 10:15:03 -0700 Subject: [PATCH 48/49] spacing --- eng/tools/publish-to-npm.ps1 | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/eng/tools/publish-to-npm.ps1 b/eng/tools/publish-to-npm.ps1 index 432d9ed25fd0..a025fbb86798 100644 --- a/eng/tools/publish-to-npm.ps1 +++ b/eng/tools/publish-to-npm.ps1 @@ -103,20 +103,20 @@ try { } $publishToNpm = $false - if(!$basicDeployment) { - if($registry -eq 'https://registry.npmjs.org/'){ - $publishToNpm = $true - } - else{ - Write-Host "Choosing Private Devops Feed Deployment" - $npmReg = $regAuth.replace("registry/",""); - $env:NPM_TOKEN=$npmToken - npm config set $regAuth`:username=azure-sdk - npm config set $regAuth`:_password=`$`{NPM_TOKEN`} - npm config set $regAuth`:email=not_set - npm config set $npmReg`:username=azure-sdk - npm config set $npmReg`:_password=`$`{NPM_TOKEN`} - npm config set $npmReg`:email=not_set + if (!$basicDeployment) { + if ($registry -eq 'https://registry.npmjs.org/') { + $publishToNpm = $true + } + else { + Write-Host "Choosing Private Devops Feed Deployment" + $npmReg = $regAuth.replace("registry/",""); + $env:NPM_TOKEN=$npmToken + npm config set $regAuth`:username=azure-sdk + npm config set $regAuth`:_password=`$`{NPM_TOKEN`} + npm config set $regAuth`:email=not_set + npm config set $npmReg`:username=azure-sdk + npm config set $npmReg`:_password=`$`{NPM_TOKEN`} + npm config set $npmReg`:email=not_set } } else { @@ -145,7 +145,7 @@ try { exit 1 } $addTagCheck = 0 - if(($additionalTag) -and ($additionalTag -ne $tag)) { + if (($additionalTag) -and ($additionalTag -ne $tag)) { $nameAndVersion = $p.Project.name + "@" + $p.Project.version Write-Host "npm dist-tag add $($nameAndVersion) $additionalTag" npm dist-tag add $nameAndVersion $additionalTag @@ -161,12 +161,13 @@ try { write-host "Copy $($p.TarGz) to $packagesToPublishPath" New-Item -ItemType Directory -Path $packagesToPublishPath -Force Copy-Item -Path $($p.TarGz) -Destination $packagesToPublishPath -Force - } elseif ($additionalTag -ne $tag) { + } + elseif ($additionalTag -ne $tag) { npm dist-tag add "$($p.Project.name)@$($p.Project)" $additionalTag . $(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{ + else { Write-Host "Skipping package publish $($p.TarGz)" } } From 24e209dcdf1ef2ac30db22bced611fbc8168fad5 Mon Sep 17 00:00:00 2001 From: Albert Cheng <38804567+ckairen@users.noreply.github.com> Date: Mon, 25 Mar 2024 15:40:01 -0700 Subject: [PATCH 49/49] Update eng/pipelines/templates/stages/archetype-sdk-client.yml --- eng/pipelines/templates/stages/archetype-sdk-client.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/stages/archetype-sdk-client.yml b/eng/pipelines/templates/stages/archetype-sdk-client.yml index b5c9df3e4036..1811aba459a4 100644 --- a/eng/pipelines/templates/stages/archetype-sdk-client.yml +++ b/eng/pipelines/templates/stages/archetype-sdk-client.yml @@ -80,7 +80,7 @@ extends: Artifacts: ${{ parameters.Artifacts }} ${{ if eq(parameters.ServiceDirectory, 'template') }}: TestPipeline: true - RunUnitTests: false + RunUnitTests: ${{ parameters.RunUnitTests }} MatrixConfigs: - ${{ each config in parameters.MatrixConfigs }}: - ${{ config }}