Skip to content

Commit 1c6e00d

Browse files
committed
ci(publish): post to #deploy on PyPI publish
1 parent 6790ab1 commit 1c6e00d

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,28 @@ jobs:
6767

6868
- name: Publish via Trusted Publishing
6969
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
70+
71+
# Announce the release in #deploy. Runs only when the publish above
72+
# succeeded. Posts via the shared Hotdata CI Slack app (bot token), so the
73+
# same SLACK_CI_BOT_TOKEN org secret drives notifications across SDK repos.
74+
- name: "Notify #deploy on Slack"
75+
# The publish above is irreversible, so a Slack/token hiccup must not
76+
# mark a successful release as failed and trigger false-alarm retries.
77+
continue-on-error: true
78+
env:
79+
SLACK_CI_BOT_TOKEN: ${{ secrets.SLACK_CI_BOT_TOKEN }}
80+
run: |
81+
set -euo pipefail
82+
if [ -z "${SLACK_CI_BOT_TOKEN:-}" ]; then
83+
echo "SLACK_CI_BOT_TOKEN not set; skipping Slack notification" >&2
84+
exit 0
85+
fi
86+
version="${GITHUB_REF_NAME#v}"
87+
text=":package: *hotdata* \`v${version}\` published to PyPI — <https://pypi.org/project/hotdata/${version}/|PyPI> · <https://github.com/${GITHUB_REPOSITORY}/releases/tag/${GITHUB_REF_NAME}|release notes>"
88+
# #deploy channel ID (rename-proof). chat.postMessage returns HTTP 200
89+
# even on logical errors, so assert on .ok to fail the step.
90+
curl -sSf -X POST https://slack.com/api/chat.postMessage \
91+
-H "Authorization: Bearer ${SLACK_CI_BOT_TOKEN}" \
92+
-H 'Content-Type: application/json; charset=utf-8' \
93+
--data "$(jq -n --arg ch 'C0ARK84E1D4' --arg text "$text" '{channel:$ch, text:$text}')" \
94+
| jq -e '.ok' >/dev/null

0 commit comments

Comments
 (0)