-
Notifications
You must be signed in to change notification settings - Fork 18
/
publish.sh
executable file
·72 lines (64 loc) · 1.57 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#! /bin/bash
set -e
rm -rf packages/convex-helpers/node_modules
npm i
npm run clean
npm run build
npm i
npm run lint
npm run test
git diff --exit-code || {
echo "Uncommitted changes found. Commit or stash them before publishing."
exit 1
}
function cleanup() {
git checkout -- :/packages/convex-helpers/package.json
}
trap cleanup EXIT
pushd packages/convex-helpers >/dev/null
if [ "$1" == "alpha" ]; then
npm version prerelease --preid alpha
else
npm version patch
fi
current=$(npm pkg get version | tr -d '"')
popd >/dev/null
cat <<EOF
Test it:
- Add some example usage to the outer convex-helpers repo.
- Run \`npm pack\` in /dist and install it elsewhere from the .tgz file.
EOF
echo "Latest versions:"
npm view convex-helpers@latest version
npm view convex-helpers@alpha version
read -r -p "Enter the new version number (hit enter for $current): " version
pushd packages/convex-helpers >/dev/null
if [ -n "$version" ]; then
npm pkg set version="$version"
else
version=$current
fi
cp package.json dist/
cd dist
npm publish --dry-run
popd >/dev/null
echo "^^^ DRY RUN ^^^"
read -r -p "Publish $version to npm? (y/n): " publish
if [ "$publish" = "y" ]; then
npm i
pushd packages/convex-helpers/dist >/dev/null
if (echo "$version" | grep alpha >/dev/null); then
npm publish --tag alpha
else
npm publish
fi
popd >/dev/null
git add package.json packages/convex-helpers/package.json
# If there's nothing to commit, continue
git commit -m "npm $version" || true
git tag "npm/$version"
git push origin "npm/$version"
git push
else
echo "Aborted."
fi