Skip to content
This repository has been archived by the owner on Aug 26, 2024. It is now read-only.

Commit

Permalink
Update release script to make it more generic
Browse files Browse the repository at this point in the history
  • Loading branch information
josegonzalez committed Oct 22, 2014
1 parent b389149 commit f7b75e2
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions release
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env bash

PACKAGE_NAME='fuzzywuzzy'
PUBLIC="true"

# Colors
COLOR_OFF="\033[0m" # unsets color to term fg color
RED="\033[0;31m" # red
Expand All @@ -10,23 +13,23 @@ CYAN="\033[0;36m" # cyan

if [[ "$@" != "major" ]] && [[ "$@" != "minor" ]] && [[ "$@" != "patch" ]]; then
echo -e "${RED}WARNING: Invalid release type, must specify 'major', 'minor', or 'patch'${COLOR_OFF}\n"
exit
exit 1
fi

echo -e "\n${GREEN}STARTING RELEASE PROCESS${COLOR_OFF}\n"

git status | grep "working directory clean" &> /dev/null
if [ ! $? -eq 0 ]; then # working directory is NOT clean
echo -e "${RED}WARNING: You have uncomitted changes, you may have forgotten something${COLOR_OFF}\n"
exit
exit 1
fi

echo -e "${YELLOW}--->${COLOR_OFF} Updating local copy"
git pull -q origin master

echo -e "${YELLOW}--->${COLOR_OFF} Retrieving release versions"

current_version=`cat fuzzywuzzy/__init__.py |grep '__version__ ='|sed 's/[^0-9.]//g'`
current_version=`cat ${PACKAGE_NAME}/__init__.py |grep '__version__ ='|sed 's/[^0-9.]//g'`
major=`echo $current_version | awk '{split($0,a,"."); print a[1]}'`
minor=`echo $current_version | awk '{split($0,a,"."); print a[2]}'`
patch=`echo $current_version | awk '{split($0,a,"."); print a[3]}'`
Expand Down Expand Up @@ -56,22 +59,34 @@ TMPFILE=`mktemp /tmp/${tempfoo}.XXXXXX` || {
find_this="__version__ = '$current_version'"
replace_with="__version__ = '$next_version'"

echo -e "${YELLOW}--->${COLOR_OFF} Updating fuzzywuzzy/__init__.py"
sed "s/$find_this/$replace_with/" fuzzywuzzy/__init__.py > $TMPFILE && mv $TMPFILE fuzzywuzzy/__init__.py
echo -e "${YELLOW}--->${COLOR_OFF} Updating ${PACKAGE_NAME}/__init__.py"
sed "s/$find_this/$replace_with/" ${PACKAGE_NAME}/__init__.py > $TMPFILE && mv $TMPFILE ${PACKAGE_NAME}/__init__.py

find_this="fuzzywuzzy.git@$current_version"
replace_with="fuzzywuzzy.git@$next_version"
find_this="${PACKAGE_NAME}.git@$current_version"
replace_with="${PACKAGE_NAME}.git@$next_version"

echo -e "${YELLOW}--->${COLOR_OFF} Updating README.rst"
sed "s/$find_this/$replace_with/" README.rst > $TMPFILE && mv $TMPFILE README.rst

if [ -f docs/conf.py ]; then
echo -e "${YELLOW}--->${COLOR_OFF} Updating docs"
find_this="version = '${current_version}'"
replace_with="version = '${next_version}'"
sed "s/$find_this/$replace_with/" docs/conf.py > $TMPFILE && mv $TMPFILE docs/conf.py

find_this="version = '${current_version}'"
replace_with="release = '${next_version}'"
sed "s/$find_this/$replace_with/" docs/conf.py > $TMPFILE && mv $TMPFILE docs/conf.py
fi

echo -e "${YELLOW}--->${COLOR_OFF} Updating CHANGES.rst for new release"
version_header="$next_version ($(date +%F))"
dashes=`yes '-'|head -n ${#version_header}|tr -d '\n'`
gitchangelog |sed "4s/.*/$version_header/"|sed "5s/.*/$dashes/" > $TMPFILE && mv $TMPFILE CHANGES.rst

echo -e "${YELLOW}--->${COLOR_OFF} Adding changed files to git"
git add CHANGES.rst README.rst fuzzywuzzy/__init__.py
git add CHANGES.rst README.rst ${PACKAGE_NAME}/__init__.py
if [ -f docs/conf.py ]; then git add docs/conf.py; fi

echo -e "${YELLOW}--->${COLOR_OFF} Creating release"
git commit -q -m "Release version $next_version"
Expand All @@ -82,9 +97,11 @@ git tag -a $next_version -m "Release version $next_version"
echo -e "${YELLOW}--->${COLOR_OFF} Pushing release and tags to github"
git push -q origin master && git push -q --tags

echo -e "${YELLOW}--->${COLOR_OFF} Creating python release"
cp README.rst README
python setup.py sdist upload > /dev/null
rm README
if [[ "$PUBLIC" == "true" ]]; then
echo -e "${YELLOW}--->${COLOR_OFF} Creating python release"
cp README.rst README
python setup.py sdist upload > /dev/null
rm README
fi

echo -e "\n${CYAN}RELEASED VERSION ${next_version}!${COLOR_OFF}\n"

0 comments on commit f7b75e2

Please sign in to comment.