-
-
Notifications
You must be signed in to change notification settings - Fork 51
296 lines (250 loc) · 7.5 KB
/
release.yml
File metadata and controls
296 lines (250 loc) · 7.5 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
name: Release
on:
push:
tags:
- 'v*.*.*'
env:
PYTHON_VERSION: "3.12"
jobs:
# Run full test suite before release
test:
name: Pre-Release Tests
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-release-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-release-
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
pip install pytest-cov
- name: Run all tests
run: |
pytest tests/ -v \
-m "not slow" \
--cov=src/polymarket_mcp \
--cov-report=xml \
--cov-fail-under=80
env:
POLYGON_PRIVATE_KEY: "0000000000000000000000000000000000000000000000000000000000000001"
POLYGON_ADDRESS: "0x0000000000000000000000000000000000000001"
- name: Lint check
run: |
pip install ruff black
ruff check src/
black --check src/
# Build Python package
build:
name: Build Package
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: |
python -m build
- name: Check package
run: |
twine check dist/*
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
# Build and push Docker image
docker:
name: Build & Push Docker Image
runs-on: ubuntu-latest
needs: test
if: hashFiles('Dockerfile') != ''
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
if: secrets.DOCKER_USERNAME != '' && secrets.DOCKER_PASSWORD != ''
- name: Extract version from tag
id: version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ secrets.DOCKER_USERNAME != '' && secrets.DOCKER_PASSWORD != '' }}
tags: |
${{ secrets.DOCKER_USERNAME }}/polymarket-mcp:latest
${{ secrets.DOCKER_USERNAME }}/polymarket-mcp:${{ steps.version.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
if: secrets.DOCKER_USERNAME != '' && secrets.DOCKER_PASSWORD != ''
# Generate changelog
changelog:
name: Generate Changelog
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
id: changelog
run: |
# Get previous tag
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
echo "First release - generating full changelog"
COMMITS=$(git log --pretty=format:"- %s (%h)" --no-merges)
else
echo "Generating changelog since $PREV_TAG"
COMMITS=$(git log $PREV_TAG..HEAD --pretty=format:"- %s (%h)" --no-merges)
fi
# Save to file
cat > RELEASE_NOTES.md << EOF
## Changes
$COMMITS
## Installation
\`\`\`bash
pip install polymarket-mcp
\`\`\`
Or use the MCP installer:
\`\`\`bash
# Install in Claude Desktop
uvx mcp install polymarket-mcp
\`\`\`
## Docker
\`\`\`bash
docker pull polymarket-mcp:${GITHUB_REF#refs/tags/v}
\`\`\`
## What's New
See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) for detailed changes.
EOF
echo "Generated release notes"
cat RELEASE_NOTES.md
- name: Upload release notes
uses: actions/upload-artifact@v4
with:
name: release-notes
path: RELEASE_NOTES.md
# Create GitHub Release
release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [test, build, changelog]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Download release notes
uses: actions/download-artifact@v4
with:
name: release-notes
- name: Create Release
uses: softprops/action-gh-release@v1
with:
body_path: RELEASE_NOTES.md
files: |
dist/*
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Publish to PyPI
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [test, build]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
environment:
name: pypi
url: https://pypi.org/project/polymarket-mcp/
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: secrets.PYPI_API_TOKEN != ''
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true
# Update documentation
docs:
name: Update Documentation
runs-on: ubuntu-latest
needs: release
steps:
- uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update version badge in README
run: |
VERSION=${GITHUB_REF#refs/tags/v}
sed -i "s/version-[0-9.]*-blue/version-$VERSION-blue/g" README.md
if git diff --quiet; then
echo "No changes to README"
else
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add README.md
git commit -m "Update version badge to $VERSION [skip ci]"
git push
fi
# Notify on completion
notify:
name: Release Notification
runs-on: ubuntu-latest
needs: [release, publish]
if: always()
steps:
- name: Release Status
run: |
echo "Release Status:"
echo "==============="
echo "Tests: ${{ needs.test.result }}"
echo "Build: ${{ needs.build.result }}"
echo "Release: ${{ needs.release.result }}"
echo "Publish: ${{ needs.publish.result }}"
echo ""
if [ "${{ needs.release.result }}" == "success" ]; then
echo "✅ Release ${{ github.ref_name }} completed successfully!"
echo "📦 Package: https://pypi.org/project/polymarket-mcp/"
echo "📋 Release: https://github.com/${{ github.repository }}/releases/tag/${{ github.ref_name }}"
else
echo "❌ Release failed - check logs above"
exit 1
fi