Commit d5c257b
Add PowerShell script to add review comments on PRs modifying release notes (#2058)
### ❔What, Why & How
Contributors updating `RELEASENOTES.md` need to be notified when a new
AL-Go version is released so they can move their changes above the new
version section to maintain proper changelog structure.
**Solution:**
- **PowerShell Script**
(`Internal/Scripts/CommentOnExistingReleaseNotesPrs.ps1`): Manual script
using GitHub CLI to add review comments directly on RELEASENOTES.md file
changes in open PRs
- **Automatic Version Detection**: Script automatically detects the
current version from `RELEASENOTES.md` using multiline regex pattern
that supports vX.Y format only
- **Inline Documentation**: Complete usage instructions and
implementation details in the script header
**Usage:**
```powershell
# Recommended: Use gh auth login for secure authentication
gh auth login
# Or set token as environment variable (may be visible in shell history)
$env:GH_TOKEN = "your-token-here"
# or
$env:GITHUB_TOKEN = "your-token-here"
# Run the script
pwsh Internal/Scripts/CommentOnExistingReleaseNotesPrs.ps1
```
**Key Features:**
- **GitHub CLI Integration**: Uses `gh` commands for better readability
and maintainability
- **Review Comments on File Changes**: Adds comments directly on
RELEASENOTES.md file in the "Files changed" tab at line 1, not as
general PR comments
- **Version Release Notification**: Informs contributors that a new
AL-Go version has been released and their changes need to be moved
- **Automatic Version Detection**: No manual updates needed when
releasing new versions (supports vX.Y format only)
- **Fail-fast Error Handling**: Errors out if version cannot be detected
(no fallback defaults)
- **Version-Specific Comment Checking**: Verifies if review comments for
the current version exist on RELEASENOTES.md before adding new ones,
allowing re-commenting when version changes
- **Comprehensive Reporting**: Detailed summary with success/skip/fail
counts and failed PR list
- **Robust Error Handling**: Handles edge cases (empty PR lists, null
results, API failures) with proper array checking
- **Secure Authentication**: Recommends `gh auth login` with warnings
about shell history exposure
- **Resource Cleanup**: Finally block ensures temporary files are always
removed
- **Exit Codes**: Returns 0 for success, 1 for failures
- **Idiomatic PowerShell**: Uses `@()` array operator for clean, simple
array handling
- **Self-Documenting**: All documentation is in the script header for
easy maintenance
- **Code Quality**: UTF-8 with BOM encoding, passes all pre-commit
checks and PSScriptAnalyzer validation with zero alerts
- **Scalability**: Supports up to 1000 open PRs (maximum limit for gh
CLI)
- **Progress Suppression**: Includes `$ProgressPreference =
"SilentlyContinue"` for cleaner output in automated scenarios
- **Naming Convention**: Script follows PascalCase naming convention
consistent with other PowerShell scripts in the repository
**Comment Message:**
```
A new version of AL-Go (vX.Y) has been released.
Please move your release notes changes to above the ## vX.Y section in the RELEASENOTES.md file.
This ensures your changes are included in the next release rather than being listed under an already-released version.
```
**Implementation Details:**
- Uses multiline regex `(?m)^##\s*v(\d+\.\d+)` for version detection
(major.minor format only)
- Creates review comments using GitHub API endpoint
`/repos/{owner}/{repo}/pulls/{pr}/comments` with required `line: 1`
field
- Review comments include `path: "RELEASENOTES.md"`, `line: 1`, and the
PR's head commit SHA
- Checks for existing review comments on RELEASENOTES.md file with
version-specific text: "A new version of AL-Go (vX.Y) has been
released."
- Version-specific checking prevents false positives from comments about
different versions and allows re-commenting when a new version is
released
- Properly validates empty arrays using
`@($existingReviewComments).Count -gt 0` check
- Uses `Write-Host` with error indicators (✗) for consistent error
reporting instead of `Write-Warning`
- Tracks success, skip, and fail counts separately
- Lists specific PR numbers that failed for manual review
- Uses `@()` array operator for simplified null-safe array handling
- Properly escapes `$searchText` to prevent issues with special
characters in jq filters
- Fetches up to 1000 open PRs (maximum for gh CLI) with documentation
note about limitation
- Suppresses progress bars with `$ProgressPreference =
"SilentlyContinue"` for consistency with other scripts in the repository
- Discards API response output using `Out-Null` to avoid unused variable
warnings
- Script is located in `Internal/Scripts/` alongside other internal
utility scripts
- File encoded with UTF-8 with BOM for PSScriptAnalyzer compliance
- Code follows repository standards with no trailing whitespace
- File name uses PascalCase (`CommentOnExistingReleaseNotesPrs.ps1`) to
match repository conventions (e.g., `GetOwnerForE2ETests.ps1`,
`RemoveTempRepos.ps1`)
**Requirements:**
- GitHub CLI (`gh`) installed: https://cli.github.com/
- GitHub authentication (via `gh auth login` or token)
- PowerShell 7 or later
Related to issue: #
### ✅ Checklist
- [ ] Add tests (E2E, unit tests)
- [ ] Update RELEASENOTES.md
- [x] Update documentation (e.g. for new settings or scenarios)
- [ ] Add telemetry
<!-- START COPILOT CODING AGENT SUFFIX -->
<details>
<summary>Original prompt</summary>
> Go through all open PRs that change the release notes and add a
comment that it needs to be moved above the new version section.
</details>
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>1 parent 4847b79 commit d5c257b
1 file changed
Lines changed: 225 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
0 commit comments