Skip to content

Commit 2338259

Browse files
authored
Merge pull request #210 from brendandburns/push
Improve build and push scripts.
2 parents 447750e + 571975c commit 2338259

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

build-package.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#!/bin/bash
22

3+
# exit on any error
4+
set -e
5+
6+
. ./pre-check.sh
7+
38
tsc
49
npm pack

pre-check.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
branch=$(git rev-parse --abbrev-ref HEAD)
4+
5+
if [[ "${branch}" != "master" ]]; then
6+
echo "This script can only be run on the master branch. Current branch is ${branch}"
7+
exit 1
8+
fi
9+
10+
if ! git diff --quiet; then
11+
echo "This script must only run on a clean master branch."
12+
echo
13+
git status
14+
exit 1
15+
fi
16+
17+
untracked=$(git ls-files --exclude-standard --others)
18+
19+
if [[ "${untracked}" != "" ]]; then
20+
echo "This script requires no untracked files."
21+
echo
22+
git status
23+
exit 1
24+
fi

push-package.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
11
#!/bin/bash
22

3+
# exit on any error
4+
set -e
5+
6+
version=$(cat package.json | jq -r .version)
7+
8+
. ./pre-check.sh
9+
10+
echo "This will tag and publish package version ${version}"
11+
read -p "Confirm [y/N]" confirm
12+
13+
case "${confirm}" in
14+
y|Y ) echo "Tagging and pushing ${version}";;
15+
* ) echo "Aborting"; exit 0;;
16+
esac
17+
18+
git tag ${1}
19+
git push upstream ${1}
20+
321
npm publish

0 commit comments

Comments
 (0)