-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathupload_to_pip.sh
More file actions
executable file
·62 lines (51 loc) · 1.41 KB
/
Copy pathupload_to_pip.sh
File metadata and controls
executable file
·62 lines (51 loc) · 1.41 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
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
repository="${TWINE_REPOSITORY:-pypi}"
upload=false
usage() {
cat <<'EOF'
Usage: ./upload_to_pip.sh [--upload] [--repository NAME]
Build TB2J distributions and validate them with twine.
Options:
--upload Upload checked artifacts. Without this, only build/check.
--repository NAME Twine repository name from ~/.pypirc (default: pypi).
-h, --help Show this help.
Environment:
TWINE_REPOSITORY Default repository when --repository is not given.
EOF
}
while [[ $# -gt 0 ]]; do
case "$1" in
--upload)
upload=true
shift
;;
--repository)
repository="${2:?--repository requires a value}"
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 2
;;
esac
done
rm -rf -- dist build
uv build --no-sources
artifacts=(dist/*)
if [[ ! -e "${artifacts[0]}" ]]; then
echo "No distribution artifacts were built in dist/." >&2
exit 1
fi
python -m twine check --strict "${artifacts[@]}"
if [[ "$upload" == true ]]; then
python -m twine upload --repository "$repository" --verbose "${artifacts[@]}"
else
echo "Build and twine check passed. Re-run with --upload to publish to '$repository'."
fi