Skip to content

Commit

Permalink
Do not publish to npm if no changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lmuntaner committed Jul 1, 2024
1 parent 752543e commit c6ba2e4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ jobs:
run: printf '%s\n' '//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}' registry=https://registry.npmjs.org/ always-auth=true >> .npmrc
- name: Publish
working-directory: ${{env.working-directory}}
run: npm publish --provenance --access public
run: ./scripts/publish-npm.sh
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# NPM libraries
node_modules
dist
# Output of 'npm pack'
*.tgz

# Editor settings
.vscode
Expand Down
14 changes: 14 additions & 0 deletions js-library/scripts/publish-npm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

# Reference: NPM RRFC --if-needed https://github.com/npm/rfcs/issues/466

LOCAL_SHASUM=$(npm pack --json | jq '.[] | .shasum' | sed -r 's/^"|"$//g')

NPM_TARBALL=$(npm show @dfinity/verifiable-credentials dist.tarball)
NPM_SHASUM=$(curl -s "$NPM_TARBALL" 2>&1 | shasum | cut -f1 -d' ')

if [ "$LOCAL_SHASUM" == "$NPM_SHASUM" ]; then
echo "No changes in @dfinity/verifiable-credentials need to be published to NPM."
else
npm publish --provenance --access public
fi

0 comments on commit c6ba2e4

Please sign in to comment.