Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
#!/usr/bin/env bash
set -euo pipefail

usage() {
cat <<'EOF'
Usage:
scripts/publish.sh [--check|--dry-run]

By default this builds, validates, and uploads the current pyproject.toml
version to PyPI. Use --check or --dry-run to build and validate without
uploading.
EOF
}

version="$(python3 - <<'PY'
try:
import tomllib
Expand All @@ -12,6 +23,25 @@ with open("pyproject.toml", "r", encoding="utf-8") as handle:
PY
)"

upload=true
case "${1:-}" in
"")
;;
"--upload")
;;
"--check"|"--dry-run")
upload=false
;;
"-h"|"--help")
usage
exit 0
;;
*)
usage >&2
exit 2
;;
esac

has_pypirc_credentials() {
local pypirc="${PYPIRC_PATH:-$HOME/.pypirc}"

Expand Down Expand Up @@ -51,11 +81,10 @@ ensure_pypi_credentials() {

python3 -m build
python3 -m twine check "dist/torbot-${version}"*
if [[ "${1:-}" == "--upload" ]]; then
if [[ "$upload" == true ]]; then
ensure_pypi_credentials
python3 -m twine upload "dist/torbot-${version}"*
else
echo "Publishing is ready. Run the following when you have your PyPI token:"
echo "python3 -m twine upload dist/torbot-${version}*"
echo "Or run: scripts/publish.sh --upload"
echo "Package artifacts for torbot ${version} are ready."
echo "Run scripts/publish.sh to upload them to PyPI."
fi
Loading