/ manage.sh
manage.sh
 1  #!/bin/bash
 2  # -*- coding: utf-8 -*-
 3  
 4  set -e
 5  
 6  function publish {
 7      bump
 8      readme
 9      push
10  }
11  
12  function fix_headers {
13      python scripts/fix_headers.py
14  }
15  
16  function bump {
17      previousVersion=$( grep '^version =' setup.py | sed 's/version = \"\(.*\)\"/\1/' )
18      echo "Next version number? (previous: '$previousVersion')"
19      read version
20      if [ -z "$version" ]; then
21          echo "empty version string"
22          exit 1
23      fi
24      sed -i -b "s/version = .*/version = \"$version\"/" setup.py
25  }
26  
27  function readme {
28      # creates a changelog based on the commits from the previous version until now
29      changelog=$(tail -n +6 doc/changes.rst)
30      gitlog=$(git log v$previousVersion.. --oneline --pretty=format:'* %s (%h)' | grep -v "Merge")
31      today=$(date "+(%B %d, %Y)")
32      echo -e "Change log\n==========\n\nStable versions\n~~~~~~~~~~~~~~~\n\nVersion $version $today\n-----------------------------------\n\n$gitlog\n$changelog" > doc/changes.rst
33  }
34  
35  function push {
36      echo "Break (Ctrl+c) here if something is wrong. Else, press enter"
37      read foobar
38  
39      git commit -am "Publish version $version"
40  
41      git tag -m "Version $version" v$version
42  
43      git push --tags ${REMOTE:-origin} master
44  }
45  
46  $1