1 | #!/usr/bin/env bash
|
2 | # Tag and push a release.
|
3 |
|
4 | set -e
|
5 |
|
6 | # Make sure we're in the project root.
|
7 |
|
8 | cd $(dirname "$0")/..
|
9 |
|
10 | # Make sure the darn thing works
|
11 |
|
12 | npm update && script/smoke-test
|
13 |
|
14 | # Make sure we're on the master branch.
|
15 |
|
16 | (git branch | grep -q '* master') || {
|
17 | echo "Only release from the master branch."
|
18 | exit 1
|
19 | }
|
20 |
|
21 | # Figure out what version we're releasing.
|
22 |
|
23 | tag=v`node -e 'console.log(require("./package.json").version)'`
|
24 |
|
25 | # Ensure there's a line in the CHANGELOG
|
26 |
|
27 | grep "$tag" CHANGELOG.md || {
|
28 | echo "No entry for '$tag' found in the CHANGELOG."
|
29 | exit 1
|
30 | }
|
31 |
|
32 | # Make sure we haven't released this version before.
|
33 |
|
34 | git fetch -t origin
|
35 |
|
36 | (git tag -l | grep -q "$tag") && {
|
37 | echo "Whoops, there's already a '${tag}' tag."
|
38 | exit 1
|
39 | }
|
40 |
|
41 | # Tag it and bag it.
|
42 |
|
43 | npm publish && git tag "$tag" &&
|
44 | git push origin master --tags
|