aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Triguba <hello@eugenetriguba.com>2026-03-21 13:18:08 -0400
committerEugene Triguba <hello@eugenetriguba.com>2026-03-21 13:37:32 -0400
commitd83b45fbeea7c5003c0c9495d646e33c0ef4a891 (patch)
tree44e5d6a1be66a36ef43da470dac8ae996aa25a31
parentAdd support for Python 3.6, 3.7, and 3.8 on CI (diff)
downloadtaskipy2-d83b45fbeea7c5003c0c9495d646e33c0ef4a891.zip
Add automated announcement email on pypi publish
-rw-r--r--.builds/release.yml2
-rwxr-xr-xscripts/publish-to-pypi.sh57
2 files changed, 59 insertions, 0 deletions
diff --git a/.builds/release.yml b/.builds/release.yml
index 22181b0..3027e9e 100644
--- a/.builds/release.yml
+++ b/.builds/release.yml
@@ -10,6 +10,7 @@ triggers:
to: builds@eugenetriguba.com
secrets:
- 7e447af3-be10-4abf-8a6f-d6fd2cf7e173
+ - 73a2e7cc-90c1-4e1c-9baf-2f2a19ef3b0e
packages:
- uv
sources:
@@ -19,4 +20,5 @@ tasks:
cd taskipy2
set +x
TOKEN=$(cat ~/.pypi-token)
+ source ~/.smtp-env
./scripts/publish-to-pypi.sh --token "$TOKEN"
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 "$@"