#!/usr/bin/env bash # Deploy a new version of a Python library: # # 1. Bump the version # 2. Tag the Git commit # 3. Push to PyPI and GitHub. # # This probably works for other projects as well, but relies on certain # aspects of the way the repos are laid out that may not be universal. # # Note: unlike most Python scripts in this repo, this should run in # the project virtualenv rather than the script virtualenv. set -o errexit set -o nounset print_info '-> rm -rv dist/*' rm -rv dist/* echo "" print_info "-> uv build" uv build echo "" print_info "-> uv publish --username=__token__ --password=$(…)" uv publish --username=__token__ --password=$(security find-generic-password -s 'https://upload.pypi.org/legacy/' -a __token__ -w) echo "" version=$(find src -name __init__.py \ | xargs grep '__version__ =' \ | awk '{print $3}' \ | tr -d '"') print_info "-> git tag v$version" git tag "v$version" echo "" print_info "-> git push origin main --tag" git push origin main --tag