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