-
Notifications
You must be signed in to change notification settings - Fork 5
348 lines (304 loc) · 12.8 KB
/
publish.yml
File metadata and controls
348 lines (304 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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
name: Publish to JSR
on:
push:
branches:
- main
paths:
- "packages/*/deno.json"
- "packages/*/mod.ts"
- "packages/*/src/**"
- "packages/*/package.json"
workflow_dispatch:
inputs:
dry_run:
description: "Perform a dry run without actually publishing"
required: false
type: boolean
default: false
env:
DENO_VERSION: v2.x
jobs:
changes:
name: Detect Changes
runs-on: ubuntu-latest
outputs:
schema: ${{ steps.changes.outputs.schema }}
lib: ${{ steps.changes.outputs.lib }}
pyodide: ${{ steps.changes.outputs.pyodide }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect package changes
id: changes
run: |
# Get the previous commit (or empty tree if first commit)
if git rev-parse HEAD~1 >/dev/null 2>&1; then
PREVIOUS_COMMIT=$(git rev-parse HEAD~1)
else
PREVIOUS_COMMIT=$(git hash-object -t tree /dev/null)
fi
# Check for changes in each package
if git diff --name-only $PREVIOUS_COMMIT HEAD | grep -E '^packages/schema/' || [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "schema=true" >> $GITHUB_OUTPUT
echo "Schema package changed"
else
echo "schema=false" >> $GITHUB_OUTPUT
fi
if git diff --name-only $PREVIOUS_COMMIT HEAD | grep -E '^packages/lib/' || [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "lib=true" >> $GITHUB_OUTPUT
echo "Lib package changed"
else
echo "lib=false" >> $GITHUB_OUTPUT
fi
if git diff --name-only $PREVIOUS_COMMIT HEAD | grep -E '^packages/pyodide-runtime-agent/' || [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "pyodide=true" >> $GITHUB_OUTPUT
echo "Pyodide package changed"
else
echo "pyodide=false" >> $GITHUB_OUTPUT
fi
validate:
name: Validate Packages
runs-on: ubuntu-latest
needs: changes
if: needs.changes.outputs.schema == 'true' || needs.changes.outputs.lib == 'true' || needs.changes.outputs.pyodide == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Deno
uses: denoland/setup-deno@v2
with:
deno-version: ${{ env.DENO_VERSION }}
cache: true
- name: Run CI checks
run: deno task ci
- name: Validate package configs
run: |
# Check that versions are consistent across workspace
SCHEMA_VERSION=$(deno eval "console.log(JSON.parse(Deno.readTextFileSync('packages/schema/deno.json')).version)")
LIB_VERSION=$(deno eval "console.log(JSON.parse(Deno.readTextFileSync('packages/lib/deno.json')).version)")
PYODIDE_VERSION=$(deno eval "console.log(JSON.parse(Deno.readTextFileSync('packages/pyodide-runtime-agent/deno.json')).version)")
echo "Package versions:"
echo " Schema: $SCHEMA_VERSION"
echo " Lib: $LIB_VERSION"
echo " Pyodide: $PYODIDE_VERSION"
# Check that dependencies reference correct versions
LIB_SCHEMA_DEP=$(deno eval "console.log(JSON.parse(Deno.readTextFileSync('packages/lib/deno.json')).imports['@runt/schema'])")
PYODIDE_SCHEMA_DEP=$(deno eval "console.log(JSON.parse(Deno.readTextFileSync('packages/pyodide-runtime-agent/deno.json')).imports['@runt/schema'])")
PYODIDE_LIB_DEP=$(deno eval "console.log(JSON.parse(Deno.readTextFileSync('packages/pyodide-runtime-agent/deno.json')).imports['@runt/lib'])")
echo "Workspace dependencies:"
echo " Lib -> Schema: $LIB_SCHEMA_DEP"
echo " Pyodide -> Schema: $PYODIDE_SCHEMA_DEP"
echo " Pyodide -> Lib: $PYODIDE_LIB_DEP"
- name: Dry run publish validation
run: |
if [ "${{ needs.changes.outputs.schema }}" = "true" ]; then
echo "Validating schema package..."
cd packages/schema
deno publish --dry-run --allow-slow-types
cd ../..
fi
if [ "${{ needs.changes.outputs.lib }}" = "true" ]; then
echo "Validating lib package..."
cd packages/lib
deno publish --dry-run --allow-slow-types
cd ../..
fi
if [ "${{ needs.changes.outputs.pyodide }}" = "true" ]; then
echo "Validating pyodide package..."
cd packages/pyodide-runtime-agent
deno publish --dry-run --allow-slow-types
cd ../..
fi
publish-schema:
name: Publish Schema
runs-on: ubuntu-latest
needs: [changes, validate]
if: needs.changes.outputs.schema == 'true' && needs.validate.result == 'success'
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Deno
uses: denoland/setup-deno@v2
with:
deno-version: ${{ env.DENO_VERSION }}
cache: true
- name: Get package version
id: version
run: |
VERSION=$(cd packages/schema && deno eval "console.log(JSON.parse(Deno.readTextFileSync('deno.json')).version)")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Publishing @runt/schema@$VERSION"
- name: Dry run publish
if: github.event.inputs.dry_run == 'true'
run: |
cd packages/schema
echo "Dry run: Would publish @runt/schema@${{ steps.version.outputs.version }}"
deno publish --dry-run --allow-slow-types
- name: Publish to JSR
if: github.event.inputs.dry_run != 'true'
run: |
cd packages/schema
echo "Publishing @runt/schema@${{ steps.version.outputs.version }}"
npx jsr publish --allow-slow-types
publish-lib:
name: Publish Lib
runs-on: ubuntu-latest
needs: [changes, validate, publish-schema]
if: needs.changes.outputs.lib == 'true' && needs.validate.result == 'success' && (needs.publish-schema.result == 'success' || needs.publish-schema.result == 'skipped')
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Deno
uses: denoland/setup-deno@v2
with:
deno-version: ${{ env.DENO_VERSION }}
cache: true
- name: Get package version
id: version
run: |
VERSION=$(cd packages/lib && deno eval "console.log(JSON.parse(Deno.readTextFileSync('deno.json')).version)")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Publishing @runt/lib@$VERSION"
- name: Wait for schema dependency
if: needs.publish-schema.result == 'success' && github.event.inputs.dry_run != 'true'
run: |
echo "Waiting for @runt/schema to be available on JSR..."
sleep 30
- name: Dry run publish
if: github.event.inputs.dry_run == 'true'
run: |
cd packages/lib
echo "Dry run: Would publish @runt/lib@${{ steps.version.outputs.version }}"
deno publish --dry-run --allow-slow-types
- name: Publish to JSR
if: github.event.inputs.dry_run != 'true'
run: |
cd packages/lib
echo "Publishing @runt/lib@${{ steps.version.outputs.version }}"
npx jsr publish --allow-slow-types
publish-pyodide:
name: Publish Pyodide Runtime Agent
runs-on: ubuntu-latest
needs: [changes, validate, publish-schema, publish-lib]
if: needs.changes.outputs.pyodide == 'true' && needs.validate.result == 'success' && (needs.publish-schema.result == 'success' || needs.publish-schema.result == 'skipped') && (needs.publish-lib.result == 'success' || needs.publish-lib.result == 'skipped')
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Deno
uses: denoland/setup-deno@v2
with:
deno-version: ${{ env.DENO_VERSION }}
cache: true
- name: Get package version
id: version
run: |
VERSION=$(cd packages/pyodide-runtime-agent && deno eval "console.log(JSON.parse(Deno.readTextFileSync('deno.json')).version)")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Publishing @runt/pyodide-runtime-agent@$VERSION"
- name: Wait for dependencies
if: (needs.publish-schema.result == 'success' || needs.publish-lib.result == 'success') && github.event.inputs.dry_run != 'true'
run: |
echo "Waiting for dependencies to be available on JSR..."
sleep 45
- name: Dry run publish
if: github.event.inputs.dry_run == 'true'
run: |
cd packages/pyodide-runtime-agent
echo "Dry run: Would publish @runt/pyodide-runtime-agent@${{ steps.version.outputs.version }}"
deno publish --dry-run --allow-slow-types
- name: Publish to JSR
if: github.event.inputs.dry_run != 'true'
run: |
cd packages/pyodide-runtime-agent
echo "Publishing @runt/pyodide-runtime-agent@${{ steps.version.outputs.version }}"
npx jsr publish --allow-slow-types
create-tags:
name: Create Release Tags
runs-on: ubuntu-latest
needs: [changes, publish-schema, publish-lib, publish-pyodide]
if: always() && (needs.changes.outputs.schema == 'true' || needs.changes.outputs.lib == 'true' || needs.changes.outputs.pyodide == 'true') && github.event.inputs.dry_run != 'true'
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Deno
uses: denoland/setup-deno@v2
with:
deno-version: ${{ env.DENO_VERSION }}
cache: true
- name: Create tags for published packages
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
if [ "${{ needs.publish-schema.result }}" = "success" ]; then
SCHEMA_VERSION=$(cd packages/schema && deno eval "console.log(JSON.parse(Deno.readTextFileSync('deno.json')).version)")
git tag "v$SCHEMA_VERSION-schema" -m "Release @runt/schema@$SCHEMA_VERSION"
echo "Created tag: v$SCHEMA_VERSION-schema"
fi
if [ "${{ needs.publish-lib.result }}" = "success" ]; then
LIB_VERSION=$(cd packages/lib && deno eval "console.log(JSON.parse(Deno.readTextFileSync('deno.json')).version)")
git tag "v$LIB_VERSION-lib" -m "Release @runt/lib@$LIB_VERSION"
echo "Created tag: v$LIB_VERSION-lib"
fi
if [ "${{ needs.publish-pyodide.result }}" = "success" ]; then
PYODIDE_VERSION=$(cd packages/pyodide-runtime-agent && deno eval "console.log(JSON.parse(Deno.readTextFileSync('deno.json')).version)")
git tag "v$PYODIDE_VERSION-pyodide" -m "Release @runt/pyodide-runtime-agent@$PYODIDE_VERSION"
echo "Created tag: v$PYODIDE_VERSION-pyodide"
fi
git push origin --tags
summary:
name: Summary
runs-on: ubuntu-latest
needs:
[
changes,
validate,
publish-schema,
publish-lib,
publish-pyodide,
create-tags,
]
if: always()
steps:
- name: Report results
run: |
echo "## Publish Summary"
echo ""
echo "**Changes detected:**"
echo "- Schema: ${{ needs.changes.outputs.schema }}"
echo "- Lib: ${{ needs.changes.outputs.lib }}"
echo "- Pyodide: ${{ needs.changes.outputs.pyodide }}"
echo ""
echo "**Results:**"
echo "- Validation: ${{ needs.validate.result }}"
echo "- Schema publish: ${{ needs.publish-schema.result }}"
echo "- Lib publish: ${{ needs.publish-lib.result }}"
echo "- Pyodide publish: ${{ needs.publish-pyodide.result }}"
echo "- Tags created: ${{ needs.create-tags.result }}"
echo ""
if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then
echo "**Dry run completed - no packages were published**"
else
if [ "${{ needs.publish-schema.result }}" = "success" ] || [ "${{ needs.publish-lib.result }}" = "success" ] || [ "${{ needs.publish-pyodide.result }}" = "success" ]; then
echo "✅ **Packages successfully published to JSR**"
else
echo "❌ **No packages were published (no changes or errors)**"
fi
fi
- name: Check for failures
if: needs.validate.result == 'failure' || needs.publish-schema.result == 'failure' || needs.publish-lib.result == 'failure' || needs.publish-pyodide.result == 'failure'
run: |
echo "❌ One or more publish jobs failed"
exit 1