Skip to content

Commit ff2d02f

Browse files
Merge pull request #14 from superstreamlabs/github-actions
GitHub actions
2 parents ac811e5 + 9cabdaf commit ff2d02f

File tree

1 file changed

+97
-1
lines changed

1 file changed

+97
-1
lines changed

.github/workflows/release.yaml

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ jobs:
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
@@ -23,7 +26,7 @@ jobs:
2326

2427
- name: Install dependencies
2528
run: |
26-
pip install --quiet build twine
29+
pip install --quiet build twine toml
2730
2831
- name: Modify package name for beta
2932
run: |
@@ -38,11 +41,21 @@ jobs:
3841
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
3942
run: |
4043
twine upload dist/*
44+
45+
- name: Get version
46+
if: always()
47+
id: get_version
48+
run: |
49+
VERSION=$(python3 -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
50+
echo "version=$VERSION" >> $GITHUB_OUTPUT
4151
4252
prod-release:
4353
name: Production Release
4454
runs-on: ubuntu-latest
4555
if: github.ref == 'refs/heads/latest'
56+
outputs:
57+
version: ${{ steps.get_version.outputs.version }}
58+
status: ${{ job.status }}
4659

4760
steps:
4861
- name: Checkout code
@@ -68,6 +81,7 @@ jobs:
6881
twine upload dist/*
6982
7083
- name: Get version from pyproject.toml
84+
if: always()
7185
id: get_version
7286
run: |
7387
VERSION=$(python3 -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
@@ -91,4 +105,86 @@ jobs:
91105
generate_release_notes: true
92106
env:
93107
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
94128
129+
- name: Send Slack notification on success
130+
if: steps.release_info.outputs.result == 'success'
131+
uses: slackapi/slack-github-action@v1
132+
with:
133+
payload: |
134+
{
135+
"text": "✅ SUCCESSFUL: ${{ steps.release_info.outputs.type }} Release ${{ steps.release_info.outputs.version }}",
136+
"blocks": [
137+
{
138+
"type": "section",
139+
"text": {
140+
"type": "mrkdwn",
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 }}"
142+
}
143+
}
144+
]
145+
}
146+
env:
147+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
148+
continue-on-error: true
149+
150+
- name: Send Slack notification on failure
151+
if: steps.release_info.outputs.result == 'failure'
152+
uses: slackapi/slack-github-action@v1
153+
with:
154+
payload: |
155+
{
156+
"text": "❌ FAILED: ${{ steps.release_info.outputs.type }} Release",
157+
"blocks": [
158+
{
159+
"type": "section",
160+
"text": {
161+
"type": "mrkdwn",
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>"
163+
}
164+
}
165+
]
166+
}
167+
env:
168+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
169+
continue-on-error: true
170+
171+
- name: Send Slack notification on cancellation
172+
if: steps.release_info.outputs.result == 'cancelled'
173+
uses: slackapi/slack-github-action@v1
174+
with:
175+
payload: |
176+
{
177+
"text": "⚠️ ABORTED: ${{ steps.release_info.outputs.type }} Release",
178+
"blocks": [
179+
{
180+
"type": "section",
181+
"text": {
182+
"type": "mrkdwn",
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 }}"
184+
}
185+
}
186+
]
187+
}
188+
env:
189+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
190+
continue-on-error: true

0 commit comments

Comments
 (0)