releaser-pleaser/docs/tutorials/github.md
Julian Tölle 2d3a960939
feat: run one job concurrently to reduce chance of conflicts (#198)
Each run of releaser-pleaser acts on the same global state in the
forge. Therefore, parallel runs are unnecessary.

This commit also communicates to the GitHub and GitLab CI pipelines that
the releaser-pleaser jobs can be cancelled as early as possible.

- On GitHub Actions this can be guaranteed through the workflow
  settings. These settings are copied into each repository that uses
  releaser-pleaser, so users need to update this manually. I will add a
  note to the release notes for this.
- On GitLab CI/CD this requires the user to configure a project level setting to
  "auto-cancel redundant pipelines". We will not recommend user to set
  this, as it is quite invasive and can break their regular CI pipelines.
2025-06-14 13:43:35 +00:00

76 lines
2.4 KiB
Markdown

# Getting started on GitHub
In this tutorial you will learn how to set up `releaser-pleaser` in your GitHub project with GitHub Actions.
## 1. Repository Settings
### 1.1. Squash Merging
`releaser-pleaser` requires you to use `squash` merging. With other merge options it can not reliably find the right pull request for every commit on `main`.
Open your repository settings to page _General_:
> `https://github.com/YOUR-NAME/YOUR-PROJECT/settings`
In the "Pull Requests" section make sure that only "Allow squash merging" is enabled and "Allow merge commits" and "Allow rebase merging" is disabled.
![Screenshot of the required merge settings](./github-settings-pr.png)
### 1.2. Workflow Permissions
`releaser-pleaser` creates [release pull requests](../explanation/release-pr.md) for you. By default, Actions are not allowed to create pull requests, so we need to enable this.
Open your repository settings to page _Actions > General_:
> `https://github.com/YOUR-NAME/YOUR-PROJECT/settings/actions`
In the "Workflow permissions" section make sure that "Allow GitHub Actions to create and approve pull requests" is enabled.
![Screenshot of the required workflow settings](./github-settings-workflow.png)
## 2. GitHub Actions Workflow
Create a new file `.github/workflows/releaser-pleaser.yaml` with this content. Make sure that it is available on the `main` branch.
```yaml
name: releaser-pleaser
on:
push:
branches: [main]
pull_request_target:
types:
- edited
- labeled
- unlabeled
concurrency:
group: releaser-pleaser
cancel-in-progress: true
jobs:
releaser-pleaser:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: releaser-pleaser
uses: apricote/releaser-pleaser@v0.4.0
```
## 3. Release Pull Request
Once this job runs for the first time, you can check the logs to see what it did.
If you have releasable commits since the last tag, `releaser-pleaser` opens a release pull request for the proposed release.
Once you merge this pull request, `releaser-pleaser` automatically creates a Git tag and GitHub Release with the proposed version and changelog.
## Related Documentation
- **Explanation**
- [Release Pull Request](../explanation/release-pr.md)
- **Guide**
- [GitHub Workflow Permissions](../guides/github-workflow-permissions.md)
- **Reference**
- [GitHub Action](../reference/github-action.md)