Skip to content

Commit d758863

Browse files
committed
Skip publish stage if nothing to publish
1 parent 5f51e38 commit d758863

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

.ado/azure-pipelines.publish.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,19 @@ extends:
7878
displayName: 'Pack all public packages'
7979
8080
- script: |
81-
echo "Packed tarballs:"
8281
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
8388
displayName: 'List packed tarballs'
8489
8590
- stage: Publish
8691
displayName: Publish to NPM
8792
dependsOn: Build
88-
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'), not(${{ parameters.skipNpmPublish }}))
93+
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'), not(${{ parameters.skipNpmPublish }}), eq(stageDependencies.Build.BuildAndPack.outputs['check.hasTarballs'], 'true'))
8994
jobs:
9095
- job: PublishPackages
9196
displayName: Publish NPM Packages

.github/workflows/pr.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ jobs:
305305
name: NPM Publish Dry Run — Pack
306306
runs-on: ubuntu-latest
307307
timeout-minutes: 60
308+
outputs:
309+
has-tarballs: ${{ steps.check.outputs.has-tarballs }}
308310
steps:
309311
- name: Checkout
310312
uses: actions/checkout@v4
@@ -324,9 +326,17 @@ jobs:
324326
run: yarn lage pack --verbose --grouped
325327

326328
- name: List packed tarballs
327-
run: ls -la _packed/
329+
id: check
330+
run: |
331+
ls -la _packed/
332+
if ls _packed/*.tgz > /dev/null 2>&1; then
333+
echo "has-tarballs=true" >> $GITHUB_OUTPUT
334+
else
335+
echo "has-tarballs=false" >> $GITHUB_OUTPUT
336+
fi
328337
329338
- name: Upload packed tarballs
339+
if: steps.check.outputs.has-tarballs == 'true'
330340
uses: actions/upload-artifact@v4
331341
with:
332342
name: packed-tarballs-dry-run
@@ -337,6 +347,7 @@ jobs:
337347
runs-on: ubuntu-latest
338348
timeout-minutes: 60
339349
needs: publish-dry-run-pack
350+
if: needs.publish-dry-run-pack.outputs.has-tarballs == 'true'
340351
steps:
341352
- name: Checkout
342353
uses: actions/checkout@v4

0 commit comments

Comments
 (0)