This CLI app supports you to follow git-flow and create a release pull request.
(Release pull request means a pull request which the base branch is the release branch like main
.)
This app fetches pull requests which merged into the development branch, and generates new pull request would merge into the release branch. If the pull request already exists, it updates the title and the body of that.
go install github.com/nekonenene/gh-release-pr-generator@v1
First, you need to get GitHub API Token to control your repository, please see here.
The token needs the write-access permission of pull requests.
gh-release-pr-generator --token 123456789abcd123456789abcd --repo-owner nekonenene --repo-name my-repository-name --head-branch staging --base-branch production
Parameter | Description | Required? |
---|---|---|
-token | GitHub API Token | YES |
-repo-owner | Repository owner name | YES |
-repo-name | Repository name | YES |
-base-branch (-prod-branch) |
Release branch name (default: main ) |
|
-head-branch (-dev-branch) |
Development branch name (default: develop ) |
|
-template-path | PATH of the template file | |
-limit | Limit number of fetching pull requests (default: 100 ) |
|
-enterprise-url | URL of GitHub Enterprise (ex. https://github.your.domain ) |
And this command shows all parameters:
gh-release-pr-generator --help
You can customize the title and the body of the release pull request. Create a template file and specific that with -template-path
option.
The first line of the template will be the title, and the rest will be the body.
Release {{ .Year }}-{{ .Month }}-{{ .Date }} {{ .Hour }}:{{ .Minute }}
# Pull Requests
{{ range $i, $pull := .Pulls }}
* {{ $pull.Title }} (#{{ $pull.Number }}) @{{ $pull.User.Login }}
{{- end }}
Paramter | Description |
---|---|
Year | Current Year (ex. 2006 ) |
YearShort | Current Year (ex. 06 ) |
Month | Current Month (ex. 01 ) |
MonthShort | Current Month (ex. 1 ) |
Date | Current Date (ex. 02 ) |
DateShort | Current Date (ex. 2 ) |
Weekday | Current Weekday (ex. Monday ) |
WeekdayShort | Current Weekday (ex. Mon ) |
Hour | Current Hour (ex. 03 ) |
HourShort | Current Hour (ex. 3 ) |
Minute | Current Minute (ex. 04 ) |
MinuteShort | Current Minute (ex. 4 ) |
Second | Current Second (ex. 05 ) |
SecondShort | Current Second (ex. 5 ) |
Time | Current Time |
Pulls | Pull Requests Array |
The following is an example of the config file for GitHub Actions.
name: Generate Release Pull Request
on:
push:
branches:
- develop
jobs:
gh-release-pr-generator:
name: gh-release-pr-generator
runs-on: ubuntu-latest
env:
TZ: Asia/Tokyo
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ^1.19.4
- name: Install gh-release-pr-generator
run: go install github.com/nekonenene/gh-release-pr-generator@v1
- name: Run gh-release-pr-generator
run: gh-release-pr-generator --token ${{ secrets.GITHUB_TOKEN }} --repo-owner ${{ github.repository_owner }} --repo-name ${{ github.event.repository.name }} --dev-branch develop --prod-branch main
make build