Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
# The notify job replies in the start notice's thread.
slack-ts: ${{ steps.slack-start.outputs.ts }}

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand All @@ -34,6 +37,7 @@ jobs:

# Non-fatal: Slack being down must not block the release.
- name: Notify Slack (start)
id: slack-start
if: ${{ vars.SLACK_CHANNEL_ID != '' }}
continue-on-error: true
uses: slackapi/slack-github-action@dcb1066f776dd043e64d0e8ba94ca15cc7e1875d # v4.0.0
Expand Down Expand Up @@ -121,6 +125,13 @@ jobs:
if: ${{ !cancelled() && vars.SLACK_CHANNEL_ID != '' }}
runs-on: ubuntu-latest

env:
# Notices reply in the start notice's thread, quoted so YAML keeps the ts a
# string. Without a start notice (its post failed or never ran) this is null,
# which the Slack client drops, and they post to the channel. Failures are
# also broadcast to the channel; success stays in the thread.
THREAD_TS: ${{ needs.build.outputs.slack-ts && format('"{0}"', needs.build.outputs.slack-ts) || 'null' }}

steps:
- name: Notify Slack (checks failed)
if: ${{ needs.pre-publish-checks.result == 'failure' }}
Expand All @@ -144,6 +155,8 @@ jobs:
errors: true
payload: |
channel: ${{ vars.SLACK_CHANNEL_ID }}
thread_ts: ${{ env.THREAD_TS }}
reply_broadcast: ${{ env.THREAD_TS != 'null' }}
text: >-
*plain-parser*: Build of `${{ github.ref_name }}` FAILED :x:. Nothing was published to PyPI.
See <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|the run log>.
Expand All @@ -157,6 +170,8 @@ jobs:
errors: true
payload: |
channel: ${{ vars.SLACK_CHANNEL_ID }}
thread_ts: ${{ env.THREAD_TS }}
reply_broadcast: ${{ env.THREAD_TS != 'null' }}
text: >-
*plain-parser*: Uploading `${{ github.ref_name }}` to the GitHub Release FAILED :x:. Nothing was published to PyPI.
See <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|the run log>.
Expand All @@ -170,6 +185,8 @@ jobs:
errors: true
payload: |
channel: ${{ vars.SLACK_CHANNEL_ID }}
thread_ts: ${{ env.THREAD_TS }}
reply_broadcast: ${{ env.THREAD_TS != 'null' }}
text: >-
*plain-parser*: Publishing `${{ github.ref_name }}` to PyPI FAILED :x:.
See <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|the run log>.
Expand All @@ -195,6 +212,7 @@ jobs:
errors: true
payload: |
channel: ${{ vars.SLACK_CHANNEL_ID }}
thread_ts: ${{ env.THREAD_TS }}
text: >-
*plain-parser*: pre-release `${{ github.ref_name }}` published to PyPI :test_tube:.
Normal installs are unaffected — try it with `pip install --pre plain-parser==${{ steps.version.outputs.version }}`.
Expand All @@ -208,6 +226,23 @@ jobs:
errors: true
payload: |
channel: ${{ vars.SLACK_CHANNEL_ID }}
thread_ts: ${{ env.THREAD_TS }}
text: >-
*plain-parser*: `${{ github.ref_name }}` published to PyPI :white_check_mark:.
Install with `pip install --upgrade plain-parser`.

# Success also puts a ✅ on the start notice, so the result shows in the
# channel without another message. Needs the app's reactions:write scope.
# Non-fatal: the result is already posted, and a re-run gets already_reacted.
- name: Notify Slack (✅ on the start notice)
if: ${{ needs.publish-to-pypi.result == 'success' && env.THREAD_TS != 'null' }}
continue-on-error: true
uses: slackapi/slack-github-action@dcb1066f776dd043e64d0e8ba94ca15cc7e1875d # v4.0.0
with:
method: reactions.add
token: ${{ secrets.SLACK_BOT_TOKEN }}
errors: true
payload: |
channel: ${{ vars.SLACK_CHANNEL_ID }}
timestamp: ${{ env.THREAD_TS }}
name: white_check_mark
Loading