-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
release.sh
executable file
·80 lines (66 loc) · 1.74 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env bash
# Create releases for pip or docker or both
set -euo pipefail
version="$(pcregrep -wor "\d{4}\.[12]?[0-9]\.[123]?[0-9]" acpype/__init__.py)"
function usage() {
echo "syntax: $0 < [-p, -d] | -a > to create a release for pip or docker or both"
echo " -p : for pip, create wheel and upload to https://pypi.org/project/acpype/ (if you have permission)"
echo " -d : for docker, create images and upload to https://hub.docker.com/u/acpype (if you have permission)"
echo " -a : do both above"
echo " -v : verbose mode, print all commands"
echo " -h : prints this message"
exit 1
}
function run_pip() {
echo ">>> Creating pip package"
poetry build
poetry publish
# python3 -m twine upload --repository testpypi dist/*"$version"* # TestPyPI
# python3 -m twine upload --repository pypi dist/*"$version"* # official release
rm -vfr dist/*"$version"*
}
function run_docker() {
echo ">>> Creating docker images"
docker buildx build --platform linux/amd64 -t acpype/acpype:latest -t acpype/acpype:"$version" .
echo ">>> Pushing docker images"
docker push acpype/acpype --all-tags
docker image rm acpype/acpype:"$version"
}
function run_both() {
run_docker
run_pip
}
do_pip=false
do_doc=false
do_all=false
verb=false
no_args=true
while getopts "adpvh" optionName; do
case "$optionName" in
a) do_all=true ;;
d) do_doc=true ;;
p) do_pip=true ;;
v) verb=true ;;
h) usage ;;
?) usage ;;
*) usage ;;
esac
no_args=false
done
if "${no_args}"; then
usage
elif $do_all && ($do_doc || $do_pip); then
usage
fi
if ${verb}; then
set -x
fi
if $do_pip; then
run_pip
fi
if $do_doc; then
run_docker
fi
if $do_all; then
run_both
fi