forked from bachya/simplisafe-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease
More file actions
executable file
·63 lines (51 loc) · 1.38 KB
/
Copy pathrelease
File metadata and controls
executable file
·63 lines (51 loc) · 1.38 KB
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
#!/bin/sh
set -e
REPO_PATH="$( dirname "$( cd "$(dirname "$0")" ; pwd -P )" )"
if [ -z "$1" ]; then
echo "Usage: script/release [patch | minor | major]"
exit 1
fi
if [ "$(git rev-parse --abbrev-ref HEAD)" != "dev" ]; then
echo "Refusing to publish a release from a branch other than dev"
exit 1
fi
if [ -z "$(command -v poetry)" ]; then
echo "Poetry needs to be installed to run this script: pip3 install poetry"
exit 1
fi
# Temporarily uninstall pre-commit hooks so that we can push to dev and master:
pre-commit uninstall
old_version="$(poetry version | awk -F' ' '{ print $2 }')"
case "$1" in
patch)
poetry version patch
;;
minor)
poetry version minor
;;
major)
poetry version major
;;
*)
echo "Unknown release action: \"$1\""
exit 1
;;
esac
# Update the PyPI package version:
new_version="$(poetry version | awk -F' ' '{ print $2 }')"
git add pyproject.toml
# Update the docs version:
sphinx_conf=$(sed "s/$old_version/$new_version/g" "$REPO_PATH/docs/conf.py")
echo "$sphinx_conf" > "$REPO_PATH/docs/conf.py"
git add docs/conf.py
# Commit, tag, and push:
git commit -m "Bump version to $new_version"
git tag "$new_version"
git push && git push --tags
# Merge dev into master:
git checkout master
git merge dev
git push
git checkout dev
# Re-initialize pre-commit:
pre-commit install