11#! /usr/bin/env bash
2+ set -eo pipefail; [[ $RELEASE_TRACE ]] && set -x
23
34PACKAGE_NAME=' beaver'
5+ INIT_PACKAGE_NAME=' beaver'
46PUBLIC=" true"
57
68# Colors
@@ -11,28 +13,46 @@ YELLOW="\033[0;33m" # yellow
1113MAGENTA=" \033[0;35m" # magenta
1214CYAN=" \033[0;36m" # cyan
1315
16+ # ensure wheel is available
17+ pip install wheel > /dev/null
18+
19+ # ensure Pygment is available
20+ pip install Pygments > /dev/null
21+
22+ command -v gitchangelog > /dev/null 2>&1 || {
23+ echo -e " ${RED} WARNING: Missing gitchangelog binary, please run: pip install gitchangelog==2.2.0${COLOR_OFF} \n"
24+ exit 1
25+ }
26+
27+ command -v rst-lint > /dev/null || {
28+ echo -e " ${RED} WARNING: Missing rst-lint binary, please run: pip install restructuredtext_lint${COLOR_OFF} \n"
29+ exit 1
30+ }
31+
1432if [[ " $@ " != " major" ]] && [[ " $@ " != " minor" ]] && [[ " $@ " != " patch" ]]; then
1533 echo -e " ${RED} WARNING: Invalid release type, must specify 'major', 'minor', or 'patch'${COLOR_OFF} \n"
1634 exit 1
1735fi
1836
1937echo -e " \n${GREEN} STARTING RELEASE PROCESS${COLOR_OFF} \n"
2038
39+ set +e;
2140git status | grep " working directory clean" & > /dev/null
2241if [ ! $? -eq 0 ]; then # working directory is NOT clean
2342 echo -e " ${RED} WARNING: You have uncomitted changes, you may have forgotten something${COLOR_OFF} \n"
2443 exit 1
2544fi
45+ set -e;
2646
2747echo -e " ${YELLOW} --->${COLOR_OFF} Updating local copy"
2848git pull -q origin master
2949
3050echo -e " ${YELLOW} --->${COLOR_OFF} Retrieving release versions"
3151
32- current_version=` cat ${PACKAGE_NAME } /__init__.py | grep ' __version__ =' | sed ' s/[^0-9.]//g' `
33- major=` echo $current_version | awk ' {split($0,a,"."); print a[1]}' `
34- minor=` echo $current_version | awk ' {split($0,a,"."); print a[2]}' `
35- patch=` echo $current_version | awk ' {split($0,a,"."); print a[3]}' `
52+ current_version=$( cat ${INIT_PACKAGE_NAME } /__init__.py | grep ' __version__ =' | sed ' s/[^0-9.]//g' )
53+ major=$( echo $current_version | awk ' {split($0,a,"."); print a[1]}' )
54+ minor=$( echo $current_version | awk ' {split($0,a,"."); print a[2]}' )
55+ patch=$( echo $current_version | awk ' {split($0,a,"."); print a[3]}' )
3656
3757if [[ " $@ " == " major" ]]; then
3858 major=$(( $major + 1 )) ;
@@ -49,18 +69,21 @@ next_version="${major}.${minor}.${patch}"
4969
5070echo -e " ${YELLOW} >${COLOR_OFF} ${MAGENTA}${current_version}${COLOR_OFF} -> ${MAGENTA}${next_version}${COLOR_OFF} "
5171
72+ echo -e " ${YELLOW} --->${COLOR_OFF} Ensuring readme passes lint checks (if this fails, run rst-lint)"
73+ rst-lint README.rst > /dev/null
74+
5275echo -e " ${YELLOW} --->${COLOR_OFF} Creating necessary temp file"
53- tempfoo=` basename $0 `
54- TMPFILE=` mktemp /tmp/${tempfoo} .XXXXXX` || {
76+ tempfoo=$( basename $0 )
77+ TMPFILE=$( mktemp /tmp/${tempfoo} .XXXXXX) || {
5578 echo -e " ${RED} WARNING: Cannot create temp file using mktemp in /tmp dir ${COLOR_OFF} \n"
5679 exit 1
5780}
5881
5982find_this=" __version__ = '$current_version '"
6083replace_with=" __version__ = '$next_version '"
6184
62- echo -e " ${YELLOW} --->${COLOR_OFF} Updating ${PACKAGE_NAME } /__init__.py"
63- sed " s/$find_this /$replace_with /" ${PACKAGE_NAME } /__init__.py > $TMPFILE && mv $TMPFILE ${PACKAGE_NAME } /__init__.py
85+ echo -e " ${YELLOW} --->${COLOR_OFF} Updating ${INIT_PACKAGE_NAME } /__init__.py"
86+ sed " s/$find_this /$replace_with /" ${INIT_PACKAGE_NAME } /__init__.py > $TMPFILE && mv $TMPFILE ${INIT_PACKAGE_NAME } /__init__.py
6487
6588echo -e " ${YELLOW} --->${COLOR_OFF} Updating README.rst"
6689find_this=" ${PACKAGE_NAME} .git@$current_version "
83106
84107echo -e " ${YELLOW} --->${COLOR_OFF} Updating CHANGES.rst for new release"
85108version_header=" $next_version ($( date +%F) )"
86- dashes=` yes ' -' | head -n ${# version_header} | tr -d ' \n' `
109+ set +e ; dashes=$( yes ' -' | head -n ${# version_header} | tr -d ' \n' ) ; set -e
87110gitchangelog | sed " 4s/.*/$version_header /" | sed " 5s/.*/$dashes /" > $TMPFILE && mv $TMPFILE CHANGES.rst
88111
89112echo -e " ${YELLOW} --->${COLOR_OFF} Updating debian/changelog"
90113dch -v $next_version " Release version $next_version "
91114dch -r stable
92115
93116echo -e " ${YELLOW} --->${COLOR_OFF} Adding changed files to git"
94- git add CHANGES.rst README.rst debian/changelog ${PACKAGE_NAME } /__init__.py
117+ git add CHANGES.rst README.rst debian/changelog ${INIT_PACKAGE_NAME } /__init__.py
95118if [ -f docs/conf.py ]; then git add docs/conf.py; fi
96119
97120echo -e " ${YELLOW} --->${COLOR_OFF} Creating release"
@@ -106,7 +129,7 @@ git push -q origin master && git push -q --tags
106129if [[ " $PUBLIC " == " true" ]]; then
107130 echo -e " ${YELLOW} --->${COLOR_OFF} Creating python release"
108131 cp README.rst README
109- python setup.py sdist upload > /dev/null
132+ python setup.py sdist bdist_wheel upload > /dev/null
110133 rm README
111134fi
112135
0 commit comments