forked from pouchdb/pouchdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Recover if publishing packages fails part-way through
Co-Authored-By: Alba Herrerias <[email protected]>
- Loading branch information
1 parent
4dcaac8
commit 5b07d18
Showing
3 changed files
with
74 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,4 @@ tests/integration/utils-bundle.js | |
package-lock.json | ||
yarn.lock | ||
/.eslintcache | ||
release-todo.txt |
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,71 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
publish_packages () { | ||
local root_dir="$PWD" | ||
local todo="$root_dir/release-todo.txt" | ||
|
||
if [[ ! -e "$todo" ]] ; then | ||
echo 'No packages to release, quitting.' | ||
return 0 | ||
fi | ||
|
||
local pkgs=($(cat "$todo")) | ||
local failed='n' | ||
|
||
for pkg in "${pkgs[@]}" ; do | ||
cd "$root_dir" | ||
|
||
if ! should_publish "$pkg" ; then | ||
continue | ||
fi | ||
|
||
if [[ "$failed" == 'n' ]] ; then | ||
if ! publish_package "$pkg" ; then | ||
failed='y' | ||
echo "Publishing '$pkg' failed, quitting." | ||
echo "$pkg" > "$todo" | ||
fi | ||
else | ||
echo "$pkg" >> "$todo" | ||
fi | ||
done | ||
|
||
if [[ "$failed" == 'n' ]] ; then | ||
rm "$todo" | ||
fi | ||
} | ||
|
||
should_publish () { | ||
local pkg="$1" | ||
|
||
if [ ! -d "packages/node_modules/$pkg" ]; then | ||
return 1 | ||
elif [ "true" = $(node --eval "console.log(require('./packages/node_modules/$pkg/package.json').private);") ]; then | ||
return 1 | ||
else | ||
return 0 | ||
fi | ||
} | ||
|
||
publish_package () { | ||
local pkg="$1" | ||
|
||
cd "packages/node_modules/$pkg" | ||
echo "Publishing $pkg..." | ||
|
||
if [ -n "$DRY_RUN" ]; then | ||
echo "Dry run, not publishing" | ||
elif [ -n "$BETA" ]; then | ||
if ! npm publish --tag beta ; then | ||
return 1 | ||
fi | ||
else | ||
if ! npm publish ; then | ||
return 1 | ||
fi | ||
fi | ||
} | ||
|
||
publish_packages |
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