Skip to content

Commit 8c00d60

Browse files
Add release event dispatcher workflow
Adds an opt-in workflow that fires repository_dispatch on release events to a downstream repository, when one is configured via the RELEASE_AUTOMATION_REPO repository variable. When the variable is unset, the workflow is a no-op so forks and other adopters pay no overhead. Two event types are emitted: mcp-server-release-drafted on release: { types: [created] } mcp-server-released on release: { types: [published] } Prereleases are skipped for both event types. The downstream payload is { tag, url } only — no other release data crosses the boundary. Required when RELEASE_AUTOMATION_REPO is set: Variable RELEASE_AUTOMATION_REPO owner/repo of the downstream Secret RELEASE_AUTOMATION_DISPATCH_PAT PAT with actions:write on it Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 457f599 commit 8c00d60

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Dispatch release events
2+
3+
# Fires a `repository_dispatch` on release events to an optional downstream
4+
# repository, configured at runtime via the `RELEASE_AUTOMATION_REPO`
5+
# repository variable. When the variable is not set, this workflow is a no-op,
6+
# so adopters and forks pay no overhead unless they opt in.
7+
#
8+
# Event types emitted:
9+
# mcp-server-release-drafted on release: { types: [created] }
10+
# mcp-server-released on release: { types: [published] }
11+
#
12+
# Prereleases are skipped for both event types.
13+
#
14+
# Required when RELEASE_AUTOMATION_REPO is set:
15+
# Variable RELEASE_AUTOMATION_REPO owner/repo of the downstream repo
16+
# Secret RELEASE_AUTOMATION_DISPATCH_PAT PAT with actions:write on that repo
17+
18+
on:
19+
release:
20+
types: [created, published]
21+
22+
permissions: {}
23+
24+
concurrency:
25+
group: release-dispatch-${{ github.event.release.id }}-${{ github.event.action }}
26+
cancel-in-progress: false
27+
28+
jobs:
29+
dispatch:
30+
if: ${{ vars.RELEASE_AUTOMATION_REPO != '' }}
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Resolve event type
34+
id: event
35+
env:
36+
ACTION: ${{ github.event.action }}
37+
IS_PRERELEASE: ${{ github.event.release.prerelease }}
38+
run: |
39+
set -euo pipefail
40+
if [[ "$IS_PRERELEASE" == "true" ]]; then
41+
echo "::notice::Skipping prerelease"
42+
echo "skip=true" >> "$GITHUB_OUTPUT"
43+
exit 0
44+
fi
45+
case "$ACTION" in
46+
created) echo "type=mcp-server-release-drafted" >> "$GITHUB_OUTPUT" ;;
47+
published) echo "type=mcp-server-released" >> "$GITHUB_OUTPUT" ;;
48+
*)
49+
echo "::notice::Unhandled release action: $ACTION"
50+
echo "skip=true" >> "$GITHUB_OUTPUT"
51+
;;
52+
esac
53+
54+
- name: Send repository_dispatch
55+
if: steps.event.outputs.skip != 'true'
56+
env:
57+
GH_TOKEN: ${{ secrets.RELEASE_AUTOMATION_DISPATCH_PAT }}
58+
TARGET_REPO: ${{ vars.RELEASE_AUTOMATION_REPO }}
59+
EVENT_TYPE: ${{ steps.event.outputs.type }}
60+
TAG: ${{ github.event.release.tag_name }}
61+
URL: ${{ github.event.release.html_url }}
62+
run: |
63+
set -euo pipefail
64+
if [[ -z "${GH_TOKEN:-}" ]]; then
65+
echo "::error::RELEASE_AUTOMATION_DISPATCH_PAT secret is not set"
66+
exit 1
67+
fi
68+
gh api "repos/${TARGET_REPO}/dispatches" \
69+
-f "event_type=${EVENT_TYPE}" \
70+
-F "client_payload[tag]=${TAG}" \
71+
-F "client_payload[url]=${URL}"

0 commit comments

Comments
 (0)