-
Notifications
You must be signed in to change notification settings - Fork 0
343 lines (287 loc) · 10.6 KB
/
release.yml
File metadata and controls
343 lines (287 loc) · 10.6 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
name: Release CI (Legacy)
on:
push:
tags:
# Legacy tags only - must start with v followed by version number
- 'v[0-9].*'
- '!async-cassandra-v*'
- '!async-cassandra-bulk-v*'
jobs:
full-ci:
uses: ./.github/workflows/ci-monorepo.yml
with:
package: async-cassandra
run-integration-tests: true
run-full-suite: true
build-package:
needs: full-ci
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: |
cd libs/async-cassandra
python -m build
- name: Check package
run: |
cd libs/async-cassandra
twine check dist/*
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: libs/async-cassandra/dist/
retention-days: 7
publish-testpypi:
name: Publish to TestPyPI
needs: [full-ci, build-package]
runs-on: ubuntu-latest
# Only publish for proper pre-release versions (PEP 440)
if: contains(github.ref_name, 'rc') || contains(github.ref_name, 'a') || contains(github.ref_name, 'b')
permissions:
id-token: write # Required for trusted publishing
steps:
- uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: List distribution files
run: |
echo "Distribution files to be published:"
ls -la dist/
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
verbose: true
- name: Create TestPyPI Summary
run: |
echo "## 📦 Published to TestPyPI" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Version: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Install with:" >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
echo "pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple async-cassandra" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "View on TestPyPI: https://test.pypi.org/project/async-cassandra/" >> $GITHUB_STEP_SUMMARY
validate-testpypi:
name: Validate TestPyPI Package
needs: publish-testpypi
runs-on: ubuntu-latest
# Only validate for pre-release versions that were published to TestPyPI
if: contains(github.ref_name, 'rc') || contains(github.ref_name, 'a') || contains(github.ref_name, 'b')
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Wait for package availability
run: |
echo "Waiting for package to be available on TestPyPI..."
sleep 30
- name: Install from TestPyPI
run: |
# Strip 'v' prefix from tag
VERSION=${GITHUB_REF_NAME#v}
echo "Installing version: $VERSION"
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple async-cassandra==$VERSION
- name: Test imports
run: |
cat > test_imports.py << 'EOF'
import async_cassandra
print(f'✅ Package version: {async_cassandra.__version__}')
# Test core imports
from async_cassandra import (
AsyncCluster,
AsyncCassandraSession,
AsyncResultSet,
AsyncRetryPolicy,
AsyncStreamingResultSet,
StreamConfig,
create_streaming_statement,
)
print('✅ Core async classes imported')
# Test exception imports
from async_cassandra import (
AsyncCassandraError,
ConnectionError,
QueryError,
)
print('✅ Exception classes imported')
# Test monitoring imports
from async_cassandra import (
ConnectionMonitor,
RateLimitedSession,
create_monitored_session,
HOST_STATUS_UP,
HOST_STATUS_DOWN,
HOST_STATUS_UNKNOWN,
HostMetrics,
ClusterMetrics,
)
print('✅ Monitoring classes imported')
# Test metrics imports
from async_cassandra import (
MetricsMiddleware,
MetricsCollector,
InMemoryMetricsCollector,
PrometheusMetricsCollector,
QueryMetrics,
ConnectionMetrics,
create_metrics_system,
)
print('✅ Metrics classes imported')
print('')
print('🎉 All imports successful!')
EOF
python test_imports.py
- name: Create validation summary
run: |
echo "## ✅ TestPyPI Validation Passed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Package successfully installed and imported from TestPyPI" >> $GITHUB_STEP_SUMMARY
release-info:
needs: [full-ci]
runs-on: ubuntu-latest
if: always()
steps:
- name: Get tag info
run: |
echo "## Release Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Tag: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [[ "${{ github.ref_name }}" =~ -rc ]] || [[ "${{ github.ref_name }}" =~ -beta ]] || [[ "${{ github.ref_name }}" =~ -alpha ]]; then
echo "✅ Pre-release published to TestPyPI" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Next steps:" >> $GITHUB_STEP_SUMMARY
echo "1. Test the package from TestPyPI" >> $GITHUB_STEP_SUMMARY
echo "2. If everything works, create a release tag without suffix" >> $GITHUB_STEP_SUMMARY
else
echo "This is a release tag. Ready for PyPI publishing." >> $GITHUB_STEP_SUMMARY
fi
create-github-release:
name: Create GitHub Release
needs: [full-ci]
runs-on: ubuntu-latest
if: success()
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for release notes
- name: Check if pre-release
id: check-prerelease
run: |
if [[ "${{ github.ref_name }}" =~ rc|a|b ]]; then
echo "prerelease=true" >> $GITHUB_OUTPUT
echo "Pre-release detected"
else
echo "prerelease=false" >> $GITHUB_OUTPUT
echo "Stable release detected"
fi
- name: Generate Release Notes
id: release-notes
run: |
VERSION="${{ github.ref_name }}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
# Create release notes based on type
if [[ "$VERSION" =~ rc|a|b ]]; then
cat > release-notes.md << 'EOF'
## Pre-release for Testing
⚠️ **This is a pre-release version available on TestPyPI**
### Installation
```bash
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple async-cassandra==${{ github.ref_name }}
```
### Testing Instructions
Please test:
- Package installation
- Basic imports: `from async_cassandra import AsyncCluster`
- FastAPI integration if applicable
- Report any issues on GitHub
### What's Changed
EOF
else
cat > release-notes.md << 'EOF'
## Stable Release
### Installation
```bash
pip install async-cassandra
```
### What's Changed
EOF
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
name: ${{ github.ref_name }}
tag_name: ${{ github.ref }}
prerelease: ${{ steps.check-prerelease.outputs.prerelease }}
generate_release_notes: true
body_path: release-notes.md
draft: false
debug-condition:
name: Debug Release Condition
runs-on: ubuntu-latest
steps:
- name: Debug info
run: |
echo "github.ref = ${{ github.ref }}"
echo "github.ref_name = ${{ github.ref_name }}"
echo "ref contains 'a': ${{ contains(github.ref, 'a') }}"
echo "ref_name contains 'a': ${{ contains(github.ref_name, 'a') }}"
echo "ref_name contains '-': ${{ contains(github.ref_name, '-') }}"
echo "Should publish to PyPI (new logic): ${{ !contains(github.ref_name, '-') }}"
publish-pypi:
name: Publish to PyPI
needs: [full-ci, build-package]
runs-on: ubuntu-latest
# Only publish stable versions (no pre-release suffix)
# Match only versions like v0.0.1, v1.2.3, etc (no suffix)
if: "!contains(github.ref_name, 'rc') && !contains(github.ref_name, 'a') && !contains(github.ref_name, 'b') && !contains(github.ref_name, 'dev')"
permissions:
id-token: write # Required for trusted publishing
steps:
- uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: List distribution files
run: |
echo "Distribution files to be published to PyPI:"
ls -la dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
print-hash: true
- name: Create PyPI Summary
run: |
echo "## 🚀 Published to PyPI" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Version: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Install with:" >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
echo "pip install async-cassandra" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "View on PyPI: https://pypi.org/project/async-cassandra/" >> $GITHUB_STEP_SUMMARY