-
Notifications
You must be signed in to change notification settings - Fork 1
325 lines (285 loc) · 12.8 KB
/
release.yml
File metadata and controls
325 lines (285 loc) · 12.8 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
# Release workflow: build and publish all packages on version tags
#
# Trigger: push a tag matching 'v*' (e.g., v0.0.3) to main
#
name: Release
on:
push:
tags:
- "v*"
# Cancel any in-progress release for a previous tag
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
# ──────────────────────────────────────────────────────────────────
# Python packages → PyPI (trusted publishing, no token needed)
# ──────────────────────────────────────────────────────────────────
publish-python:
name: "PyPI: ${{ matrix.package.name }}"
runs-on: ubuntu-latest
permissions:
id-token: write # OIDC for PyPI trusted publishing
strategy:
fail-fast: false
matrix:
package:
- { dir: memorylayer-sdk-python, name: memorylayer-client }
- { dir: memorylayer-core-python, name: memorylayer-server }
- { dir: memorylayer-sdk-langchain-python, name: memorylayer-langchain }
- { dir: memorylayer-sdk-llamaindex-python, name: memorylayer-llamaindex }
environment:
name: pypi
url: https://pypi.org/project/${{ matrix.package.name }}/
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build tools
run: pip install --upgrade build
- name: Build package
working-directory: ${{ matrix.package.dir }}
run: python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: ${{ matrix.package.dir }}/dist/
# ──────────────────────────────────────────────────────────────────
# TypeScript SDK → npm
# ──────────────────────────────────────────────────────────────────
publish-npm-sdk:
name: "npm: @scitrera/memorylayer-sdk"
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v4
with:
node-version: "24"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
working-directory: memorylayer-sdk-typescript
run: npm install
- name: Build
working-directory: memorylayer-sdk-typescript
run: npm run build
- name: Publish to npm
working-directory: memorylayer-sdk-typescript
run: npm publish --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# ──────────────────────────────────────────────────────────────────
# TypeScript MCP server → npm (after SDK is published)
# ──────────────────────────────────────────────────────────────────
publish-npm-mcp:
name: "npm: @scitrera/memorylayer-mcp-server"
needs: publish-npm-sdk
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v4
with:
node-version: "24"
registry-url: "https://registry.npmjs.org"
- name: Wait for SDK availability on npm
run: |
VERSION="${GITHUB_REF_NAME#v}"
for i in $(seq 1 30); do
if npm view "@scitrera/memorylayer-sdk@${VERSION}" version 2>/dev/null; then
echo "SDK v${VERSION} is available on npm"
exit 0
fi
echo "Waiting for @scitrera/memorylayer-sdk@${VERSION} (attempt ${i}/30)..."
sleep 10
done
echo "::error::SDK not available on npm after 5 minutes"
exit 1
- name: Install deps (swap local SDK file:dep for the registry version)
working-directory: memorylayer-mcp-typescript
# ``npm install pkg@version`` rewrites *both* package.json and
# package-lock.json so the local ``file:../memorylayer-sdk-typescript``
# dep is replaced cleanly with the registry version. Other transitive
# deps keep their existing locked versions — preserving the
# reproducibility benefit of the committed lockfile.
run: |
VERSION="${GITHUB_REF_NAME#v}"
npm install "@scitrera/memorylayer-sdk@^${VERSION}"
- name: Build
working-directory: memorylayer-mcp-typescript
run: npm run build
- name: Publish to npm
working-directory: memorylayer-mcp-typescript
run: npm publish --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# ──────────────────────────────────────────────────────────────────
# Claude Code plugin → npm (after MCP server is published)
# ──────────────────────────────────────────────────────────────────
publish-npm-cc-plugin:
name: "npm: @scitrera/memorylayer-cc-plugin"
needs: publish-npm-mcp
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v4
with:
node-version: "24"
registry-url: "https://registry.npmjs.org"
- name: Wait for MCP server availability on npm
run: |
VERSION="${GITHUB_REF_NAME#v}"
for i in $(seq 1 30); do
if npm view "@scitrera/memorylayer-mcp-server@${VERSION}" version 2>/dev/null; then
echo "MCP server v${VERSION} is available on npm"
exit 0
fi
echo "Waiting for @scitrera/memorylayer-mcp-server@${VERSION} (attempt ${i}/30)..."
sleep 10
done
echo "::error::MCP server not available on npm after 5 minutes"
exit 1
- name: Install deps (swap local MCP file:dep for the registry version)
working-directory: memorylayer-cc-plugin
# See ``publish-npm-mcp`` for the rationale — ``npm install pkg@version``
# patches both package.json and the lockfile surgically.
run: |
VERSION="${GITHUB_REF_NAME#v}"
npm install "@scitrera/memorylayer-mcp-server@^${VERSION}"
- name: Build
working-directory: memorylayer-cc-plugin
run: npm run build
- name: Publish to npm
working-directory: memorylayer-cc-plugin
run: npm publish --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# ──────────────────────────────────────────────────────────────────
# OpenCode plugin → npm (after MCP server is published)
# ──────────────────────────────────────────────────────────────────
publish-npm-opencode-plugin:
name: "npm: @scitrera/memorylayer-opencode-plugin"
needs: publish-npm-mcp
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v4
with:
node-version: "24"
registry-url: "https://registry.npmjs.org"
- name: Wait for MCP server availability on npm
run: |
VERSION="${GITHUB_REF_NAME#v}"
for i in $(seq 1 30); do
if npm view "@scitrera/memorylayer-mcp-server@${VERSION}" version 2>/dev/null; then
echo "MCP server v${VERSION} is available on npm"
exit 0
fi
echo "Waiting for @scitrera/memorylayer-mcp-server@${VERSION} (attempt ${i}/30)..."
sleep 10
done
echo "::error::MCP server not available on npm after 5 minutes"
exit 1
- name: Install deps (swap local MCP file:dep for the registry version)
working-directory: memorylayer-opencode-plugin
# See ``publish-npm-mcp`` for the rationale — ``npm install pkg@version``
# patches both package.json and the lockfile surgically.
run: |
VERSION="${GITHUB_REF_NAME#v}"
npm install "@scitrera/memorylayer-mcp-server@^${VERSION}"
- name: Build
working-directory: memorylayer-opencode-plugin
run: npm run build
- name: Publish to npm
working-directory: memorylayer-opencode-plugin
# First-publish exception: npm Trusted Publisher config is
# per-package and only applies to packages that already exist on
# the registry. ``@scitrera/memorylayer-opencode-plugin`` has
# never been published, so trusted publishing can't authorize
# the very first PUT — it has to use a classic token. AFTER
# the first successful publish, configure trusted publisher on
# npmjs.com → Package Settings → Trusted Publisher (repo
# ``scitrera/memorylayer``, workflow ``release.yml``), then
# DELETE the ``env:`` block below to switch this job to pure
# OIDC auth like the other three.
run: npm publish --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# ──────────────────────────────────────────────────────────────────
# Docker image → Docker Hub + GHCR (after memorylayer-server is on PyPI)
# ──────────────────────────────────────────────────────────────────
publish-docker:
name: "Docker: scitrera/memorylayer-server"
needs: publish-python
runs-on: ubuntu-latest
permissions:
contents: read
packages: write # required to push to ghcr.io
steps:
- uses: actions/checkout@v6
- name: Wait for memorylayer-server on PyPI
run: |
VERSION="${GITHUB_REF_NAME#v}"
for i in $(seq 1 30); do
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
"https://pypi.org/pypi/memorylayer-server/${VERSION}/json")
if [ "${STATUS}" = "200" ]; then
echo "memorylayer-server ${VERSION} is available on PyPI"
exit 0
fi
echo "Waiting for memorylayer-server ${VERSION} on PyPI (attempt ${i}/30)..."
sleep 10
done
echo "::error::memorylayer-server not available on PyPI after 5 minutes"
exit 1
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
# Push the same tags to both Docker Hub and GHCR. The action
# emits one tag entry per (image, tag) combination so a single
# build-push step covers both registries.
images: |
scitrera/memorylayer-server
ghcr.io/${{ github.repository_owner }}/memorylayer-server
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max