Skip to content

Commit

Permalink
Improve release.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippWendler committed Dec 7, 2015
1 parent dcae395 commit 7f5113f
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 27 deletions.
18 changes: 13 additions & 5 deletions doc/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,24 @@ by passing the parameter `--system-site-packages` to `virtualenv`.

## Releasing a new Version

* Make sure to install `pandoc` and `pypandoc` in the virtual environment
you use, otherwise the documentation cannot be converted to the correct
format that PyPI needs.
* Make sure to install `pandoc`, otherwise the documentation cannot be
converted to the correct format that PyPI needs.
You also need `twine`.

* Update version number in field `__version__` of `benchexec/__init__.py`,
e.g., from `1.1-dev` to `1.1`. Update `CHANGELOG.md` and commit.
* Define next version number, e.g., from `1.1-dev` to `1.1`.
Add an according entry to `CHANGELOG.md` and commit.

* Check whether any of the DTD files in `doc/` changed since last release.
If yes, push a copy of the changed DTD with the new version to
`http://www.sosy-lab.org/benchexec/{benchmark,result,table}-<VERSION>.dtd`,
and update the version number in all references to this DTD in BenchExec.

* The remaining steps can also be automated with the script
[release.sh](https://github.com/sosy-lab/benchexec/blob/master/release.sh).

* Update version number in field `__version__` of `benchexec/__init__.py`,
e.g., from `1.1-dev` to `1.1` and commit.

* Create a Git tag:

git tag -s <VERSION>
Expand Down
76 changes: 55 additions & 21 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,27 @@

set -e

VERSION="$(grep __version__ benchexec/__init__.py | sed -e "s/^.*'\(.*\)'.*$/\1/")"
if [ -z "$1" ]; then
echo "Please specify to-be-released version as parameter."
exit 1
fi

OLD_VERSION="$(grep __version__ benchexec/__init__.py | sed -e "s/^.*'\(.*\)'.*$/\1/")"
VERSION="$1"
if [ $(expr match "$VERSION" ".*dev") -gt 0 ]; then
echo "Cannot relase development version, please update benchexec/__init__.py."
echo "Cannot release development version."
exit 1
fi
if [ "$VERSION" = "$OLD_VERSION" ]; then
echo "Version already exists."
exit 1
fi
if ! grep -q "BenchExec $VERSION" CHANGELOG.md; then
echo "Cannot relase version without changelog, please update CHANGELOG.md"
echo "Cannot release version without changelog, please update CHANGELOG.md"
exit 1
fi
if [ ! -z "$(git status -uno -s)" ]; then
echo "Cannot release with local changes, please stash them."
exit 1
fi

Expand All @@ -20,44 +34,62 @@ if [ -z "$DEBEMAIL" ]; then
echo "Please define environment variable DEBEMAIL with your name you want to use for the Debian package."
exit 1
fi

read -p "Do you want to release version '$VERSION'? (y/n) " -n 1 -r
echo
if ! [[ $REPLY =~ ^[Yy]$ ]]; then
exit 0
if ! which pandoc > /dev/null; then
echo 'Please install pandoc, e.g. with "sudo apt-get install pandoc".'
exit 1
fi
if ! which twine > /dev/null; then
echo 'Please install twine, e.g. with "pip3 install --user twine".'
exit 1
fi

# Prepare files with new version number
sed -e "s/^__version__ = .*/__version__ = '$VERSION'/" -i benchexec/__init__.py
dch -v "$VERSION-1" "New upstream version."
dch -r ""

git commit debian/changelog benchexec/__init__.py -m"Release $VERSION"


# Other preparations
DIR="$(pwd)"
DIST_DIR="$DIR/dist-$VERSION"
rm -r "$DIST_DIR" 2>/dev/null || true
mkdir "$DIST_DIR"


# Test and build under Python 3
TEMP3="$(mktemp -d)"
virtualenv -p /usr/bin/python3 --system-site-packages "$TEMP3"
. "$TEMP3/bin/activate"
git clone "file://$DIR" "$TEMP3/benchexec"
pushd "$TEMP3/benchexec"
pip install -e "."
pip install pypandoc
python setup.py nosetests
python setup.py sdist bdist_egg bdist_wheel
popd
deactivate
cp "$TEMP3/benchexec/dist/"* "$DIST_DIR"
rm -rf "$TEMP3"

# Test and build under Python 2
TEMP2="$(mktemp -d)"
virtualenv -p /usr/bin/python2 --system-site-packages "$TEMP2"
virtualenv -p /usr/bin/python2 "$TEMP2"
. "$TEMP2/bin/activate"
git clone "file://$DIR" "$TEMP2/benchexec"
pushd "$TEMP2/benchexec"
pip install -e "."
pip install pypandoc
python setup.py test
python setup.py bdist_egg
popd
deactivate
cp "$TEMP2/benchexec/dist/"* "$DIST_DIR"
rm -rf "$TEMP2"


# Build Debian package
TAR="BenchExec-$VERSION.tar.gz"

TEMP_DEB="$(mktemp -d)"
Expand All @@ -69,30 +101,32 @@ cd "BenchExec-$VERSION"

dh_make -p "benchexec_$VERSION" --createorig -f "../$TAR" -i -c apache || true

echo
echo "In the following editor, please enter 'New upstream version.' in the empty changelog entry."
echo "Press ENTER to continue."
read
dch -v "$VERSION-1"

EDITOR=/bin/true dch -r --no-force-save-on-release
dpkg-buildpackage -us -uc
popd
cp "$TEMP_DEB/BenchExec-$VERSION/debian/changelog" "debian/changelog"
cp "$TEMP_DEB/benchexec_$VERSION-1_all.deb" "$DIST_DIR"
rm -rf "$TEMP_DEB"

for f in "$DIST_DIR/"*; do
gpg --detach-sign -a "$f"
done
git tag -s "$VERSION" -m "Relase $VERSION"


# Upload and finish
read -p "Everything finished, do you want to release version '$VERSION' publically? (y/n) " -n 1 -r
echo
if ! [[ $REPLY =~ ^[Yy]$ ]]; then
exit 0
fi

git push --tags
twine upload "$DIST_DIR/BenchExec"*

read -p "Please enter next version number: " -r
sed -e "s/^__version__ = .*/__version__ = '$REPLY'/" -i benchexec/__init__.py
git commit benchexec/__init__.py -m"Prepare version number for next development cycle."


echo
echo "Please create a release on GitHub and add content from CHANGELOG.md and files from $DIST_DIR/:"
echo "https://github.com/sosy-lab/benchexec/releases"
echo
echo "Please increment version in benchexec/__init__.py to next development version."
echo
echo "Please commit the changed file debian/changelog."
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
] if not PY2 else []),
},
install_requires = ['tempita==0.5.2'],
setup_requires=['nose>=1.0', 'lxml'],
setup_requires=['nose>=1.0'] + ['lxml'] if not PY2 else [],
test_suite = 'nose.collector' if not PY2 else 'benchexec.test_python2.Python2Tests',
zip_safe = True,
)

0 comments on commit 7f5113f

Please sign in to comment.