diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/publish-to-pypi.sh | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/scripts/publish-to-pypi.sh b/scripts/publish-to-pypi.sh index c779419..a3eb1a6 100755 --- a/scripts/publish-to-pypi.sh +++ b/scripts/publish-to-pypi.sh @@ -2,11 +2,13 @@ set -e PYPI_TOKEN="" +ANNOUNCE_MAILING_LIST="~eugenetriguba/taskipy2-announce@lists.sr.ht" main() { parse_args "$@" uv build uv publish --token "$PYPI_TOKEN" + send_announcement_email } usage() { @@ -15,6 +17,12 @@ usage() { echo "Options:" echo " -h, --help Show this help message and exit" echo " -t, --token Required PyPI token for publishing the package" + echo "" + echo "Environment Variables:" + echo " SMTP_HOST: The SMTP host to send an announcement email from." + echo " SMTP_FROM: The email address in the announcement email 'from' field." + echo " SMTP_USER: The username to login the SMTP host with." + echo " SMTP_PASSWORD: The password associated with the username in the SMTP host." } parse_args() { @@ -36,4 +44,53 @@ parse_args() { done } +send_announcement_email() { + _pyproject_version=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/') + _changelog_body=$(extract_changelog_section "$_pyproject_version") + + cat <<EOF >mail.txt +From: ${SMTP_FROM} +To: ${ANNOUNCE_MAILING_LIST} +Subject: [taskipy2] v${_pyproject_version} released + +Hi all, + +taskipy2 v${_pyproject_version} has been released and is now available on PyPI. + + pip install --upgrade taskipy2 + +What's new in v${_pyproject_version}: + +${_changelog_body} + +Full changelog: https://git.sr.ht/~eugenetriguba/taskipy2/tree/main/item/CHANGELOG.md + +Regards, +Eugene Triguba +EOF + + curl \ + --silent \ + --show-error \ + --ssl-reqd \ + --url "smtp://${SMTP_HOST}:587" \ + --user "${SMTP_USER}:${SMTP_PASSWORD}" \ + --mail-from "$SMTP_FROM" \ + --mail-rcpt "$ANNOUNCE_MAILING_LIST" \ + --upload-file mail.txt + + echo "Announcement email sent to $ANNOUNCE_MAILING_LIST" +} + +extract_changelog_section() { + _changelog_version="$1" + awk " + /^\#\# \[$_changelog_version\]/ { found=1; next } + found && /^\#\# \[/ { exit } + found { print } + " CHANGELOG.md | + sed -e 's/^### \(.*\)/\1:/' \ + -e '/./,$!d' +} + main "$@" |