-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: publish to npm only if needed (#432)
# Motivation So far, we've been incrementing the version of all libraries when we publish, even if some of them received no improvements or fixes. I find this approach a bit cumbersome. Since I propose to commit to semantic versioning (#431), a better approach would be most welcomed. That's why this PR introduces a publication script that handles the publishing of libraries only if they were actually modified. # Changes - use `shasum` to compare local library with npm and publish only upon differences
- Loading branch information
1 parent
21a73b7
commit 16a3ea4
Showing
2 changed files
with
27 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Reference: NPM RRFC --if-needed https://github.com/npm/rfcs/issues/466 | ||
|
||
function publish_npm() { | ||
local lib=$1 | ||
|
||
LOCAL_SHASUM=$(npm pack -w packages/"$lib" --json | jq '.[] | .shasum' | sed -r 's/^"|"$//g') | ||
|
||
NPM_TARBALL=$(npm show @dfinity/"$lib" 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/$lib need to be published to NPM." | ||
else | ||
npm publish --workspace=packages/"$lib" --provenance --access public | ||
fi | ||
} | ||
|
||
# Tips: libs use by other libs first | ||
LIBS=utils,ledger,nns-proto,nns,sns,cmc,ckbtc,ic-management | ||
|
||
for lib in $(echo $LIBS | sed "s/,/ /g"); do | ||
publish_npm "$lib" | ||
done |