This script uses the GitHub CLI (gh) to fetch pull requests from a repository, filter them by label, and format the results into a text file.
It’s especially useful for generating release notes from merged PRs.
-
Install the GitHub CLI
On macOS (Homebrew):
brew install gh
Or see full installation instructions.
-
Authenticate with GitHub
Run:
gh auth login
You only need to do this once. The CLI will prompt you to log in via web or token.
-
Verify authentication
gh auth status
You should see your GitHub username and authenticated host.
./generate-release-notes.sh -O OWNER -R REPO -L LABEL -o OUTPUTFILE-O OWNER→ Repository owner (e.g.,owner)-R REPO→ Repository name (e.g.,repoName)-L LABEL→ Label to filter PRs (e.g.,v1.0)-N NUMBER→ Number of PRs to fetch (e.g.,10)-o OUTPUTFILE→ Output file to write formatted results
./gh-pr-export.sh -O owner -R repo-name -L v1.0 -N 5 -o pr_notes.txtThis will generate a file like:
PR #1
----------
Title: First PR
Body : This is body of first PR...
PR #2
----------
Title: Second PR
Body : This is body of second PR...
- Only merged PRs are included.
- You must be authenticated with GitHub CLI (
gh auth login) before running the script. - You can run the script from anywhere if it’s in your
$PATH.