Commit | Line | Data |
---|---|---|
806e1ea5 DV |
1 | #!/bin/bash |
2 | # This script "releases" a version of dygraphs. | |
3 | ||
4 | if [ $# -ne 1 ]; then | |
5 | echo "Usage: $0 X.Y.Z" >&2 | |
6 | exit 1 | |
7 | fi | |
8 | ||
9 | VERSION=$1 | |
10 | echo $VERSION | egrep '\d+\.\d+\.\d+' > /dev/null | |
11 | if [ $? -ne 0 ]; then | |
12 | echo "Version must be of the form 1.2.3 (got '$VERSION')" >&2 | |
13 | exit 1 | |
14 | fi | |
15 | ||
16 | # Make sure this is being run from a release branch with the correct name. | |
17 | branch=$(git rev-parse --abbrev-ref HEAD) | |
18 | if [ $branch != "release-$VERSION" ]; then | |
19 | echo "Must be on a branch named 'release-$VERSION' (found '$branch')" >&2 | |
20 | exit 1 | |
21 | fi | |
22 | ||
7655a77a DV |
23 | git status | grep 'working directory clean' > /dev/null |
24 | if [ $? -ne 0 ]; then | |
25 | echo "Must release with a clean working directory. Commit your changes." >&2 | |
26 | exit 1 | |
27 | fi | |
28 | ||
9d3b9a9e DV |
29 | grep "$VERSION" package.json |
30 | if [ $? -ne 0 ]; then | |
31 | echo "Version in package.json doesn't match command line argument." >&2 | |
32 | exit 1 | |
33 | fi | |
34 | ||
35 | grep "v$VERSION" bower.json | |
36 | if [ $? -ne 0 ]; then | |
37 | echo "Version in bower.json doesn't match command line argument." >&2 | |
38 | exit 1 | |
39 | fi | |
40 | ||
fd674af0 DV |
41 | grep "$VERSION" releases.json |
42 | if [ $? -ne 0 ]; then | |
43 | echo "Version $VERSION does not appear in releases.json." >&2 | |
44 | exit 1 | |
45 | fi | |
46 | ||
7655a77a DV |
47 | make lint test test-combined |
48 | if [ $? -ne 0 ]; then | |
49 | echo "Tests failed. Won't release!" >&2 | |
50 | exit 1 | |
51 | fi | |
fd674af0 | 52 | git reset --hard # make test-combined deletes the source map |
7655a77a | 53 | |
806e1ea5 DV |
54 | # Push a permanent copy of documentation & generated files to a versioned copy |
55 | # of the site. This is where the downloadable files are generated. | |
56 | # TODO(danvk): make sure this actually generates the downloadable files! | |
57 | echo "Pushing docs and generated files to dygraphs.com/$VERSION" | |
58 | ./push-to-web.sh dygraphs.com:dygraphs.com/$VERSION | |
59 | if [ $? -ne 0 ]; then | |
60 | echo "Push to web failed" >&2 | |
61 | exit 1 | |
62 | fi | |
63 | ||
172be781 DV |
64 | # Everything is good. |
65 | # Switch to the "releases" branch, merge this change and tag it. | |
66 | echo "Switching branches to do the release." | |
67 | git checkout releases | |
68 | git merge --no-ff $branch | |
69 | ||
806e1ea5 DV |
70 | COMMIT=$(git rev-parse HEAD) |
71 | echo "Tagging commit $COMMIT as version $VERSION" | |
7655a77a | 72 | git tag -a "v$VERSION" -m "Release of version $VERSION" |
06682812 | 73 | git push --tags |
806e1ea5 DV |
74 | |
75 | echo "Release was successful!" | |
9023a6d6 DV |
76 | echo "Pushing the new version to dygraphs.com..." |
77 | ./push-to-web.sh dygraphs.com:dygraphs.com | |
78 | ||
79 | echo "Success!\n" | |
80 | echo "Don't forget to merge changes on this branch back into master:" | |
00179556 | 81 | echo "git merge --no-ff $branch" |
172be781 DV |
82 | |
83 | # Discourage users from working on the "releases" branch. | |
84 | git checkout master |