utils.rb: fix handling of require return value
[rbot] / tag-release
1 #!/bin/bash
2
3 if [ -z $1 ]; then
4         echo "Please specify a version"
5         exit
6 fi
7
8 abort() {
9         echo $1
10         exit 1
11 }
12
13 FULLVERSION=$1
14 VERSION=${FULLVERSION/-*/}
15
16 echo "Full version: $FULLVERSION"
17 echo "Version: $VERSION"
18
19 sed -i -e "/^\$version =/ c \$version = '$FULLVERSION'" launch_here.rb
20 sed -i -e "/^\$version ||=/ c \$version ||= '$FULLVERSION'" bin/rbot
21 sed -i -e "/^  s.version =/ c \  s.version = '$VERSION'" Rakefile
22
23 NOGIT=${FULLVERSION/-git/}
24 if [ $NOGIT == $FULLVERSION ]; then
25         # Not a git version
26         rake package || abort "Failed to build package!"
27         git commit -m "Version $FULLVERSION" -a || abort "Failed to commit release!"
28         git tag -a -m "rbot $FULLVERSION" rbot-$FULLVERSION || abort "Failed to tag release!"
29         if [ $VERSION != $FULLVERSION ]; then
30                 pushd pkg
31                 mv rbot-$VERSION.gem rbot-$FULLVERSION.gem
32                 mv rbot-$VERSION.tgz rbot-$FULLVERSION.tgz
33                 mv rbot-$VERSION.zip rbot-$FULLVERSION.zip
34                 popd
35         fi
36 else
37         # git version
38         git commit -m "Start working on $NOGIT" -a
39 fi