-
Notifications
You must be signed in to change notification settings - Fork 4
114 lines (94 loc) · 3.35 KB
/
Copy pathpublish-registry.yml
File metadata and controls
114 lines (94 loc) · 3.35 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
name: Publish to Registry (Studio)
on:
workflow_dispatch:
inputs:
mcps:
description: 'MCPs to publish (comma-separated, e.g. "discord-read,slack-mcp"). Leave empty to detect from changes.'
required: false
type: string
default: ""
dry_run:
description: "Dry run (preview payloads without publishing)"
required: false
type: boolean
default: false
push:
branches:
- main
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
mcps: ${{ steps.detect.outputs.mcps }}
has_changes: ${{ steps.detect.outputs.has_changes }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install
- name: Detect MCPs to publish
id: detect
run: |
MANUAL_MCPS="${{ github.event.inputs.mcps }}"
if [ -n "$MANUAL_MCPS" ]; then
echo "📋 Manual publish triggered for: $MANUAL_MCPS"
CHANGED_MCPS=$(echo "$MANUAL_MCPS" | tr ',' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | jq -R . | jq -s .)
else
PREVIOUS_COMMIT="${{ github.event.before }}"
if [ "$PREVIOUS_COMMIT" = "0000000000000000000000000000000000000000" ] || [ -z "$PREVIOUS_COMMIT" ]; then
PREVIOUS_COMMIT="HEAD~1"
fi
if ! git cat-file -e "$PREVIOUS_COMMIT" 2>/dev/null; then
PREVIOUS_COMMIT="HEAD~1"
fi
CHANGED_MCPS=$(bun run scripts/detect-changed-mcps.ts "$PREVIOUS_COMMIT" HEAD)
fi
echo "Changed MCPs: $CHANGED_MCPS"
# Filter to only MCPs that have an app.json (publishable to registry)
PUBLISHABLE='[]'
for mcp in $(echo "$CHANGED_MCPS" | jq -r '.[]'); do
if [ -f "$mcp/app.json" ]; then
PUBLISHABLE=$(echo "$PUBLISHABLE" | jq -c --arg m "$mcp" '. + [$m]')
fi
done
echo "Publishable MCPs: $PUBLISHABLE"
echo "mcps=$PUBLISHABLE" >> $GITHUB_OUTPUT
if [ "$PUBLISHABLE" = "[]" ]; then
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "has_changes=true" >> $GITHUB_OUTPUT
fi
publish:
needs: detect-changes
if: needs.detect-changes.outputs.has_changes == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
mcp: ${{ fromJSON(needs.detect-changes.outputs.mcps) }}
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install
- name: Publish ${{ matrix.mcp }} to registry
run: |
if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then
bun run scripts/publish-one.ts ${{ matrix.mcp }} --dry-run
else
bun run scripts/publish-one.ts ${{ matrix.mcp }}
fi
env:
PUBLISH_API_KEY: ${{ secrets.PUBLISH_API_KEY }}
- name: Notify success
if: success()
run: echo "✅ Successfully published ${{ matrix.mcp }} to registry"
- name: Notify failure
if: failure()
run: echo "❌ Failed to publish ${{ matrix.mcp }} to registry"