-
Notifications
You must be signed in to change notification settings - Fork 0
250 lines (215 loc) · 9.57 KB
/
release.yml
File metadata and controls
250 lines (215 loc) · 9.57 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
# Release workflow: build and publish all packages on version tags
#
# Trigger: push a tag matching 'v*' (e.g., v0.0.3) to main
#
# Required setup:
# PyPI - Configure trusted publishing for each Python package at
# https://pypi.org/manage/project/<name>/settings/publishing/
# Set: Owner=scitrera, Repo=memorylayer, Workflow=release.yml, Environment=pypi
# npm - Create an automation token at https://www.npmjs.com/settings/<user>/tokens
# Add as repository secret: NPM_TOKEN
# Docker Hub - Create an access token at https://hub.docker.com/settings/security
# Add as repository secrets: DOCKERHUB_USERNAME, DOCKERHUB_TOKEN
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@v4
- 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
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
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
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
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Replace local SDK reference with registry version
working-directory: memorylayer-mcp-typescript
run: |
VERSION="${GITHUB_REF_NAME#v}"
sed -i 's|"file:../memorylayer-sdk-typescript"|"^'"${VERSION}"'"|' package.json
- 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 dependencies
working-directory: memorylayer-mcp-typescript
run: npm install
- 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
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
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Replace local MCP reference with registry version
working-directory: memorylayer-cc-plugin
run: |
VERSION="${GITHUB_REF_NAME#v}"
sed -i 's|"file:../memorylayer-mcp-typescript"|"^'"${VERSION}"'"|' package.json
- 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 dependencies
working-directory: memorylayer-cc-plugin
run: npm install
- 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
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# ──────────────────────────────────────────────────────────────────
# Docker image → Docker Hub (after memorylayer-server is on PyPI)
# ──────────────────────────────────────────────────────────────────
publish-docker:
name: "Docker: scitrera/memorylayer-server"
needs: publish-python
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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:
images: scitrera/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: 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