-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor release notes generation to PowerShell #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Migrated the release notes generation step from bash to PowerShell for improved compatibility and maintainability. Enhanced commit listing to use GitHub API for author usernames, added fallback to git log, and improved release note formatting for both pre-release and standard releases.
Changed the workflow branch filter from '*testing*' to '*naming*' to trigger releases on branches related to naming instead of testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Refactors the release notes generation in the GitHub Actions workflow from bash to PowerShell, adds GitHub API-based commit author resolution with a git log fallback, and improves formatting for pre-release and standard releases.
- Switch release-notes generation step to PowerShell
- Use GitHub API to enrich commit list with GitHub usernames; fallback to git log
- Adjust formatting for pre-release and standard releases; add testing branch trigger
Comments suppressed due to low confidence (1)
.github/workflows/release.yml:1
- In the fallback path, $commits is an array of lines from git, but later it's interpolated into a string, which PowerShell joins with spaces, breaking Markdown list formatting. Convert the array to a newline-delimited string and then test for emptiness, e.g.: $commits = (git log ... ) -join "`n"; and similarly join in both branches before the emptiness check.
name: Visual Studio Extension Release
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| # Get commits with GitHub usernames using GitHub API | ||
| try { | ||
| Write-Host "Fetching commits from GitHub API..." | ||
| $apiResponse = gh api "repos/${{ github.repository }}/commits?sha=${{ github.sha }}&per_page=100" --jq '.[] | "\(.commit.message | split("\n")[0])||\(.author.login // "unknown")||\(.sha[0:7])"' | ||
| **Version:** v${{ steps.version.outputs.DISPLAY_VERSION }} | ||
| **Commit:** ${{ github.sha }} | ||
| **Changes ($TAG_INFO):** | ||
| $COMMITS | ||
| ## Installation | ||
| 1. Download the \`.vsix\` file below | ||
| 2. Double-click to install in Visual Studio | ||
| 3. Or use: \`Extensions > Manage Extensions > Install from file\`" | ||
| else | ||
| RELEASE_BODY="## ${{ steps.version-bump.outputs.BUMP_TYPE == 'patch' && '🐛 Patch' || steps.version-bump.outputs.BUMP_TYPE == 'minor' && '✨ Minor' || '🚨 Major' }} Version Bump | ||
| $commitList = @() | ||
| foreach ($line in $apiResponse) { | ||
| $parts = $line -split '\|\|' | ||
| $message = $parts[0] | ||
| $author = $parts[1] | ||
| $sha = $parts[2] | ||
| # Stop if we've reached the last tag | ||
| if (![string]::IsNullOrEmpty($lastCommitSha) -and $sha -eq $lastCommitSha.Substring(0, 7)) { | ||
| break | ||
| } | ||
| $commitList += "- $message by @$author ($sha)" | ||
| } | ||
| $commits = $commitList -join "`n" | ||
| Write-Host "✅ Successfully fetched commits with GitHub usernames" | ||
| } | ||
| catch { | ||
| Write-Host "⚠️ Failed to get commits from GitHub API: $_" | ||
| Write-Host "Falling back to git log..." |
Copilot
AI
Oct 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The try/catch will not catch failures from the native gh command because non-zero exit codes from external processes are non-terminating in PowerShell. As a result, the fallback to git log may never run. After invoking gh, check
.github/workflows/release.yml
Outdated
| # Get commits with GitHub usernames using GitHub API | ||
| try { | ||
| Write-Host "Fetching commits from GitHub API..." | ||
| $apiResponse = gh api "repos/${{ github.repository }}/commits?sha=${{ github.sha }}&per_page=100" --jq '.[] | "\(.commit.message | split("\n")[0])||\(.author.login // "unknown")||\(.sha[0:7])"' |
Copilot
AI
Oct 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The GitHub API call is limited to per_page=100 and does not paginate, so releases with more than 100 commits since the last tag will be truncated. Use gh api --paginate to fetch all pages, e.g.: gh api --paginate "repos/.../commits?sha=...&per_page=100" and process the combined output.
| $apiResponse = gh api "repos/${{ github.repository }}/commits?sha=${{ github.sha }}&per_page=100" --jq '.[] | "\(.commit.message | split("\n")[0])||\(.author.login // "unknown")||\(.sha[0:7])"' | |
| $apiResponse = gh api --paginate "repos/${{ github.repository }}/commits?sha=${{ github.sha }}&per_page=100" --jq '.[] | "\(.commit.message | split("\n")[0])||\(.author.login // "unknown")||\(.sha[0:7])"' |
.github/workflows/release.yml
Outdated
| $releaseBody += "## Installation`n" | ||
| $releaseBody += "1. Download the `.vsix` file below`n" | ||
| $releaseBody += "2. Double-click to install in Visual Studio`n" | ||
| $releaseBody += "3. Or use: ``Extensions > Manage Extensions > Install from file```n" |
Copilot
AI
Oct 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Installation block is duplicated across pre-release and standard branches. Consider building this once (e.g., $installation = "..."), then appending it in both branches to reduce duplication and the risk of inconsistent future edits.
Adds error handling for the GitHub API call and refactors installation instructions to reduce duplication in the release notes generation script within the release workflow.
Migrated the release notes generation step from bash to PowerShell for improved compatibility and maintainability. Enhanced commit listing to use GitHub API for author usernames, added fallback to git log, and improved release note formatting for both pre-release and standard releases.