-
Notifications
You must be signed in to change notification settings - Fork 9
224 lines (196 loc) · 8.13 KB
/
release.yml
File metadata and controls
224 lines (196 loc) · 8.13 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
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Exact version (e.g. 0.6.0). Leave empty to auto-calculate from bump_type.'
required: false
type: string
bump_type:
description: 'Version bump type (used when version is empty)'
required: false
type: choice
default: patch
options:
- patch
- minor
- major
env:
DOCKER_REGISTRY: ghcr.io
IMAGE_NAME: ghcr.io/codealive-ai/codealive-mcp
permissions:
id-token: write # MCP Registry OIDC authentication
contents: write # Git tags and GitHub Releases
packages: write # Docker push to GHCR
jobs:
release:
name: Release
runs-on: ubuntu-latest
environment: release
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pytest pytest-asyncio pytest-mock pytest-cov jsonschema
- name: Run tests
run: |
python -m pytest src/tests/ -v
- name: Calculate version
id: version
run: |
# Derive current version from the latest git tag (single source of truth)
CURRENT=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1 | sed 's/^v//')
if [ -z "$CURRENT" ]; then
CURRENT="0.0.0"
echo "::warning::No existing version tags found, starting from 0.0.0"
fi
echo "current=$CURRENT" >> $GITHUB_OUTPUT
if [ -n "${{ inputs.version }}" ]; then
VERSION="${{ inputs.version }}"
else
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
case "${{ inputs.bump_type }}" in
major) VERSION="$((MAJOR + 1)).0.0" ;;
minor) VERSION="$MAJOR.$((MINOR + 1)).0" ;;
patch) VERSION="$MAJOR.$MINOR.$((PATCH + 1))" ;;
*) echo "::error::No version or bump_type provided"; exit 1 ;;
esac
fi
# Validate version format
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "::error::Invalid version format: $VERSION (expected X.Y.Z)"
exit 1
fi
# Check if tag already exists
if git tag -l "v$VERSION" | grep -q "v$VERSION"; then
echo "::error::Tag v$VERSION already exists. Delete it first or choose a different version."
exit 1
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "### Releasing $CURRENT → $VERSION" >> $GITHUB_STEP_SUMMARY
- name: Prepare server.json for publish
run: |
VERSION="${{ steps.version.outputs.version }}"
# Update server.json in working directory (not committed)
# pyproject.toml uses setuptools-scm — version comes from Docker build arg
python -c "
import json
with open('server.json', 'r') as f:
data = json.load(f)
version = '$VERSION'
data['version'] = version
if 'packages' in data:
for package in data['packages']:
registry_type = package.get('registryType')
if registry_type == 'oci':
# OCI packages: version goes in identifier tag, NOT as a field
package.pop('version', None)
identifier = package.get('identifier', '')
if ':' in identifier:
base = identifier.rsplit(':', 1)[0]
package['identifier'] = f'{base}:{version}'
else:
package['version'] = version
with open('server.json', 'w') as f:
json.dump(data, f, indent=2)
f.write('\n')
"
echo "Updated server.json to $VERSION (working dir only)"
- name: Validate server.json
run: |
python -c "
import json, sys, urllib.request
from jsonschema import ValidationError, validate
schema_url = 'https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json'
with urllib.request.urlopen(schema_url, timeout=30) as response:
schema = json.load(response)
with open('server.json', 'r') as f:
data = json.load(f)
validate(instance=data, schema=schema)
print('server.json validation passed')
"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Login to GitHub Container Registry
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
push: true
platforms: linux/amd64,linux/arm64
file: ./Dockerfile
build-args: VERSION=${{ steps.version.outputs.version }}
tags: |
${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
${{ env.IMAGE_NAME }}:v${{ steps.version.outputs.version }}
${{ env.IMAGE_NAME }}:latest
labels: |
io.modelcontextprotocol.server.name=io.github.CodeAlive-AI/codealive-mcp
cache-from: type=gha
cache-to: type=gha
# Git tag created AFTER Docker push succeeds — if Docker fails, no stale tag
- name: Create and push git tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}"
git push origin "v${{ steps.version.outputs.version }}"
- name: Install MCP Publisher CLI
run: |
curl -L "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" | tar xz mcp-publisher
chmod +x mcp-publisher
- name: Login to MCP Registry (GitHub OIDC)
run: ./mcp-publisher login github-oidc
- name: Publish to MCP Registry
run: ./mcp-publisher publish
- name: Create GitHub Release
uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe # v2.6.1
with:
tag_name: v${{ steps.version.outputs.version }}
name: CodeAlive MCP v${{ steps.version.outputs.version }}
body: |
## CodeAlive MCP Server v${{ steps.version.outputs.version }}
### Deployment Options
**Docker Container (Local)**
```bash
docker run --rm -i -e CODEALIVE_API_KEY=your-key ghcr.io/codealive-ai/codealive-mcp:v${{ steps.version.outputs.version }}
```
**MCP Registry**
```json
{
"name": "io.github.codealive-ai/codealive-mcp",
"transport": {
"type": "stdio",
"command": "docker",
"args": ["run", "--rm", "-i", "-e", "CODEALIVE_API_KEY=YOUR_API_KEY_HERE", "ghcr.io/codealive-ai/codealive-mcp:v${{ steps.version.outputs.version }}"]
}
}
```
**Remote HTTP (Zero Setup)**
```json
{
"transport": {
"type": "http",
"url": "https://mcp.codealive.ai/api"
},
"headers": {
"Authorization": "Bearer your-codealive-api-key"
}
}
```
draft: false
prerelease: false