Skip to content

Commit 128abf4

Browse files
committed
Skip SDK publish when no changes since last release
The npm-publish job previously published the SDK to GitHub Packages on every release tag, even when no SDK files had changed. This adds change detection that compares the sdk/ directory between the current and previous release tags, skipping the publish if nothing changed.
1 parent 82d018b commit 128abf4

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

.github/workflows/build.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,27 +356,54 @@ jobs:
356356

357357
steps:
358358
- uses: actions/checkout@v4
359+
with:
360+
fetch-depth: 0 # Need full history for tag comparison
361+
362+
- name: Check for SDK changes
363+
id: sdk-changes
364+
run: |
365+
CURRENT_TAG="${GITHUB_REF_NAME}"
366+
PREVIOUS_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | grep -v "$CURRENT_TAG" | head -n1)
367+
368+
if [ -z "$PREVIOUS_TAG" ]; then
369+
echo "No previous tag found, publishing SDK"
370+
echo "changed=true" >> $GITHUB_OUTPUT
371+
else
372+
CHANGES=$(git diff --name-only "$PREVIOUS_TAG" "$CURRENT_TAG" -- sdk/)
373+
if [ -n "$CHANGES" ]; then
374+
echo "SDK changes detected:"
375+
echo "$CHANGES"
376+
echo "changed=true" >> $GITHUB_OUTPUT
377+
else
378+
echo "No SDK changes since $PREVIOUS_TAG, skipping publish"
379+
echo "changed=false" >> $GITHUB_OUTPUT
380+
fi
381+
fi
359382
360383
- name: Set up Node.js
384+
if: steps.sdk-changes.outputs.changed == 'true'
361385
uses: actions/setup-node@v4
362386
with:
363387
node-version: '20'
364388
registry-url: 'https://npm.pkg.github.com'
365389
scope: '@simplyprint'
366390

367391
- name: Install dependencies and build
392+
if: steps.sdk-changes.outputs.changed == 'true'
368393
working-directory: sdk
369394
run: |
370395
npm ci
371396
npm run build
372397
373398
- name: Update package version
399+
if: steps.sdk-changes.outputs.changed == 'true'
374400
working-directory: sdk
375401
run: |
376402
VERSION="${GITHUB_REF_NAME#v}"
377403
npm version "$VERSION" --no-git-tag-version --allow-same-version
378404
379405
- name: Publish to GitHub Packages
406+
if: steps.sdk-changes.outputs.changed == 'true'
380407
working-directory: sdk
381408
run: npm publish
382409
env:

0 commit comments

Comments
 (0)