Skip to content

Commit

Permalink
test 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ckairen committed Nov 8, 2024
1 parent f594556 commit 8975c2f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
6 changes: 3 additions & 3 deletions eng/pipelines/templates/steps/npm-release-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ steps:
New-Item -ItemType Directory -Force -Path $tempDir
tar -xzf $tarFile -C $tempDir
$packageJsonDir = "$tempDir\package\package.json"
echo "##vso[task.setvariable variable=PackageJsonDir]$packageJsonDir"
$pkg = Get-Content -Raw "$packageJsonDir" | ConvertFrom-Json
$packageName = $pkg.Name
$packageVersion = $pkg.Version
$packageProps = npm view $packageName -json | ConvertFrom-Json
$originalTags = $packageProps.'dist-tags' | ConvertTo-Json -Compress
echo "##vso[task.setvariable variable=PackageName]$packageName"
echo "##vso[task.setvariable variable=OriginalTags]$originalTags"
echo "##vso[task.setvariable variable=IntendedTagVersion]$packageVersion"
displayName: Get original tags
Expand All @@ -41,14 +41,14 @@ steps:
ServiceEndpointUrl: 'https://api.esrp.microsoft.com'
MainPublisher: 'ESRPRELPACMANTEST'
DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47'
productstate: ${{parameters.Tag}}
productstate: 'dev' ${{parameters.Tag}}

- task: Powershell@2
displayName: Verify package tags
inputs:
targetType: filePath
filePath: eng/scripts/verify-npm-tags.ps1
arguments: -originalDistTags '$(OriginalTags)' -intendedTag ${{parameters.Tag}} -intendedTagVersion '$(IntendedTagVersion)' -packageJson $(PackageJsonDir) -npmToken '$(azure-sdk-npm-token)'
arguments: -originalDistTags '$(OriginalTags)' -intendedTag ${{parameters.Tag}} -intendedTagVersion '$(IntendedTagVersion)' -packageName $(PackageName) -npmToken '$(azure-sdk-npm-token)'
pwsh: true

- ${{ if ne(parameters.AdditionalTag, '') }}:
Expand Down
8 changes: 2 additions & 6 deletions eng/scripts/verify-npm-tags.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@ param (
[Parameter(mandatory = $true)]
$intendedTagVersion,
[Parameter(mandatory = $true)]
$packageJson,
$packageName,
[Parameter(mandatory = $true)]
$npmToken
)

$ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $true

$pkg = Get-Content -Raw $packageJson | ConvertFrom-Json
$packageName = $pkg.Name

Write-Host "Verify npm tag versions for package $packageName"

$parsedOriginalDistTags = $originalDistTags | ConvertFrom-Json
Expand All @@ -35,8 +32,7 @@ if ($packageDistTags."$intendedTag" -ne $intendedTagVersion) {

Write-Host "Setting AuthToken Deployment"
$regAuth = "//registry.npmjs.org/"
$env:NPM_TOKEN=$npmToken
npm config set $regAuth`:_authToken=`$`{NPM_TOKEN`}
npm config set $regAuth`:_authToken=$npmToken

foreach($tag in $correctDistTags.PSObject.Properties) {
Write-Host "npm dist-tag add $packageName@$($tag.value) $($tag.Name)"
Expand Down

0 comments on commit 8975c2f

Please sign in to comment.