6767 needs : build
6868 permissions :
6969 contents : write
70+ models : read
7071 steps :
7172 - name : Checkout Source
7273 uses : actions/checkout@v5
@@ -84,14 +85,90 @@ jobs:
8485 git push origin ${{ inputs.revision }}
8586 fi
8687
88+ - name : Generate Release Notes with Copilot
89+ env :
90+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
91+ run : |
92+ CURRENT_TAG="${{ inputs.revision }}"
93+
94+ # Find the previous tag (the one before the current tag)
95+ PREV_TAG=$(git describe --tags --abbrev=0 --exclude="${CURRENT_TAG}" HEAD 2>/dev/null || echo "")
96+
97+ # Collect commits between the previous tag and HEAD
98+ if [ -n "$PREV_TAG" ]; then
99+ COMMITS=$(git log --oneline "${PREV_TAG}..HEAD" 2>/dev/null || echo "No commits found")
100+ SINCE_LABEL="$PREV_TAG"
101+ else
102+ COMMITS=$(git log --oneline -50 2>/dev/null || echo "No commits found")
103+ SINCE_LABEL="the beginning"
104+ fi
105+
106+ # Export for Python (avoids shell-escaping issues with multiline content)
107+ export CURRENT_TAG_DATA="$CURRENT_TAG"
108+ export PREV_TAG_DATA="$SINCE_LABEL"
109+ export COMMITS_DATA="$COMMITS"
110+
111+ # Call GitHub Copilot via GitHub Models API and capture the summary
112+ SUMMARY=$(python3 << 'PYEOF'
113+ import json, os, urllib.request, sys
114+
115+ current_tag = os.environ['CURRENT_TAG_DATA']
116+ prev_tag = os.environ['PREV_TAG_DATA']
117+ commits = os.environ['COMMITS_DATA']
118+ token = os.environ['GH_TOKEN']
119+
120+ prompt = (
121+ f"Generate concise release notes for version {current_tag}.\n\n"
122+ f"Commits since {prev_tag}:\n{commits}\n\n"
123+ "Format the output as markdown with sections for New Features, Bug Fixes, "
124+ "and Other Changes (only include sections that have relevant commits). "
125+ "Be concise and clear."
126+ )
127+
128+ payload = json.dumps({
129+ "model": "gpt-4o",
130+ "messages": [{"role": "user", "content": prompt}]
131+ }).encode()
132+
133+ req = urllib.request.Request(
134+ "https://models.inference.ai.azure.com/chat/completions",
135+ data=payload,
136+ headers={
137+ "Content-Type": "application/json",
138+ "Authorization": f"Bearer {token}"
139+ }
140+ )
141+
142+ try:
143+ with urllib.request.urlopen(req) as resp:
144+ data = json.loads(resp.read())
145+ print(data["choices"][0]["message"]["content"])
146+ except Exception as e:
147+ print(f"Failed to generate summary via Copilot: {e}", file=sys.stderr)
148+ print(f"_Release notes generation failed. Raw commits since {prev_tag}:_\n\n```\n{commits}\n```")
149+ PYEOF
150+ )
151+
152+ # Append the summary (with version header) to release-notes.md
153+ NOTES_FILE="release-notes.md"
154+ if [ ! -f "$NOTES_FILE" ]; then
155+ printf "# Release Notes\n\n" > "$NOTES_FILE"
156+ fi
157+ printf "## v%s\n\n%s\n\n" "$CURRENT_TAG" "$SUMMARY" >> "$NOTES_FILE"
158+
159+ # Write the current release notes to a temp file for the Create Release step
160+ printf "%s" "$SUMMARY" > /tmp/current-release-notes.md
161+
162+ echo "Release notes generated and appended to $NOTES_FILE"
163+
87164 - name : Create Release
88165 run : |
89166 if gh release view "v${{ inputs.revision }}" >/dev/null 2>&1; then
90167 echo "Release v${{ inputs.revision }} already exists, skipping."
91168 else
92- gh release create v ${{ inputs.revision }} \
169+ gh release create ${{ inputs.revision }} \
93170 --title "v${{ inputs.revision }}" \
94- --generate- notes \
171+ --notes-file /tmp/current-release- notes.md \
95172 --latest
96173 fi
97174 env :
@@ -112,7 +189,7 @@ jobs:
112189 run : |
113190 git config user.name "github-actions[bot]"
114191 git config user.email "github-actions[bot]@users.noreply.github.com"
115- git add pom.xml
192+ git add pom.xml release-notes.md
116193 git diff --cached --quiet && echo "No changes to commit" || \
117194 git commit -m "chore: bump version to next patch after publishing ${{ inputs.revision }}" && git push
118195
0 commit comments