-
Notifications
You must be signed in to change notification settings - Fork 204
377 lines (321 loc) · 11.1 KB
/
release.yml
File metadata and controls
377 lines (321 loc) · 11.1 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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
name: Release
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
id-token: write
contents: write
jobs:
is_release:
name: Is release?
runs-on: ubuntu-latest
outputs:
release: ${{ steps.version.outputs.release }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v3
id: pnpm-install
with:
version: 9.5
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: "22.x"
registry-url: "https://registry.npmjs.org"
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- name: Configure pnpm
run: |
pnpm config set auto-install-peers true
pnpm config set exclude-links-from-lockfile true
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Check if new version
id: version
run: |
IS_RELEASE=$(./.github/scripts/is_release.sh)
echo "release=$IS_RELEASE" >> "$GITHUB_OUTPUT"
changes:
name: Repository changes
needs: [is_release]
if: needs.is_release.outputs.release == 'true'
runs-on: ubuntu-latest
outputs:
js: ${{ steps.js.outputs.release }}
python: ${{ steps.python.outputs.release }}
charts: ${{ steps.charts.outputs.release }}
template: ${{ steps.template.outputs.release }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v3
id: pnpm-install
with:
version: 9.5
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: "22.x"
registry-url: "https://registry.npmjs.org"
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- name: Configure pnpm
run: |
pnpm config set auto-install-peers true
pnpm config set exclude-links-from-lockfile true
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Check JavasScript SDK Release
id: js
run: |
IS_RELEASE=$(./.github/scripts/is_release_for_package.sh "@e2b/code-interpreter")
echo "release=$IS_RELEASE" >> "$GITHUB_OUTPUT"
- name: Check Python SDK Release
id: python
run: |
IS_RELEASE=$(./.github/scripts/is_release_for_package.sh "@e2b/code-interpreter-python")
echo "release=$IS_RELEASE" >> "$GITHUB_OUTPUT"
- name: Check Charts SDK Release
id: charts
run: |
IS_RELEASE=$(./.github/scripts/is_release_for_package.sh "@e2b/data-extractor")
echo "release=$IS_RELEASE" >> "$GITHUB_OUTPUT"
- name: Check Template SDK Release
id: template
run: |
IS_RELEASE=$(./.github/scripts/is_release_for_package.sh "@e2b/code-interpreter-template")
echo "release=$IS_RELEASE" >> "$GITHUB_OUTPUT"
charts-release:
name: Charts release
if: needs.changes.outputs.charts == 'true'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.output_version.outputs.version }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v3
id: pnpm-install
with:
version: 9.5
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Configure pnpm
run: |
pnpm config set auto-install-peers true
pnpm config set exclude-links-from-lockfile true
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Create new versions
run: pnpm run version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release new versions
run: |
poetry build
poetry config pypi-token.pypi ${PYPI_TOKEN}
poetry publish --skip-existing
working-directory: ./chart_data_extractor
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PYPI_TOKEN: ${{ secrets.CHARTS_PYPI_TOKEN }}
- name: Output new version
id: output_version
working-directory: ./chart_data_extractor
run: |
echo "::set-output name=version::$(pnpm pkg get version --workspaces=false | tr -d \\\")"
build-docker-image:
name: Build Docker Image
runs-on: ubuntu-latest
needs: [changes, charts-release]
if: always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
(needs.changes.outputs.template == 'true' || needs.changes.outputs.charts == 'true')
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set package version
working-directory: ./template
run: |
if [ -z "${{ needs.charts-release.outputs.version }}" ]; then
VERSION=$(cat ../chart_data_extractor/pyproject.toml | grep version | cut -d '"' -f 2)
else
VERSION=${{ needs.charts-release.outputs.version }}
fi
echo "Version: $VERSION"
sed -i "s/e2b_charts/e2b_charts==${VERSION}/g" requirements.txt
- uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: Install development dependencies
working-directory: ./template
run: pip install -r requirements-dev.txt
- name: Build and push to DockerHub
working-directory: ./template
run: |
python build_docker.py | docker buildx build \
--platform linux/amd64 \
--push \
--tag ${{ secrets.DOCKERHUB_USERNAME }}/code-interpreter:latest -f - .
build-template:
name: Build E2B template
runs-on: ubuntu-latest
needs: [build-docker-image]
if: always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
(needs.changes.outputs.template == 'true' || needs.changes.outputs.charts == 'true')
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: Install development dependencies
working-directory: ./template
run: pip install -r requirements-dev.txt
- name: Build E2B template
id: build-template
working-directory: ./template
run: |
python build_prod.py
env:
E2B_API_KEY: ${{ secrets.E2B_PROD_API_KEY }}
E2B_DOMAIN: ${{ vars.E2B_DOMAIN }}
python-tests:
name: Python Tests
needs: [changes, build-template]
if: always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.changes.outputs.template == 'true'
uses: ./.github/workflows/python_tests.yml
secrets: inherit
js-tests:
name: JS Tests
needs: [changes, build-template]
if: always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.changes.outputs.template == 'true'
uses: ./.github/workflows/js_tests.yml
secrets: inherit
release:
needs: [python-tests, js-tests]
if: always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
(needs.changes.outputs.js == 'true' || needs.changes.outputs.python == 'true' || needs.changes.outputs.charts == 'true' || needs.changes.outputs.template == 'true')
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.VERSION_BUMPER_APPID }}
private-key: ${{ secrets.VERSION_BUMPER_SECRET }}
- name: Checkout Repo
uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.8.1
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- uses: pnpm/action-setup@v3
with:
version: 9.5
- name: Setup Node.js 22
uses: actions/setup-node@v6
with:
node-version: "22.x"
registry-url: 'https://registry.npmjs.org'
cache: pnpm
- name: Configure pnpm
run: |
pnpm config set auto-install-peers true
pnpm config set exclude-links-from-lockfile true
- name: Update npm
run: |
npm install -g npm@^11.6
npm --version
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Create new versions
run: pnpm run version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate SDK reference
id: sdk-ref
run: pnpm run --recursive generate-ref
- name: Show docs file structure
run: |
if [ -d "./sdk-reference" ]; then
tree ./sdk-reference
else
echo "sdk-reference directory does not exist"
fi
- name: Release new versions
uses: changesets/action@v1
with:
publish: pnpm run publish
createGithubReleases: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: "" # See https://github.com/changesets/changesets/issues/1152#issuecomment-3190884868
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
- name: Update lock file
run: pnpm i --no-link --no-frozen-lockfile
- name: Commit new versions
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add ./sdk-reference
git commit -am "[skip ci] Release new versions" || exit 0
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
report-failure:
needs: [python-tests, js-tests, release]
if: failure()
name: Code Interpreter Release Failed - Slack Notification
runs-on: ubuntu-latest
steps:
- name: Release Failed - Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: "#ff0000"
SLACK_MESSAGE: ":here-we-go-again: :bob-the-destroyer: We need :fix-parrot: ASAP :pray:"
SLACK_TITLE: Code Interpreter Release Failed
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: "monitoring-releases"