-
Notifications
You must be signed in to change notification settings - Fork 18
634 lines (570 loc) · 27.5 KB
/
plugin-build.yml
File metadata and controls
634 lines (570 loc) · 27.5 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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
# Phase 2: Build Verification
#
# When a plugin has a `build` section, this workflow:
# 1. Clones the developer's source repo at the pinned commit SHA
# 2. Fetches dependencies + runs security audit
# 3. Compiles the project
# 4. Validates the artifact
# 5. Posts a build report to the PR
#
# Source code is EXTERNAL (Homebrew model):
# - plugin.yaml has: build.source_repo + build.source_commit
# - We clone at exact SHA → compile → publish our artifact
# - Community repo stays small (no source code stored)
#
# SECURITY: Split into isolated jobs to prevent Pwn Request attacks.
# - gate: blocks fork PRs that modify .github/
# - collect: zero permissions, checkouts fork code, collects data as artifact
# - build jobs: have write perms, only checkout main, process artifact data
name: "Phase 2: Build Verification"
on:
pull_request_target:
paths:
- 'skills/**'
types: [opened, synchronize, reopened]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
# ═══════════════════════════════════════════════════════════════
# Security Gate — block fork PRs that modify .github/
# ═══════════════════════════════════════════════════════════════
gate:
name: Security gate
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
safe: ${{ steps.check.outputs.safe }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false
fetch-depth: 0
- name: Block .github modifications from forks
id: check
run: |
echo "Checking PR for .github/ modifications..."
CHANGES=$(git diff --name-only origin/main...${{ github.event.pull_request.head.sha }} | grep "^\.github/" || true)
if [ -n "$CHANGES" ]; then
echo "::error::Fork PRs cannot modify .github/ files:"
echo "$CHANGES"
echo "safe=false" >> "$GITHUB_OUTPUT"
exit 1
fi
echo "No .github/ modifications detected"
echo "safe=true" >> "$GITHUB_OUTPUT"
# ═══════════════════════════════════════════════════════════════
# Collect — zero permissions sandbox, checkout fork code
# ═══════════════════════════════════════════════════════════════
collect:
name: Collect plugin data
needs: gate
runs-on: ubuntu-latest
permissions: {}
outputs:
plugin_dir: ${{ steps.find.outputs.plugin_dir }}
plugin_name: ${{ steps.find.outputs.plugin_name }}
has_build: ${{ steps.find.outputs.has_build }}
build_lang: ${{ steps.find.outputs.build_lang }}
source_repo: ${{ steps.find.outputs.source_repo }}
source_commit: ${{ steps.find.outputs.source_commit }}
source_dir: ${{ steps.find.outputs.source_dir }}
source_mode: ${{ steps.find.outputs.source_mode }}
local_source_dir: ${{ steps.find.outputs.local_source_dir }}
binary_name: ${{ steps.find.outputs.binary_name }}
build_main: ${{ steps.find.outputs.build_main }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false
fetch-depth: 0
- name: Find plugin and parse build config
id: find
run: |
CHANGED=$(git diff --name-only origin/main...${{ github.event.pull_request.head.sha }} -- 'skills/' | head -100)
PLUGIN_NAME=$(echo "$CHANGED" | head -1 | cut -d'/' -f2)
# Validate plugin name (prevent injection via malicious folder names)
if ! echo "$PLUGIN_NAME" | grep -qE '^[a-zA-Z0-9_-]+$'; then
echo "::error::Invalid plugin name: contains special characters"
exit 1
fi
PLUGIN_DIR="skills/${PLUGIN_NAME}"
echo "plugin_dir=${PLUGIN_DIR}" >> "$GITHUB_OUTPUT"
echo "plugin_name=${PLUGIN_NAME}" >> "$GITHUB_OUTPUT"
YAML_FILE="${PLUGIN_DIR}/plugin.yaml"
if [ ! -f "$YAML_FILE" ]; then
echo "has_build=false" >> "$GITHUB_OUTPUT"
exit 0
fi
# Parse all build fields at once
YAML_FILE="$YAML_FILE" PLUGIN_DIR="$PLUGIN_DIR" python3 << 'PYEOF'
import yaml, os
yaml_file = os.environ["YAML_FILE"]
plugin_dir = os.environ["PLUGIN_DIR"]
with open(yaml_file) as f:
data = yaml.safe_load(f)
build = data.get("build")
out = os.environ.get("GITHUB_OUTPUT", "/dev/null")
with open(out, "a") as gh:
if not build:
gh.write("has_build=false\n")
else:
gh.write("has_build=true\n")
gh.write(f"build_lang={build.get('lang', '')}\n")
repo = build.get('source_repo', '')
commit = build.get('source_commit', '')
gh.write(f"source_repo={repo}\n")
gh.write(f"source_commit={commit}\n")
sd = build.get('source_dir', '.')
gh.write(f"source_dir={'' if sd == '.' else sd}\n")
gh.write(f"binary_name={build.get('binary_name', '')}\n")
gh.write(f"build_main={build.get('main', '')}\n")
# source_mode: "local" if no external repo, "external" if repo specified
if repo:
gh.write("source_mode=external\n")
else:
gh.write("source_mode=local\n")
gh.write(f"local_source_dir={plugin_dir}\n")
PYEOF
# ── Collect plugin files as artifact (for local-source builds) ──
- name: Collect plugin files
run: |
mkdir -p /tmp/plugin-data
PLUGIN_DIR="skills/${{ steps.find.outputs.plugin_name }}"
if [ -d "$PLUGIN_DIR" ]; then
cp -r "$PLUGIN_DIR" /tmp/plugin-data/
fi
- uses: actions/upload-artifact@v4
with:
name: plugin-data
path: /tmp/plugin-data/
# ═══ Clone source repo (shared step) ════════════════════════
# Each build job clones the external repo at the pinned commit SHA.
# This is a YAML anchor pattern — each job repeats the clone step.
# ═══════════════════════════════════════════════════════════════
# Rust Build
# ═══════════════════════════════════════════════════════════════
build-rust:
name: Build (Rust)
needs: collect
if: needs.collect.outputs.has_build == 'true' && needs.collect.outputs.build_lang == 'rust'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
# No repository/ref override = checkouts main (trusted code)
- uses: actions/download-artifact@v4
if: needs.collect.outputs.source_mode != 'external'
with:
name: plugin-data
path: /tmp/plugin-data/
- name: Prepare source
run: |
if [ "${{ needs.collect.outputs.source_mode }}" = "external" ] && [ -n "${{ needs.collect.outputs.source_repo }}" ]; then
git clone "https://github.com/${{ needs.collect.outputs.source_repo }}.git" /tmp/source
cd /tmp/source && git checkout "${{ needs.collect.outputs.source_commit }}"
echo "Checked out $(git rev-parse HEAD)"
else
PLUGIN_NAME="${{ needs.collect.outputs.plugin_name }}"
LOCAL_DIR="${{ needs.collect.outputs.local_source_dir }}"
[ -z "$LOCAL_DIR" ] && LOCAL_DIR="${{ needs.collect.outputs.plugin_dir }}"
ARTIFACT_DIR="/tmp/plugin-data/${PLUGIN_NAME}"
if [ -d "$ARTIFACT_DIR" ]; then
cp -r "$ARTIFACT_DIR" /tmp/source
else
cp -r "$LOCAL_DIR" /tmp/source
fi
echo "Using local source from artifact"
fi
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Fetch dependencies
working-directory: /tmp/source/${{ needs.collect.outputs.source_dir }}
run: cargo fetch
- name: Security audit
working-directory: /tmp/source/${{ needs.collect.outputs.source_dir }}
run: |
cargo install cargo-audit 2>/dev/null || true
cargo audit 2>&1 || true
- name: Build
working-directory: /tmp/source/${{ needs.collect.outputs.source_dir }}
run: cargo build --release 2>&1 | tail -20
- name: Verify artifact
id: verify
run: |
BIN="/tmp/source/${{ needs.collect.outputs.source_dir }}/target/release/${{ needs.collect.outputs.binary_name }}"
if [ -f "$BIN" ]; then
chmod +x "$BIN"
SIZE=$(stat -c%s "$BIN" 2>/dev/null || stat -f%z "$BIN")
echo "size=$((SIZE / 1024 / 1024))MB" >> "$GITHUB_OUTPUT"
echo "status=pass" >> "$GITHUB_OUTPUT"
sha256sum "$BIN"
else
echo "::error::Binary not found at $BIN"
echo "status=fail" >> "$GITHUB_OUTPUT"
fi
- name: Upload artifact
if: steps.verify.outputs.status == 'pass'
uses: actions/upload-artifact@v4
with:
name: build-rust-${{ needs.collect.outputs.plugin_name }}
path: /tmp/source/${{ needs.collect.outputs.source_dir }}/target/release/${{ needs.collect.outputs.binary_name }}
# ═══════════════════════════════════════════════════════════════
# Go Build
# ═══════════════════════════════════════════════════════════════
build-go:
name: Build (Go)
needs: collect
if: needs.collect.outputs.has_build == 'true' && needs.collect.outputs.build_lang == 'go'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
# No repository/ref override = checkouts main (trusted code)
- uses: actions/download-artifact@v4
if: needs.collect.outputs.source_mode != 'external'
with:
name: plugin-data
path: /tmp/plugin-data/
- name: Prepare source
run: |
if [ "${{ needs.collect.outputs.source_mode }}" = "external" ] && [ -n "${{ needs.collect.outputs.source_repo }}" ]; then
git clone "https://github.com/${{ needs.collect.outputs.source_repo }}.git" /tmp/source
cd /tmp/source && git checkout "${{ needs.collect.outputs.source_commit }}"
echo "Checked out $(git rev-parse HEAD)"
else
PLUGIN_NAME="${{ needs.collect.outputs.plugin_name }}"
LOCAL_DIR="${{ needs.collect.outputs.local_source_dir }}"
[ -z "$LOCAL_DIR" ] && LOCAL_DIR="${{ needs.collect.outputs.plugin_dir }}"
ARTIFACT_DIR="/tmp/plugin-data/${PLUGIN_NAME}"
if [ -d "$ARTIFACT_DIR" ]; then
cp -r "$ARTIFACT_DIR" /tmp/source
else
cp -r "$LOCAL_DIR" /tmp/source
fi
echo "Using local source from artifact"
fi
- uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Fetch dependencies
working-directory: /tmp/source/${{ needs.collect.outputs.source_dir }}
run: go mod download
- name: Security check
working-directory: /tmp/source/${{ needs.collect.outputs.source_dir }}
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest 2>/dev/null || true
govulncheck ./... 2>&1 || true
- name: Build
working-directory: /tmp/source/${{ needs.collect.outputs.source_dir }}
env:
CGO_ENABLED: 0
run: go build -o "${{ needs.collect.outputs.binary_name }}" -ldflags="-s -w" .
- name: Verify artifact
id: verify
run: |
BIN="/tmp/source/${{ needs.collect.outputs.source_dir }}/${{ needs.collect.outputs.binary_name }}"
if [ -f "$BIN" ]; then
SIZE=$(stat -c%s "$BIN")
echo "size=$((SIZE / 1024 / 1024))MB" >> "$GITHUB_OUTPUT"
echo "status=pass" >> "$GITHUB_OUTPUT"
sha256sum "$BIN"
else
echo "status=fail" >> "$GITHUB_OUTPUT"
fi
- name: Upload artifact
if: steps.verify.outputs.status == 'pass'
uses: actions/upload-artifact@v4
with:
name: build-go-${{ needs.collect.outputs.plugin_name }}
path: /tmp/source/${{ needs.collect.outputs.source_dir }}/${{ needs.collect.outputs.binary_name }}
# ═══════════════════════════════════════════════════════════════
# TypeScript Build (Bun compile)
# ═══════════════════════════════════════════════════════════════
build-typescript:
name: Build (TypeScript)
needs: collect
if: needs.collect.outputs.has_build == 'true' && needs.collect.outputs.build_lang == 'typescript'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
# No repository/ref override = checkouts main (trusted code)
- uses: actions/download-artifact@v4
if: needs.collect.outputs.source_mode != 'external'
with:
name: plugin-data
path: /tmp/plugin-data/
- name: Prepare source
run: |
if [ "${{ needs.collect.outputs.source_mode }}" = "external" ] && [ -n "${{ needs.collect.outputs.source_repo }}" ]; then
git clone "https://github.com/${{ needs.collect.outputs.source_repo }}.git" /tmp/source
cd /tmp/source && git checkout "${{ needs.collect.outputs.source_commit }}"
echo "Checked out $(git rev-parse HEAD)"
else
PLUGIN_NAME="${{ needs.collect.outputs.plugin_name }}"
LOCAL_DIR="${{ needs.collect.outputs.local_source_dir }}"
[ -z "$LOCAL_DIR" ] && LOCAL_DIR="${{ needs.collect.outputs.plugin_dir }}"
ARTIFACT_DIR="/tmp/plugin-data/${PLUGIN_NAME}"
if [ -d "$ARTIFACT_DIR" ]; then
cp -r "$ARTIFACT_DIR" /tmp/source
else
cp -r "$LOCAL_DIR" /tmp/source
fi
echo "Using local source from artifact"
fi
- uses: oven-sh/setup-bun@v2
- name: Install dependencies
working-directory: /tmp/source/${{ needs.collect.outputs.source_dir }}
run: bun install
- name: Compile to binary
working-directory: /tmp/source/${{ needs.collect.outputs.source_dir }}
run: bun build --compile "${{ needs.collect.outputs.build_main }}" --outfile "${{ needs.collect.outputs.binary_name }}"
- name: Verify artifact
id: verify
run: |
BIN="/tmp/source/${{ needs.collect.outputs.source_dir }}/${{ needs.collect.outputs.binary_name }}"
if [ -f "$BIN" ]; then
SIZE=$(stat -c%s "$BIN")
echo "size=$((SIZE / 1024 / 1024))MB" >> "$GITHUB_OUTPUT"
echo "status=pass" >> "$GITHUB_OUTPUT"
sha256sum "$BIN"
else
echo "status=fail" >> "$GITHUB_OUTPUT"
fi
- name: Upload artifact
if: steps.verify.outputs.status == 'pass'
uses: actions/upload-artifact@v4
with:
name: build-ts-${{ needs.collect.outputs.plugin_name }}
path: /tmp/source/${{ needs.collect.outputs.source_dir }}/${{ needs.collect.outputs.binary_name }}
# ═══════════════════════════════════════════════════════════════
# Node.js (npm pack)
# ═══════════════════════════════════════════════════════════════
build-node:
name: Build (Node.js)
needs: collect
if: needs.collect.outputs.has_build == 'true' && needs.collect.outputs.build_lang == 'node'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
# No repository/ref override = checkouts main (trusted code)
- uses: actions/download-artifact@v4
if: needs.collect.outputs.source_mode != 'external'
with:
name: plugin-data
path: /tmp/plugin-data/
- name: Prepare source
run: |
if [ "${{ needs.collect.outputs.source_mode }}" = "external" ] && [ -n "${{ needs.collect.outputs.source_repo }}" ]; then
git clone "https://github.com/${{ needs.collect.outputs.source_repo }}.git" /tmp/source
cd /tmp/source && git checkout "${{ needs.collect.outputs.source_commit }}"
echo "Checked out $(git rev-parse HEAD)"
else
PLUGIN_NAME="${{ needs.collect.outputs.plugin_name }}"
LOCAL_DIR="${{ needs.collect.outputs.local_source_dir }}"
[ -z "$LOCAL_DIR" ] && LOCAL_DIR="${{ needs.collect.outputs.plugin_dir }}"
ARTIFACT_DIR="/tmp/plugin-data/${PLUGIN_NAME}"
if [ -d "$ARTIFACT_DIR" ]; then
cp -r "$ARTIFACT_DIR" /tmp/source
else
cp -r "$LOCAL_DIR" /tmp/source
fi
echo "Using local source from artifact"
fi
- uses: oven-sh/setup-bun@v2
- name: Install dependencies
working-directory: /tmp/source/${{ needs.collect.outputs.source_dir }}
run: bun install
- name: Compile to binary
working-directory: /tmp/source/${{ needs.collect.outputs.source_dir }}
run: bun build --compile "${{ needs.collect.outputs.build_main }}" --outfile "${{ needs.collect.outputs.binary_name }}"
- name: Verify artifact
id: verify
run: |
BIN="/tmp/source/${{ needs.collect.outputs.source_dir }}/${{ needs.collect.outputs.binary_name }}"
if [ -f "$BIN" ]; then
SIZE=$(stat -c%s "$BIN")
echo "size=$((SIZE / 1024 / 1024))MB" >> "$GITHUB_OUTPUT"
echo "status=pass" >> "$GITHUB_OUTPUT"
sha256sum "$BIN"
else
echo "status=fail" >> "$GITHUB_OUTPUT"
fi
- name: Upload artifact
if: steps.verify.outputs.status == 'pass'
uses: actions/upload-artifact@v4
with:
name: build-node-${{ needs.collect.outputs.plugin_name }}
path: /tmp/source/${{ needs.collect.outputs.source_dir }}/${{ needs.collect.outputs.binary_name }}
# ═══════════════════════════════════════════════════════════════
# Python Validation (pip install — no binary packaging)
# Python plugins are distributed as pip packages, not binaries.
# Users install via pip/pipx at runtime.
# ═══════════════════════════════════════════════════════════════
build-python:
name: Build (Python)
needs: collect
if: needs.collect.outputs.has_build == 'true' && needs.collect.outputs.build_lang == 'python'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
# No repository/ref override = checkouts main (trusted code)
- uses: actions/download-artifact@v4
if: needs.collect.outputs.source_mode != 'external'
with:
name: plugin-data
path: /tmp/plugin-data/
- name: Prepare source
run: |
if [ "${{ needs.collect.outputs.source_mode }}" = "external" ] && [ -n "${{ needs.collect.outputs.source_repo }}" ]; then
git clone "https://github.com/${{ needs.collect.outputs.source_repo }}.git" /tmp/source
cd /tmp/source && git checkout "${{ needs.collect.outputs.source_commit }}"
echo "Checked out $(git rev-parse HEAD)"
else
PLUGIN_NAME="${{ needs.collect.outputs.plugin_name }}"
LOCAL_DIR="${{ needs.collect.outputs.local_source_dir }}"
[ -z "$LOCAL_DIR" ] && LOCAL_DIR="${{ needs.collect.outputs.plugin_dir }}"
ARTIFACT_DIR="/tmp/plugin-data/${PLUGIN_NAME}"
if [ -d "$ARTIFACT_DIR" ]; then
cp -r "$ARTIFACT_DIR" /tmp/source
else
cp -r "$LOCAL_DIR" /tmp/source
fi
echo "Using local source from artifact"
fi
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Check Python version requirements
working-directory: /tmp/source/${{ needs.collect.outputs.source_dir }}
run: |
# Extract requires-python from pyproject.toml if present
if [ -f pyproject.toml ]; then
REQUIRES=$(python3 -c "
import tomllib
with open('pyproject.toml', 'rb') as f:
data = tomllib.load(f)
print(data.get('project', {}).get('requires-python', 'not specified'))
" 2>/dev/null || echo "not specified")
echo "requires-python: $REQUIRES"
fi
- name: Install package
working-directory: /tmp/source/${{ needs.collect.outputs.source_dir }}
run: |
pip install pip-audit
pip install -e . 2>/dev/null || pip install -r requirements.txt 2>/dev/null || pip install . || {
echo "::error::pip install failed — this package cannot be installed"
exit 1
}
echo "pip install succeeded"
- name: Security audit
run: pip-audit 2>&1 || true
- name: Verify entry point works
id: verify
working-directory: /tmp/source/${{ needs.collect.outputs.source_dir }}
run: |
MAIN="${{ needs.collect.outputs.build_main }}"
BIN="${{ needs.collect.outputs.binary_name }}"
# Check if the entry point script runs
if [ -n "$MAIN" ] && python3 "$MAIN" --help > /dev/null 2>&1; then
echo "Entry point $MAIN responds to --help"
echo "status=pass" >> "$GITHUB_OUTPUT"
elif command -v "$BIN" > /dev/null 2>&1; then
echo "Installed command $BIN found in PATH"
echo "status=pass" >> "$GITHUB_OUTPUT"
else
echo "status=pass" >> "$GITHUB_OUTPUT"
echo "::warning::Could not verify entry point, but pip install succeeded"
fi
# Report package info
pip show "$(python3 -c "
import tomllib
with open('pyproject.toml', 'rb') as f:
print(tomllib.load(f).get('project', {}).get('name', ''))
" 2>/dev/null || echo '')" 2>/dev/null || true
# ═══════════════════════════════════════════════════════════════
# Build Report
# ═══════════════════════════════════════════════════════════════
report:
name: Build report
needs: [collect, build-rust, build-go, build-typescript, build-node, build-python]
if: always() && needs.collect.outputs.has_build == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Post build report
uses: actions/github-script@v7
env:
BUILD_LANG: ${{ needs.collect.outputs.build_lang }}
PLUGIN_NAME: ${{ needs.collect.outputs.plugin_name }}
SOURCE_REPO: ${{ needs.collect.outputs.source_repo }}
SOURCE_COMMIT: ${{ needs.collect.outputs.source_commit }}
with:
script: |
const lang = process.env.BUILD_LANG;
const pluginName = process.env.PLUGIN_NAME;
const sourceRepo = process.env.SOURCE_REPO;
const sourceCommit = process.env.SOURCE_COMMIT;
const results = {
rust: '${{ needs.build-rust.result }}',
go: '${{ needs.build-go.result }}',
typescript: '${{ needs.build-typescript.result }}',
node: '${{ needs.build-node.result }}',
python: '${{ needs.build-python.result }}',
};
const result = results[lang] || 'skipped';
const passed = result === 'success';
const icon = passed ? '✅' : (result === 'skipped' ? '⏭️' : '❌');
const status = passed ? 'PASSED' : (result === 'skipped' ? 'SKIPPED' : 'FAILED');
const shortSha = sourceCommit.substring(0, 8);
const body = [
`## 🔨 Phase 2: Build Verification — ${icon} ${status}`,
'',
`> **Plugin**: \`${pluginName}\` | **Language**: \`${lang}\``,
`> **Source**: [\`${sourceRepo}@${shortSha}\`](https://github.com/${sourceRepo}/tree/${sourceCommit})`,
`> `,
`> *Compiled from developer source code by our CI. Users install our build artifacts.*`,
'',
passed
? 'Build succeeded. Compiled artifact uploaded as workflow artifact.'
: result === 'skipped'
? 'No build configuration — Skill-only plugin.'
: `Build failed. Check the [workflow logs](${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}).`,
'',
'---',
`*Source integrity: commit SHA \`${sourceCommit}\` is the content fingerprint.*`
].join('\n');
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ github.event.pull_request.number }},
});
const botComment = comments.find(c =>
c.user.type === 'Bot' && c.body.includes('Phase 2: Build Verification')
);
const params = { owner: context.repo.owner, repo: context.repo.repo, body };
if (botComment) {
await github.rest.issues.updateComment({ ...params, comment_id: botComment.id });
} else {
await github.rest.issues.createComment({ ...params, issue_number: ${{ github.event.pull_request.number }} });
}