Skip to content

Commit 828bdef

Browse files
authored
fix: Publish stage always skipped due to condition evaluation issues (#4094)
Two issues in the Publish stage condition: 1. not(${{ parameters.skipNpmPublish }}) mixes compile-time template expansion with runtime expression evaluation. The YAML boolean expands to 'False'/'True' (capital), which are non-empty strings (always truthy in runtime), so not() always returns false. Fix: use ne() string comparison instead. 2. stageDependencies.Build.BuildAndPack.outputs['check.hasTarballs'] does not resolve correctly under 1ES Pipeline Templates, because templateContext.outputs restructures the job and breaks the output variable reference path. Fix: remove the cross-stage variable dependency and verify tarballs exist inside the Publish job after downloading the artifact.
1 parent d49b99b commit 828bdef

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

.ado/azure-pipelines.publish.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,12 @@ extends:
7979
8080
- script: |
8181
ls -la $(System.DefaultWorkingDirectory)/_packed/
82-
if ls $(System.DefaultWorkingDirectory)/_packed/*.tgz > /dev/null 2>&1; then
83-
echo "##vso[task.setvariable variable=hasTarballs;isOutput=true]true"
84-
else
85-
echo "##vso[task.setvariable variable=hasTarballs;isOutput=true]false"
86-
fi
87-
name: check
8882
displayName: 'List packed tarballs'
8983
9084
- stage: Publish
9185
displayName: Publish to NPM
9286
dependsOn: Build
93-
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'), ne('${{ parameters.skipNpmPublish }}', 'true'), eq(stageDependencies.Build.BuildAndPack.outputs['check.hasTarballs'], 'true'))
87+
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'), ne('${{ parameters.skipNpmPublish }}', 'true'))
9488
jobs:
9589
- job: PublishPackages
9690
displayName: Publish NPM Packages
@@ -113,24 +107,33 @@ extends:
113107
- script: |
114108
echo "Downloaded tarballs:"
115109
ls -la $(System.DefaultWorkingDirectory)/_packed/
116-
displayName: 'List downloaded tarballs'
110+
if ls $(System.DefaultWorkingDirectory)/_packed/*.tgz > /dev/null 2>&1; then
111+
echo "##vso[task.setvariable variable=hasTarballs]true"
112+
else
113+
echo "No tarballs found — nothing to publish."
114+
echo "##vso[task.setvariable variable=hasTarballs]false"
115+
fi
116+
displayName: 'Check downloaded tarballs'
117117
118118
- script: |
119119
yarn
120120
displayName: 'yarn install'
121+
condition: eq(variables['hasTarballs'], 'true')
121122
122123
- script: |
123124
yarn config set npmPublishAccess public
124125
yarn config set npmPublishRegistry "https://registry.npmjs.org"
125126
yarn config set npmAuthToken $(npmAuth)
126127
npm config set //registry.npmjs.org/:_authToken $(npmAuth)
127128
displayName: 'Configure npm publishing auth'
129+
condition: eq(variables['hasTarballs'], 'true')
128130
129131
- script: |
130132
# https://github.com/changesets/changesets/issues/432
131133
# We can't use `changeset publish` because it doesn't support workspaces, so we have to publish each package individually
132134
yarn lage publish --verbose --grouped --reporter azureDevops
133135
displayName: 'Publish NPM Packages'
136+
condition: eq(variables['hasTarballs'], 'true')
134137
135138
- script: |
136139
yarn config unset npmPublishAccess

0 commit comments

Comments
 (0)