#!/usr/bin/env bash # release: perform the chore work required for a pe-parse/pepy release set -eo pipefail function installed { cmd=$(command -v "${1}") [[ -n "${cmd}" ]] && [[ -f "${cmd}" ]] return ${?} } function die { >&2 echo "Barf: ${*}" exit 1 } # Fail early if we don't have the expected tools. for tool in git python3 twine; do installed "${tool}" || die "Missing dependency: ${tool}" done # Fail early if `git status` reports any untracked changes. [[ -n $(git status -s) ]] && die "Untracked changes in repo" # Next, check the VERSION in version and make sure it doesn't already have a git tag. [[ -f ./VERSION ]] || die "Missing VERSION file; wrong directory?" version=$(<./VERSION) [[ -n $(git tag -l "${version}") ]] && die "git tag for ${version} already exists!" # Next, craft a tag for the current HEAD. Push both the current commit and the tag. git tag "${version}" git push git push origin "${version}" # Finally, build pepy and publish it to PyPI. # Nuke the dist/ directory before, to avoid old sdists. rm -rf dist/ python3 setup.py sdist twine upload dist/* echo OK