-
Notifications
You must be signed in to change notification settings - Fork 95
/
release.sh
executable file
·65 lines (55 loc) · 1.85 KB
/
release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
# Script used to execute a puncover release:
#
# 1. Update the version in the code
# 2. Commit the change
# 3. Tag the commit
# 4. Push the commit and the tag
# 5. Build the package
# 6. Upload the package to PyPI
# 7. Create a release on GitHub
# 8. Upload the package to the release on GitHub
#
# It can be run for example like so:
#
# PUNCOVER_VERSION=0.1.0 ./release.sh
set -euo pipefail
if [[ -z "${PUNCOVER_VERSION:-}" ]]; then
echo "PUNCOVER_VERSION must be set"
exit 1
fi
# check that the twine tool is installed
if ! command -v twine &> /dev/null; then
echo "twine could not be found, install with 'pip install twine'"
exit 1
fi
# confirm that the token is set to TWINE_PASSWORD + TWINE_USERNAME
if [[ -z "${TWINE_PASSWORD:-}" || -z "${TWINE_USERNAME:-}" ]]; then
echo "TWINE_PASSWORD and TWINE_USERNAME must be set"
exit 1
fi
# check if tag already exists
if git rev-parse -q --verify "refs/tags/${PUNCOVER_VERSION}"; then
echo "Tag ${PUNCOVER_VERSION} already exists"
exit 1
fi
PUNCOVER_VERSION_COMMA_DELIMITED=$(echo ${PUNCOVER_VERSION} | sed 's/\./, /g')
if grep -q "${PUNCOVER_VERSION_COMMA_DELIMITED}" puncover/version.py; then
echo "Version ${PUNCOVER_VERSION} already set in puncover/version.py"
exit 1
fi
# little sed magic to update the version in the code
sed -i -r 's/(.*__version_info__ = )\(.*\)/\1\('"${PUNCOVER_VERSION_COMMA_DELIMITED}"'\)/g' puncover/version.py
git add . && git commit -m "Bump version to ${PUNCOVER_VERSION}"
git tag -a {-m=,}${PUNCOVER_VERSION}
rm -rf dist
python setup.py sdist bdist_wheel
read -p "Ready to push to GitHub and publish to PyPi? " -n 1 -r
echo # move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
git push && git push --tags
twine upload dist/*
gh release create --generate-notes ${PUNCOVER_VERSION}
gh release upload ${PUNCOVER_VERSION} dist/*
fi