1111 name : Beta Release
1212 runs-on : ubuntu-latest
1313 if : github.ref == 'refs/heads/master'
14+ outputs :
15+ version : ${{ steps.get_version.outputs.version }}
16+ status : ${{ job.status }}
1417
1518 steps :
1619 - name : Checkout code
@@ -39,123 +42,20 @@ jobs:
3942 run : |
4043 twine upload dist/*
4144
42- - name : Get version for beta
45+ - name : Get version
4346 if : always()
44- id : get_beta_version
47+ id : get_version
4548 run : |
4649 VERSION=$(python3 -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
4750 echo "version=$VERSION" >> $GITHUB_OUTPUT
48-
49- - name : Send Slack notification on success
50- if : success()
51- uses : slackapi/slack-github-action@v1
52- with :
53- payload : |
54- {
55- "text": "✅ SUCCESSFUL: Beta Release ${{ steps.get_beta_version.outputs.version }}",
56- "blocks": [
57- {
58- "type": "section",
59- "text": {
60- "type": "mrkdwn",
61- "text": "*Beta Release Successful* ✅\n*Version:* ${{ steps.get_beta_version.outputs.version }}\n*Repository:* ${{ github.repository }}\n*Branch:* ${{ github.ref_name }}\n*Commit:* <${{ github.event.head_commit.url }}|${{ github.sha }}>\n*Author:* ${{ github.event.head_commit.author.name }}\n*Message:* ${{ github.event.head_commit.message }}"
62- }
63- }
64- ]
65- }
66- env :
67- SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
68- continue-on-error : true
69-
70- - name : Send Slack notification on failure
71- if : failure()
72- uses : slackapi/slack-github-action@v1
73- with :
74- payload : |
75- {
76- "text": "❌ FAILED: Beta Release",
77- "blocks": [
78- {
79- "type": "section",
80- "text": {
81- "type": "mrkdwn",
82- "text": "*Beta Release Failed* ❌\n*Repository:* ${{ github.repository }}\n*Branch:* ${{ github.ref_name }}\n*Commit:* <${{ github.event.head_commit.url }}|${{ github.sha }}>\n*Author:* ${{ github.event.head_commit.author.name }}\n*Workflow Run:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Details>"
83- }
84- }
85- ]
86- }
87- env :
88- SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
89- continue-on-error : true
90-
91- - name : Send Slack notification on cancellation
92- if : cancelled()
93- uses : slackapi/slack-github-action@v1
94- with :
95- payload : |
96- {
97- "text": "⚠️ ABORTED: Beta Release",
98- "blocks": [
99- {
100- "type": "section",
101- "text": {
102- "type": "mrkdwn",
103- "text": "*Beta Release Aborted* ⚠️\n*Repository:* ${{ github.repository }}\n*Branch:* ${{ github.ref_name }}\n*Commit:* <${{ github.event.head_commit.url }}|${{ github.sha }}>\n*Author:* ${{ github.event.head_commit.author.name }}"
104- }
105- }
106- ]
107- }
108- env :
109- SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
110- continue-on-error : true
111-
112- - name : Send email notification on success
113- if : success()
114- uses : dawidd6/action-send-mail@v3
115- with :
116- server_address : smtp.gmail.com
117- server_port : 587
118- username : ${{ secrets.EMAIL_USERNAME }}
119- password : ${{ secrets.EMAIL_PASSWORD }}
120- subject : " SUCCESSFUL: Beta Release '${{ github.repository }}' [Build #${{ github.run_number }}]"
121- 122- from :
GitHub Actions <[email protected] > 123- body : |
124- SUCCESSFUL: Beta Release '${{ github.repository }}' [Build #${{ github.run_number }}]
125-
126- Version: ${{ steps.get_beta_version.outputs.version }}
127- Branch: ${{ github.ref_name }}
128- Commit: ${{ github.sha }}
129- Author: ${{ github.event.head_commit.author.name }}
130-
131- Check workflow run at: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
132- continue-on-error : true
133-
134- - name : Send email notification on failure
135- if : failure()
136- uses : dawidd6/action-send-mail@v3
137- with :
138- server_address : smtp.gmail.com
139- server_port : 587
140- username : ${{ secrets.EMAIL_USERNAME }}
141- password : ${{ secrets.EMAIL_PASSWORD }}
142- subject : " FAILED: Beta Release '${{ github.repository }}' [Build #${{ github.run_number }}]"
143- 144- from :
GitHub Actions <[email protected] > 145- body : |
146- FAILED: Beta Release '${{ github.repository }}' [Build #${{ github.run_number }}]
147-
148- Branch: ${{ github.ref_name }}
149- Commit: ${{ github.sha }}
150- Author: ${{ github.event.head_commit.author.name }}
151-
152- Check console output at: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
153- continue-on-error : true
15451
15552 prod-release :
15653 name : Production Release
15754 runs-on : ubuntu-latest
15855 if : github.ref == 'refs/heads/latest'
56+ outputs :
57+ version : ${{ steps.get_version.outputs.version }}
58+ status : ${{ job.status }}
15959
16060 steps :
16161 - name : Checkout code
18181 twine upload dist/*
18282
18383 - name : Get version from pyproject.toml
84+ if : always()
18485 id : get_version
18586 run : |
18687 VERSION=$(python3 -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
@@ -204,20 +105,40 @@ jobs:
204105 generate_release_notes : true
205106 env :
206107 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
108+
109+ notify :
110+ name : Send Notifications
111+ runs-on : ubuntu-latest
112+ needs : [beta-release, prod-release]
113+ if : always()
114+
115+ steps :
116+ - name : Determine release type and status
117+ id : release_info
118+ run : |
119+ if [ "${{ github.ref }}" == "refs/heads/master" ]; then
120+ echo "type=Beta" >> $GITHUB_OUTPUT
121+ echo "version=${{ needs.beta-release.outputs.version }}" >> $GITHUB_OUTPUT
122+ echo "result=${{ needs.beta-release.result }}" >> $GITHUB_OUTPUT
123+ else
124+ echo "type=Production" >> $GITHUB_OUTPUT
125+ echo "version=${{ needs.prod-release.outputs.version }}" >> $GITHUB_OUTPUT
126+ echo "result=${{ needs.prod-release.result }}" >> $GITHUB_OUTPUT
127+ fi
207128
208129 - name : Send Slack notification on success
209- if : success()
130+ if : steps.release_info.outputs.result == ' success'
210131 uses : slackapi/slack-github-action@v1
211132 with :
212133 payload : |
213134 {
214- "text": "✅ SUCCESSFUL: Production Release ${{ steps.get_version .outputs.version }}",
135+ "text": "✅ SUCCESSFUL: ${{ steps.release_info.outputs.type }} Release ${{ steps.release_info .outputs.version }}",
215136 "blocks": [
216137 {
217138 "type": "section",
218139 "text": {
219140 "type": "mrkdwn",
220- "text": "*Production Release Successful* ✅\n*Version:* ${{ steps.get_version .outputs.version }}\n*Repository:* ${{ github.repository }}\n*Branch:* ${{ github.ref_name }}\n*Commit:* <${{ github.event.head_commit.url }}|${{ github.sha }}>\n*Author:* ${{ github.event.head_commit.author.name }}\n*Message:* ${{ github.event.head_commit.message }}\n*Release:* <${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ steps.get_version.outputs.version }}|View Release> "
141+ "text": "*${{ steps.release_info.outputs.type }} Release Successful* ✅\n*Version:* ${{ steps.release_info .outputs.version }}\n*Repository:* ${{ github.repository }}\n*Branch:* ${{ github.ref_name }}\n*Commit:* <${{ github.event.head_commit.url }}|${{ github.sha }}>\n*Author:* ${{ github.event.head_commit.author.name }}\n*Message:* ${{ github.event.head_commit.message }}"
221142 }
222143 }
223144 ]
@@ -227,18 +148,18 @@ jobs:
227148 continue-on-error : true
228149
229150 - name : Send Slack notification on failure
230- if : failure()
151+ if : steps.release_info.outputs.result == ' failure'
231152 uses : slackapi/slack-github-action@v1
232153 with :
233154 payload : |
234155 {
235- "text": "❌ FAILED: Production Release",
156+ "text": "❌ FAILED: ${{ steps.release_info.outputs.type }} Release",
236157 "blocks": [
237158 {
238159 "type": "section",
239160 "text": {
240161 "type": "mrkdwn",
241- "text": "*Production Release Failed* ❌\n*Repository:* ${{ github.repository }}\n*Branch:* ${{ github.ref_name }}\n*Commit:* <${{ github.event.head_commit.url }}|${{ github.sha }}>\n*Author:* ${{ github.event.head_commit.author.name }}\n*Workflow Run:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Details>"
162+ "text": "*${{ steps.release_info.outputs.type }} Release Failed* ❌\n*Repository:* ${{ github.repository }}\n*Branch:* ${{ github.ref_name }}\n*Commit:* <${{ github.event.head_commit.url }}|${{ github.sha }}>\n*Author:* ${{ github.event.head_commit.author.name }}\n*Workflow Run:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Details>"
242163 }
243164 }
244165 ]
@@ -248,67 +169,22 @@ jobs:
248169 continue-on-error : true
249170
250171 - name : Send Slack notification on cancellation
251- if : cancelled()
172+ if : steps.release_info.outputs.result == ' cancelled'
252173 uses : slackapi/slack-github-action@v1
253174 with :
254175 payload : |
255176 {
256- "text": "⚠️ ABORTED: Production Release",
177+ "text": "⚠️ ABORTED: ${{ steps.release_info.outputs.type }} Release",
257178 "blocks": [
258179 {
259180 "type": "section",
260181 "text": {
261182 "type": "mrkdwn",
262- "text": "*Production Release Aborted* ⚠️\n*Repository:* ${{ github.repository }}\n*Branch:* ${{ github.ref_name }}\n*Commit:* <${{ github.event.head_commit.url }}|${{ github.sha }}>\n*Author:* ${{ github.event.head_commit.author.name }}"
183+ "text": "*${{ steps.release_info.outputs.type }} Release Aborted* ⚠️\n*Repository:* ${{ github.repository }}\n*Branch:* ${{ github.ref_name }}\n*Commit:* <${{ github.event.head_commit.url }}|${{ github.sha }}>\n*Author:* ${{ github.event.head_commit.author.name }}"
263184 }
264185 }
265186 ]
266187 }
267188 env :
268189 SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
269190 continue-on-error : true
270-
271- - name : Send email notification on success
272- if : success()
273- uses : dawidd6/action-send-mail@v3
274- with :
275- server_address : smtp.gmail.com
276- server_port : 587
277- username : ${{ secrets.EMAIL_USERNAME }}
278- password : ${{ secrets.EMAIL_PASSWORD }}
279- subject : " SUCCESSFUL: Production Release '${{ github.repository }}' [Build #${{ github.run_number }}]"
280- 281- from :
GitHub Actions <[email protected] > 282- body : |
283- SUCCESSFUL: Production Release '${{ github.repository }}' [Build #${{ github.run_number }}]
284-
285- Version: ${{ steps.get_version.outputs.version }}
286- Branch: ${{ github.ref_name }}
287- Commit: ${{ github.sha }}
288- Author: ${{ github.event.head_commit.author.name }}
289-
290- Check workflow run at: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
291- View Release at: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ steps.get_version.outputs.version }}
292- continue-on-error : true
293-
294- - name : Send email notification on failure
295- if : failure()
296- uses : dawidd6/action-send-mail@v3
297- with :
298- server_address : smtp.gmail.com
299- server_port : 587
300- username : ${{ secrets.EMAIL_USERNAME }}
301- password : ${{ secrets.EMAIL_PASSWORD }}
302- subject : " FAILED: Production Release '${{ github.repository }}' [Build #${{ github.run_number }}]"
303- 304- from :
GitHub Actions <[email protected] > 305- body : |
306- FAILED: Production Release '${{ github.repository }}' [Build #${{ github.run_number }}]
307-
308- Branch: ${{ github.ref_name }}
309- Commit: ${{ github.sha }}
310- Author: ${{ github.event.head_commit.author.name }}
311-
312- Check console output at: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
313- continue-on-error : true
314-
0 commit comments