Skip to content

Commit a600bbf

Browse files
committed
add release.sh
Based on @U8NWXD's script in the vivarium-core repo. This runs pytest but uploads to PyPI even if some tests fail.
1 parent 12c8c78 commit a600bbf

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

release.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
# Build a new release including a git tag and and publish it to PyPI.
3+
# Do some basic checks to avoid mistakes.
4+
#
5+
# Usage: ./release.sh 0.1.0
6+
7+
set -eu
8+
9+
version=$1
10+
11+
# Check the version number.
12+
setup_py_version="$(python setup.py --version)"
13+
if [ "$setup_py_version" != "$version" ]; then
14+
echo "setup.py has version `$setup_py_version`, not `$version`."
15+
echo "Aborting."
16+
exit 1
17+
fi
18+
19+
# Check that the working directory is clean.
20+
if [ ! -z "$(git status --untracked-files=no --porcelain)" ]; then
21+
echo "You have uncommitted git changes."
22+
echo "Aborting."
23+
exit 1
24+
fi
25+
26+
# Check that we are on master.
27+
branch="$(git rev-parse --abbrev-ref HEAD)"
28+
if [ "$branch" != "master" ]; then
29+
echo "You are on git branch `$branch` but should release from `master`."
30+
echo "Aborting."
31+
exit 1
32+
fi
33+
34+
# Create and push a git tag.
35+
git tag -m "Version v$version" "v$version"
36+
git push --tags
37+
38+
# Compile and test, allowing test failures.
39+
make clean compile
40+
set +e
41+
pytest
42+
set -e
43+
44+
# Create and publish the package.
45+
rm -rf dist build *.egg-info
46+
python setup.py sdist
47+
twine upload dist/*
48+
49+
echo "Version v$version has been published on PyPI and has a git tag."
50+
echo "Please make a GitHub Release from that tag."

0 commit comments

Comments
 (0)