6262 run : |
6363 gh release upload ${{ github.ref_name }} dist/* --clobber
6464
65- - name : Notify Slack (build failure)
66- if : ${{ failure() && vars.SLACK_CHANNEL_ID != '' }}
67- uses : slackapi/slack-github-action@dcb1066f776dd043e64d0e8ba94ca15cc7e1875d # v4.0.0
68- with :
69- method : chat.postMessage
70- token : ${{ secrets.SLACK_BOT_TOKEN }}
71- errors : true
72- payload : |
73- channel: ${{ vars.SLACK_CHANNEL_ID }}
74- text: >-
75- *Codeplain Client*: Build of `${{ github.ref_name }}` FAILED :x:. Nothing was published to PyPI.
76- See <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|the run log>.
77-
7865 publish-to-pypi :
7966 name : Publish to PyPI
8067 needs : build
8875 id-token : write
8976
9077 steps :
91- # The tag (v0.4.0rc1) without its "v", for the install command in Slack.
92- - name : Version from tag
93- id : version
94- env :
95- TAG : ${{ github.ref_name }}
96- run : echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
97-
9878 - name : Download distribution packages
9979 uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
10080 with :
@@ -104,9 +84,31 @@ jobs:
10484 - name : Publish to PyPI
10585 uses : pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1
10686
107- # Before the success notice, so a failed success post cannot trigger it.
87+ # End-of-run notices run in their own job: a failed Slack post fails only this
88+ # job, not the publish or its GitHub deployment, and "Re-run failed jobs"
89+ # re-posts without publishing again.
90+ notify :
91+ name : Notify Slack
92+ needs : [build, publish-to-pypi]
93+ if : ${{ !cancelled() && vars.SLACK_CHANNEL_ID != '' }}
94+ runs-on : ubuntu-latest
95+
96+ steps :
97+ - name : Notify Slack (build failure)
98+ if : ${{ needs.build.result == 'failure' }}
99+ uses : slackapi/slack-github-action@dcb1066f776dd043e64d0e8ba94ca15cc7e1875d # v4.0.0
100+ with :
101+ method : chat.postMessage
102+ token : ${{ secrets.SLACK_BOT_TOKEN }}
103+ errors : true
104+ payload : |
105+ channel: ${{ vars.SLACK_CHANNEL_ID }}
106+ text: >-
107+ *Codeplain Client*: Build of `${{ github.ref_name }}` FAILED :x:. Nothing was published to PyPI.
108+ See <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|the run log>.
109+
108110 - name : Notify Slack (failure)
109- if : ${{ failure() && vars.SLACK_CHANNEL_ID != ' ' }}
111+ if : ${{ needs.publish-to-pypi.result == 'failure ' }}
110112 uses : slackapi/slack-github-action@dcb1066f776dd043e64d0e8ba94ca15cc7e1875d # v4.0.0
111113 with :
112114 method : chat.postMessage
@@ -118,12 +120,20 @@ jobs:
118120 *Codeplain Client*: Publishing `${{ github.ref_name }}` to PyPI FAILED :x:.
119121 See <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|the run log>.
120122
123+ # The tag (v0.4.0rc1) without its "v", for the install command below.
124+ - name : Version from tag
125+ id : version
126+ if : ${{ needs.publish-to-pypi.result == 'success' }}
127+ env :
128+ TAG : ${{ github.ref_name }}
129+ run : echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
130+
121131 # GitHub marks the release itself as a pre-release; the tag (v0.4.0rc1)
122132 # carries the same intent for PEP 440. pip and uv skip pre-releases by
123133 # default, so "--upgrade" would NOT pick one up. Tell people the command
124134 # that actually works.
125135 - name : Notify Slack (pre-release published)
126- if : ${{ success() && github.event.release.prerelease && vars.SLACK_CHANNEL_ID != '' }}
136+ if : ${{ needs.publish-to-pypi.result == ' success' && github.event.release.prerelease }}
127137 uses : slackapi/slack-github-action@dcb1066f776dd043e64d0e8ba94ca15cc7e1875d # v4.0.0
128138 with :
129139 method : chat.postMessage
@@ -136,7 +146,7 @@ jobs:
136146 Normal installs are unaffected — try it with `pip install --pre codeplain==${{ steps.version.outputs.version }}`.
137147
138148 - name : Notify Slack (release published)
139- if : ${{ success() && !github.event.release.prerelease && vars.SLACK_CHANNEL_ID != '' }}
149+ if : ${{ needs.publish-to-pypi.result == ' success' && !github.event.release.prerelease }}
140150 uses : slackapi/slack-github-action@dcb1066f776dd043e64d0e8ba94ca15cc7e1875d # v4.0.0
141151 with :
142152 method : chat.postMessage
0 commit comments