-
-
Notifications
You must be signed in to change notification settings - Fork 2
323 lines (289 loc) · 9.9 KB
/
release.yml
File metadata and controls
323 lines (289 loc) · 9.9 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
name: Release
on:
push:
branches:
- main
workflow_dispatch:
inputs:
force_publish_client:
description: 'Force publish client to PyPI (even without new release)'
type: boolean
default: false
force_publish_mcp:
description: 'Force publish MCP to PyPI (even without new release)'
type: boolean
default: false
permissions: {}
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
python-version: "3.14"
- name: Install dependencies
run: uv sync --all-extras
- name: Run full CI pipeline
run: uv run poe ci
env:
CI_DOCS_BUILD: "true"
NO_MKDOCS_2_WARNING: "true"
DISABLE_MKDOCS_2_WARNING: "true"
release-client:
needs: test
runs-on: ubuntu-latest
concurrency:
group: release-client
cancel-in-progress: false
permissions:
id-token: write
contents: write
outputs:
released: ${{ steps.release.outputs.released }}
version: ${{ steps.release.outputs.version }}
tag: ${{ steps.release.outputs.tag }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
python-version: "3.14"
- name: Install dependencies
run: uv sync --all-extras
- name: Check for client changes
id: check
run: |
# Check if there are any commits with (client) scope or no scope since last
# client release. The optional ``!`` between ``(scope)`` and ``:`` matches
# the Conventional Commits breaking-change form (e.g. ``feat(client)!:``)
# so a major-version bump isn't silently skipped — see #451.
if git log $(git describe --tags --abbrev=0 --match="client-v*" 2>/dev/null || \
echo "HEAD~10")..HEAD --pretty=format:"%s" | \
grep -qE '^(feat|fix|perf)(\(client\))?!?:'; then
echo "has_changes=true" >> $GITHUB_OUTPUT
else
echo "has_changes=false" >> $GITHUB_OUTPUT
fi
- name: Python Semantic Release (Client)
if: steps.check.outputs.has_changes == 'true'
id: release
uses: python-semantic-release/python-semantic-release@v10.5.3
with:
github_token: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
verbosity: 2
- name: Build client package
if: >-
(steps.release.outcome == 'success' &&
steps.release.outputs.released == 'true') ||
inputs.force_publish_client == true
run: uv build
- name: Upload client build artifacts
if: >-
(steps.release.outcome == 'success' &&
steps.release.outputs.released == 'true') ||
inputs.force_publish_client == true
uses: actions/upload-artifact@v7
with:
name: client-dist
path: dist/
release-mcp:
needs: test
runs-on: ubuntu-latest
concurrency:
group: release-mcp
cancel-in-progress: false
permissions:
id-token: write
contents: write
outputs:
released: ${{ steps.release.outputs.released }}
version: ${{ steps.release.outputs.version }}
tag: ${{ steps.release.outputs.tag }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
python-version: "3.14"
- name: Install dependencies
run: uv sync --all-extras
- name: Check for MCP changes
id: check
run: |
# Check if there are any commits with (mcp) scope since last mcp release.
# The optional ``!`` between ``(mcp)`` and ``:`` matches the Conventional
# Commits breaking-change form (e.g. ``feat(mcp)!:``) so a major-version
# bump isn't silently skipped — see #451.
if git log $(git describe --tags --abbrev=0 --match="mcp-v*" 2>/dev/null || \
echo "HEAD~10")..HEAD --pretty=format:"%s" | \
grep -qE '^(feat|fix|perf)\(mcp\)!?:'; then
echo "has_changes=true" >> $GITHUB_OUTPUT
else
echo "has_changes=false" >> $GITHUB_OUTPUT
fi
- name: Python Semantic Release (MCP)
if: steps.check.outputs.has_changes == 'true'
id: release
uses: python-semantic-release/python-semantic-release@v10.5.3
with:
github_token: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
verbosity: 2
directory: katana_mcp_server
- name: Build MCP package
if: >-
(steps.release.outcome == 'success' &&
steps.release.outputs.released == 'true') ||
inputs.force_publish_mcp == true
run: cd katana_mcp_server && uv build
- name: Upload MCP build artifacts
if: >-
(steps.release.outcome == 'success' &&
steps.release.outputs.released == 'true') ||
inputs.force_publish_mcp == true
uses: actions/upload-artifact@v7
with:
name: mcp-dist
path: dist/
publish-client-pypi:
name: Publish Client to PyPI
needs: release-client
if: needs.release-client.outputs.released == 'true' || inputs.force_publish_client == true
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Download client build artifacts
uses: actions/download-artifact@v8
with:
name: client-dist
path: dist/
- name: Publish client to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: true
publish-mcp-pypi:
name: Publish MCP to PyPI
needs: release-mcp
if: needs.release-mcp.outputs.released == 'true' || inputs.force_publish_mcp == true
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Download MCP build artifacts
uses: actions/download-artifact@v8
with:
name: mcp-dist
path: dist/
- name: Publish MCP to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: true
sync-lockfile:
name: Sync uv.lock after releases
needs: [release-client, release-mcp]
if: |
always() &&
(needs.release-client.outputs.released == 'true' ||
needs.release-mcp.outputs.released == 'true')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
python-version: "3.14"
- name: Sync lockfile
run: uv sync --all-extras
- name: Commit if changed
run: |
if git diff --quiet uv.lock; then
echo "uv.lock is up to date"
else
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add uv.lock
git commit -m "chore: sync uv.lock after release"
git push origin main
fi
publish-mcp-docker:
name: Publish MCP Docker Image
needs: [publish-client-pypi, publish-mcp-pypi, release-client, release-mcp]
if: |
always() &&
(needs.release-client.outputs.released == 'true' ||
needs.release-mcp.outputs.released == 'true' ||
inputs.force_publish_mcp == true)
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Determine MCP version for tagging
id: version
run: |
if [ -n "${{ needs.release-mcp.outputs.version }}" ]; then
echo "mcp_version=${{ needs.release-mcp.outputs.version }}" >> $GITHUB_OUTPUT
else
# No MCP release this run — use the latest mcp-v* tag
LATEST_TAG=$(git tag --list 'mcp-v*' --sort=-version:refname | head -n 1)
echo "mcp_version=${LATEST_TAG#mcp-v}" >> $GITHUB_OUTPUT
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ghcr.io/${{ github.repository_owner }}/katana-mcp-server
tags: |
type=semver,pattern={{version}},value=${{ steps.version.outputs.mcp_version }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.version.outputs.mcp_version }}
type=semver,pattern={{major}},value=${{ steps.version.outputs.mcp_version }}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v7
with:
context: ./katana_mcp_server
file: ./katana_mcp_server/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64