|
| 1 | +# git-pr-release-go |
| 2 | + |
| 3 | +git-pr-release-go is a Go-based reimagination of the original Ruby CLI tool, [git-pr-release](https://github.com/x-motemen/git-pr-release). |
| 4 | + |
| 5 | +Designed to streamline the development workflow, this tool automates the creation of "Release Pull Requests" on GitHub. Each "Release Pull Request" generated compiles a comprehensive list of pull requests slated for the upcoming release, facilitating a clear overview and seamless integration process. |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | +## Usage |
| 11 | + |
| 12 | +```bash |
| 13 | +$ git-pr-release-go --from main --to release/production |
| 14 | +``` |
| 15 | + |
| 16 | +### GitHub Actions Usage |
| 17 | + |
| 18 | +For this CLI to function within GitHub Actions, it requires the following permissions: |
| 19 | + |
| 20 | +- `contents: read` |
| 21 | +- `pull-requests: write` |
| 22 | + |
| 23 | +Here's a sample workflow: |
| 24 | + |
| 25 | +```yaml |
| 26 | +name: Create Release Pull Request |
| 27 | +on: |
| 28 | + push: |
| 29 | + branches: |
| 30 | + - main |
| 31 | + |
| 32 | +jobs: |
| 33 | + create-release-pr: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + permissions: |
| 36 | + contents: read |
| 37 | + pull-requests: write |
| 38 | + steps: |
| 39 | + - name: Setup git-pr-release-go |
| 40 | + uses: KeisukeYamashita/[email protected] |
| 41 | + with: |
| 42 | + repository: odanado/git-pr-release-go |
| 43 | + arch: x86_64 |
| 44 | + platform: Linux |
| 45 | + |
| 46 | + - run: git-pr-release-go --from main --to release/production |
| 47 | + env: |
| 48 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 49 | +``` |
| 50 | +
|
| 51 | +#### Using GitHub Apps Tokens |
| 52 | +
|
| 53 | +To authenticate using a GitHub Apps token, incorporate [actions/create-github-app-token](https://github.com/actions/create-github-app-token) in your workflow. |
| 54 | +
|
| 55 | +```yaml |
| 56 | +name: Create Release Pull Request |
| 57 | +on: |
| 58 | + push: |
| 59 | + branches: |
| 60 | + - main |
| 61 | + |
| 62 | +jobs: |
| 63 | + create-release-pr: |
| 64 | + runs-on: ubuntu-latest |
| 65 | + steps: |
| 66 | + - uses: actions/create-github-app-token@v1 |
| 67 | + id: app-token |
| 68 | + with: |
| 69 | + app-id: ${{ vars.APP_ID }} |
| 70 | + private-key: ${{ secrets.PRIVATE_KEY }} |
| 71 | + |
| 72 | + - name: Setup git-pr-release-go |
| 73 | + uses: KeisukeYamashita/[email protected] |
| 74 | + with: |
| 75 | + repository: odanado/git-pr-release-go |
| 76 | + arch: x86_64 |
| 77 | + platform: Linux |
| 78 | + |
| 79 | + - run: git-pr-release-go --from main --to release/production |
| 80 | + env: |
| 81 | + GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} |
| 82 | +``` |
| 83 | +
|
| 84 | +### Options |
| 85 | +
|
| 86 | +- `--from`: The base branch name. Required. |
| 87 | +- `--to`: The target branch name. Required. |
| 88 | +- `--labels`: Specify the labels to add to the pull request as a comma-separated list of strings. Optional. |
| 89 | +- `--template`: Specify the Mustache template file. Optional. |
| 90 | +- `--json`: Output the release pull request data in JSON format. Optional. Default is false. |
| 91 | +- `--disable-generated-by-message`: Disable the generated by message in the release pull request body. Optional. Default is false. |
| 92 | + |
| 93 | +### Environment Variables |
| 94 | + |
| 95 | +- `GITHUB_TOKEN`: GitHub API token. Required. |
| 96 | +- `GITHUB_API_URL`: GitHub API URL. Optional. |
| 97 | +- `GITHUB_REPOSITORY`: GitHub repository name. Required. |
| 98 | + |
| 99 | +If you are using GitHub Actions, `GITHUB_API_URL` and `GITHUB_REPOSITORY` are automatically set by the runner and you do not need to specify them. |
| 100 | + |
| 101 | +### Mustache template customization |
| 102 | +Customize your pull request description with Mustache templates, leveraging variables like: |
| 103 | + |
| 104 | +```json5 |
| 105 | +{ |
| 106 | + // Execution date of the CLI |
| 107 | + "date": "yyyy-MM-dd", |
| 108 | + // Array of pull requests for the release, using fields from the GitHub REST API response. |
| 109 | + // https://docs.github.com/ja/rest/pulls/pulls?apiVersion=2022-11-28#list-pull-requests |
| 110 | + "pull_requests": [] |
| 111 | +} |
| 112 | +``` |
| 113 | + |
| 114 | +For a practical example, refer to our [default template file](./git-pr-release.mustache). |
| 115 | + |
| 116 | +## Compare with git-pr-release |
| 117 | + |
| 118 | +This tool is developed in Go, eliminating the need for Ruby, as it operates entirely through a binary file. |
| 119 | + |
| 120 | +While inspired by git-pr-release, this tool pays homage to its predecessor yet introduces several distinct features: |
| 121 | + |
| 122 | +- By default, the pull request description is overwritten. |
| 123 | +- Squash merging is supported without the need for additional options. |
| 124 | +- A config file is not supported. |
| 125 | +- Templates use Mustache files instead of ERB files. |
| 126 | + |
| 127 | +## TODO |
| 128 | +- [ ] Add more testing |
| 129 | + |
| 130 | +## Release flow |
| 131 | + |
| 132 | +- Create new tag `git tag -a vx.y.z -m ""` |
| 133 | +- Push the tag `git push origin vx.y.z` |
0 commit comments