-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (155 loc) · 6.38 KB
/
release.yaml
File metadata and controls
177 lines (155 loc) · 6.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: Release Pipeline
on:
push:
branches:
- master
- latest
jobs:
beta-release:
name: Beta Release
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
outputs:
version: ${{ steps.get_version.outputs.version }}
status: ${{ job.status }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install --quiet build twine toml
- name: Modify package name for beta
run: |
sed -i -E 's/^(name *= *")superstream-clients(")/\1superstream-clients-beta\2/' pyproject.toml
- name: Build package
run: python -m build
- name: Publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload dist/*
- name: Get version
if: always()
id: get_version
run: |
VERSION=$(python3 -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
echo "version=$VERSION" >> $GITHUB_OUTPUT
prod-release:
name: Production Release
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/latest'
outputs:
version: ${{ steps.get_version.outputs.version }}
status: ${{ job.status }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install --quiet build twine toml
- name: Build package
run: python -m build
- name: Publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload dist/*
- name: Get version from pyproject.toml
if: always()
id: get_version
run: |
VERSION=$(python3 -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Create Git tag
run: |
git config user.email "github-actions@superstream.ai"
git config user.name "GitHub Actions"
git tag -a ${{ steps.get_version.outputs.version }} -m "${{ steps.get_version.outputs.version }}"
git push origin ${{ steps.get_version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.get_version.outputs.version }}
files: dist/superstream_clients-${{ steps.get_version.outputs.version }}.tar.gz
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
notify:
name: Send Notifications
runs-on: ubuntu-latest
needs: prod-release
if: always() && github.ref == 'refs/heads/latest'
steps:
- name: Send Slack notification on success
if: needs.prod-release.result == 'success'
uses: slackapi/slack-github-action@v1
with:
payload: |
{
"text": "superstream-python-clients v${{ needs.prod-release.outputs.version }} Production Release SUCCESSFUL ✅",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*superstream-python-clients v${{ needs.prod-release.outputs.version }} Production Release SUCCESSFUL* ✅\n*Branch:* ${{ github.ref_name }}\n*Commit:* <${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>\n*Author:* ${{ github.event.head_commit.author.name }}\n*Release:* <${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ needs.prod-release.outputs.version }}|View Release>"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
continue-on-error: true
- name: Send Slack notification on failure
if: needs.prod-release.result == 'failure'
uses: slackapi/slack-github-action@v1
with:
payload: |
{
"text": "superstream-python-clients v${{ needs.prod-release.outputs.version }} Production Release FAILED ❌",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*superstream-python-clients v${{ needs.prod-release.outputs.version }} Production Release FAILED* ❌\n*Branch:* ${{ github.ref_name }}\n*Commit:* <${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ 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>"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
continue-on-error: true
- name: Send Slack notification on cancellation
if: needs.prod-release.result == 'cancelled'
uses: slackapi/slack-github-action@v1
with:
payload: |
{
"text": "superstream-python-clients v${{ needs.prod-release.outputs.version }} Production Release ABORTED ⚠️",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*superstream-python-clients v${{ needs.prod-release.outputs.version }} Production Release ABORTED* ⚠️\n*Branch:* ${{ github.ref_name }}\n*Commit:* <${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>\n*Author:* ${{ github.event.head_commit.author.name }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
continue-on-error: true