Skip to content

Commit

Permalink
Release scripts (#75)
Browse files Browse the repository at this point in the history
* added release scripts
  • Loading branch information
akmorrow13 authored Mar 5, 2021
1 parent 58931c8 commit 4490851
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 4 deletions.
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ check_clean_working_copy:
|| ( printf "$(red)Your working copy looks dirty.$(normal)" ; false )
@git diff --cached --exit-code > /dev/null \
|| ( printf "$(red)Your index looks dirty.$(normal)" ; false )
@test -z "$$(git ls-files --other --exclude-standard --directory)" \
|| ( printf "$(red)You have are untracked files:$(normal)" \
; git ls-files --other --exclude-standard --directory \
; false )

pypi: clean clean_sdist check_clean_working_copy
set -x \
Expand Down
12 changes: 12 additions & 0 deletions release/RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Cutting a release



1. Run `scripts/release.sh`. This cuts a new release on PyPI. You
will have to have a PyPI account and have access to the epitome
project for this to work.

2. The release script will push a release branch to your repository.
Make a pull request to upstream from this branch.

3. Tag a release on github.
73 changes: 73 additions & 0 deletions release/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/sh

set -e -x

# do we have enough arguments?
if [ $# -lt 2 ]; then
echo "Usage:"
echo
echo "./release.sh <release version> <development version>"
exit 1
fi

# get current version
current_version=$(python version.py)

# get current branch
branch=$(git status -bs | awk '{ print $2 }' | awk -F'.' '{ print $1 }' | head -n 1)

# fclean up if something goes wrong
function clean_up {

find . -name "*.bak" -exec rm -f {} \;
git checkout version.py
git checkout ${branch}
git branch -D ${release}
}
trap clean_up EXIT

# pick arguments
release=$1
devel=$2

# checkout release
git checkout -b ${release} ${branch}

# update current version
find . -name "version.py" -exec sed -e "s/${current_version}/${release}/g" \
-i.${current_version}.bak '{}' \;

find . -name "*${current_version}.bak" -exec rm -f {} \;

# commit version changes
git add version.py
# allow empty in case version was already release version (mainly for pre-releases)
git commit --allow-empty -m "bumped version from ${current_version} to release version ${release}"

# build sdist and push to pypi
pip install twine
make pypi
if [ $? != 0 ]; then
echo "Releasing epitome to PyPi failed."
exit 1
fi

# push branch to upstream
git push upstream ${release}

# update version to devel
current_version=$(python version.py)
find . -name "version.py" -exec sed -e "s/${release}/${devel}/g" \
-i.${release}.bak '{}' \;

find . -name "*${release}.bak" -exec rm -f {} \;

# commit version changes
git add version.py
git commit -m "bumped version from ${release} to ${devel}"

# pull request devel to master
git push origin ${release}

git checkout master
echo "Done. Now make a pull request from ${release} and tag a release on github for ${release}"

0 comments on commit 4490851

Please sign in to comment.