-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.sh
executable file
·22 lines (18 loc) · 996 Bytes
/
publish.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
defaultBranch=master
for branch in $(cat package.json | jq .publishing | jq -r keys[]) ; do
echo "Selected configuration: $branch"
rawRepository=$(cat package.json | jq -r .publishing.$branch.repository)
repository=$(cat package.json | jq -r .publishing.$branch.repository)
defaultRepository=$(cat package.json | jq -r .publishing.$defaultBranch.repository)
if [ $repository = $defaultRepository ]; then
echo "Changing to default repository: $repository"
echo "$( jq --arg repository "$repository" '.repository = $repository' package.json )" > package.json
elif [ $rawRepository != 'null' ]; then
echo "Changing to mirror repository: $repository"
echo "$( jq --arg repository "$repository" '.repository = $repository' package.json )" > package.json
fi
registry=$(cat package.json | jq -r .publishing.$branch.publishConfig.registry)
echo "Publishing to package repository: $registry"
npm publish --registry=$registry --access public
git reset --hard
done