Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not publish to npm if no changes #41

Merged
merged 3 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Add canister id input in the dummy relying party.
- Upgrade `@dfinity/verifiable-credentials` used in the dummy relying party to the latest published version.
- Port vc-util from II to this repository and rename it to `ic-verifiable-credentials`.
- Do not publish to NPM the JS library if there were no changes.

# 2024.06.10

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 --silent 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
Loading