Skip to content

Commit

Permalink
Merge e9420f0 into a17c494
Browse files Browse the repository at this point in the history
  • Loading branch information
ckairen authored Mar 18, 2024
2 parents a17c494 + e9420f0 commit 2126346
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 25 deletions.
25 changes: 11 additions & 14 deletions eng/pipelines/templates/stages/archetype-js-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,11 @@ 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:
ArtifactName: ${{parameters.ArtifactName}}
Artifact: ${{artifact}}
Registry: ${{parameters.Registry}}
- pwsh: >
write-host "$(Package.Archive)"
Expand Down Expand Up @@ -250,12 +247,12 @@ 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:
ArtifactName: ${{parameters.ArtifactName}}
Artifact: ${{artifact}}
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
2 changes: 1 addition & 1 deletion eng/pipelines/templates/stages/archetype-sdk-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
61 changes: 61 additions & 0 deletions eng/pipelines/templates/steps/npm-release-task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
parameters:
ArtifactName: ''
Artifact: {}
Registry: ''

steps:
- template: /eng/common/pipelines/templates/steps/set-default-branch.yml
- ${{if eq(parameters.Registry, 'https://registry.npmjs.org/')}}:
- task: PowerShell@2
displayName: Create publish package directory
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)
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'
ConnectedServiceName: 'ESRP Release Service'
Intent: 'PackageDistribution'
ContentType: 'npm'
FolderLocation: $(System.DefaultWorkingDirectory)/temp/${{parameters.ArtifactName}}/${{parameters.artifact.name}}
Owners: $(Build.RequestedForEmail)
Approvers: '[email protected]'
ServiceEndpointUrl: 'https://api.esrp.microsoft.com'
MainPublisher: 'ESRPRELPACMANTEST'
DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47'
ProductStateField: $(Tag)

- 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)"
}
}
Remove-Item $(System.DefaultWorkingDirectory)/temp/${{parameters.ArtifactName}} -Recurse
displayName: Add Additional Tags
- ${{ 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()
30 changes: 20 additions & 10 deletions eng/tools/publish-to-npm.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ param (
$filterArg="",
$basicDeployment=$false,
$devopsFeed=$false,
$skipDiff=$false
$skipDiff=$false,
$pipelineWorkspace
)

function replaceText($oldText,$newText,$filePath){
Expand Down Expand Up @@ -98,11 +99,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 +123,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,6 +153,14 @@ try {
exit 1
}
}
elseif ($p.Publish -and $publishToNpm) {
write-host $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
}
else{
Write-Host "Skipping package publish $($p.TarGz)"
}
Expand Down

0 comments on commit 2126346

Please sign in to comment.