-
Notifications
You must be signed in to change notification settings - Fork 368
/
publish.sh
executable file
·52 lines (42 loc) · 1.29 KB
/
publish.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
# exit when any command fails
set -e
set -x
# function to bump and publish a package
# $1: package name
# $2: package version
function bump_and_npm_publish {
if npm view "$1@$2" > /dev/null 2>&1; then
echo "Package '$1@$2' already exists"
else
echo "Publishing '$1@$2'"
npm version "$2" -w "$1"
npm publish --access public -w "$1"
fi
}
GIT_ROOT_DIR=$(git rev-parse --show-toplevel)
VERSION=$1
# ensure version is of format x.y.z
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "VERSION '$VERSION' is not of format x.y.z"
exit 1
fi
npm install
# Node client
bump_and_npm_publish "@nangohq/node" "$VERSION"
pushd "$GIT_ROOT_DIR/packages/shared"; npm install @nangohq/node@^$VERSION; popd;
# Shared
node scripts/flows.js
bump_and_npm_publish "@nangohq/shared" "$VERSION"
# Update all packages to use the new shared version
package_dirs=("cli" "server" "runner" "jobs" "persist")
for dir in "${package_dirs[@]}"; do
pushd "$GIT_ROOT_DIR/packages/$dir"; npm install @nangohq/shared@^$VERSION; popd;
done
# CLI
bump_and_npm_publish "nango" "$VERSION"
# Frontend
bump_and_npm_publish "@nangohq/frontend" "$VERSION"
pushd "$GIT_ROOT_DIR/packages/webapp"; npm install @nangohq/frontend@^$VERSION; popd;
# DEBUG: show changes in CI
git diff