Skip to content

Commit 304a1b1

Browse files
lostindarkCopilot
andcommitted
fix: let Copilot agent fetch release data via MCP tools
The setup step used gh CLI with GITHUB_TOKEN to find draft releases, but contents:read permission cannot see drafts. Removed the shell-based data fetching and moved it into the agent prompt instructions, which uses GitHub MCP tools with sufficient permissions. Also add workflow_dispatch trigger for manual runs, skip conclusion check on manual dispatch, and update release.yml version example. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 4dfa0b4 commit 304a1b1

File tree

2 files changed

+30
-97
lines changed

2 files changed

+30
-97
lines changed

.github/workflows/release-highlights.lock.yml

Lines changed: 19 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/release-highlights.md

Lines changed: 11 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -19,100 +19,34 @@ network:
1919
safe-outputs:
2020
update-release:
2121
steps:
22-
- name: Setup release data
22+
- name: Check workflow conclusion
2323
env:
24-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2524
WORKFLOW_CONCLUSION: ${{ github.event.workflow_run.conclusion }}
2625
run: |
27-
set -e
28-
2926
# Only proceed if the triggering workflow succeeded (skip check for manual dispatch)
3027
if [ -n "$WORKFLOW_CONCLUSION" ] && [ "$WORKFLOW_CONCLUSION" != "success" ]; then
3128
echo "Release workflow did not succeed. Skipping."
3229
exit 1
3330
fi
34-
35-
mkdir -p /tmp/release-data
36-
37-
# Find the latest draft release
38-
gh api "repos/${{ github.repository }}/releases" \
39-
--jq '[.[] | select(.draft)] | .[0]' > /tmp/release-data/current_release.json
40-
41-
RELEASE_TAG=$(jq -r '.tag_name' /tmp/release-data/current_release.json)
42-
RELEASE_ID=$(jq -r '.id' /tmp/release-data/current_release.json)
43-
44-
if [ "$RELEASE_TAG" = "null" ] || [ -z "$RELEASE_TAG" ]; then
45-
echo "No draft release found."
46-
exit 1
47-
fi
48-
49-
echo "Draft release: $RELEASE_TAG (ID: $RELEASE_ID)"
50-
echo "RELEASE_TAG=$RELEASE_TAG" >> "$GITHUB_ENV"
51-
echo "RELEASE_ID=$RELEASE_ID" >> "$GITHUB_ENV"
52-
53-
# Find previous non-draft release
54-
PREV_RELEASE_TAG=$(gh api "repos/${{ github.repository }}/releases" \
55-
--jq '[.[] | select(.draft | not)] | .[0].tag_name // empty')
56-
echo "PREV_RELEASE_TAG=$PREV_RELEASE_TAG" >> "$GITHUB_ENV"
57-
58-
if [ -n "$PREV_RELEASE_TAG" ]; then
59-
echo "Previous release: $PREV_RELEASE_TAG"
60-
61-
# Get commits between tags via API
62-
gh api "repos/${{ github.repository }}/compare/${PREV_RELEASE_TAG}...${RELEASE_TAG}" \
63-
--jq '.commits | [.[] | {sha: .sha[:8], message: (.commit.message | split("\n") | .[0]), author: .author.login}]' \
64-
> /tmp/release-data/commits.json
65-
66-
COMMIT_COUNT=$(jq length /tmp/release-data/commits.json)
67-
echo "✓ Found $COMMIT_COUNT commits"
68-
69-
# Get merged PRs between releases
70-
PREV_DATE=$(gh api "repos/${{ github.repository }}/releases/tags/${PREV_RELEASE_TAG}" --jq '.published_at')
71-
CURR_DATE=$(jq -r '.created_at' /tmp/release-data/current_release.json)
72-
73-
gh pr list \
74-
--state merged \
75-
--limit 100 \
76-
--json number,title,author,labels,mergedAt,url \
77-
--jq "[.[] | select(.mergedAt >= \"$PREV_DATE\" and .mergedAt <= \"$CURR_DATE\")]" \
78-
> /tmp/release-data/pull_requests.json
79-
80-
PR_COUNT=$(jq length /tmp/release-data/pull_requests.json)
81-
echo "✓ Found $PR_COUNT pull requests"
82-
else
83-
echo "No previous release found. This is the first release."
84-
echo "[]" > /tmp/release-data/commits.json
85-
echo "[]" > /tmp/release-data/pull_requests.json
86-
fi
87-
88-
echo "✓ Setup complete"
8931
---
9032

9133
# Release Highlights Generator
9234

93-
Generate an engaging release highlights summary for **${{ github.repository }}** release `${RELEASE_TAG}`.
35+
Generate an engaging release highlights summary for **${{ github.repository }}**.
9436

95-
## Data Available
37+
## Workflow
9638

97-
All data is pre-fetched in `/tmp/release-data/`:
98-
- `current_release.json` - Draft release metadata (tag, name, existing body with auto-generated notes)
99-
- `commits.json` - Commits since `${PREV_RELEASE_TAG}` (sha, message, author)
100-
- `pull_requests.json` - Merged PRs between releases (may be empty if changes were direct commits)
39+
### 1. Gather Release Data
10140

102-
## Workflow
41+
Use the GitHub MCP tools to fetch release information:
10342

104-
### 1. Load Data
43+
1. **Find the latest draft release** — List releases for `${{ github.repository }}` and find the first draft release. If no draft release exists, call `safeoutputs/noop(message="No draft release found")` and stop.
10544

106-
```bash
107-
# View release metadata
108-
cat /tmp/release-data/current_release.json | jq '{tag_name, name, created_at}'
45+
2. **Find the previous published release** — From the same releases list, find the most recent non-draft release. Note its tag name.
10946

110-
# List commits
111-
cat /tmp/release-data/commits.json | jq -r '.[] | "- \(.message) (\(.sha)) by @\(.author)"'
47+
3. **Get commits between releases** — Use the GitHub MCP tools to compare the previous release tag with the draft release tag to get the list of commits.
11248

113-
# List PRs (may be empty)
114-
cat /tmp/release-data/pull_requests.json | jq -r '.[] | "- #\(.number): \(.title) by @\(.author.login)"'
115-
```
49+
4. **Get merged PRs** — Search for merged pull requests in the repository between the two releases.
11650

11751
### 2. Categorize & Prioritize
11852

@@ -153,7 +87,7 @@ Structure:
15387

15488
### 4. Handle Special Cases
15589

156-
**First Release** (no `${PREV_RELEASE_TAG}`):
90+
**First Release** (no previous release):
15791
```markdown
15892
## 🎉 First Release
15993
Welcome to the inaugural release! This version includes the following capabilities:
@@ -173,7 +107,7 @@ Dependency updates and internal improvements to keep things running smoothly.
173107
**✅ CORRECT - Call the MCP tool directly:**
174108
```
175109
safeoutputs/update_release(
176-
tag="${RELEASE_TAG}",
110+
tag="<draft release tag>",
177111
operation="prepend",
178112
body="## 🌟 Release Highlights\n\n[Your complete markdown highlights here]"
179113
)

0 commit comments

Comments
 (0)