mirror of
https://github.com/apricote/releaser-pleaser.git
synced 2026-01-13 21:21:03 +00:00
refactor: let updaters define the files they want to run on (#233)
This change reverses the responsibility for which files the updaters are run on. Now each updater can specify the list of files and wether the files should be created when they do not exist yet. This simplifies the handling of each update in releaserpleaser.go, as we can just iterate over all updaters and call it for each file of that updater. Also update the flags to allow users to easily define which updaters should run.
This commit is contained in:
parent
1e9e0aa5d9
commit
f1aa1a2ef4
20 changed files with 307 additions and 151 deletions
|
|
@ -25,6 +25,7 @@
|
|||
- [Pull Request Options](reference/pr-options.md)
|
||||
- [GitHub Action](reference/github-action.md)
|
||||
- [GitLab CI/CD Component](reference/gitlab-cicd-component.md)
|
||||
- [Updaters](reference/updaters.md)
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ In some situations it makes sense to have the current version committed in files
|
|||
|
||||
## Markers
|
||||
|
||||
The line that needs to be updated must have the marker `x-releaser-pleaser-version` somewhere after the version that should be updated.
|
||||
The line that needs to be updated must have the marker
|
||||
`x-releaser-pleaser-version` somewhere after the version that should be updated.
|
||||
|
||||
For example:
|
||||
|
||||
|
|
@ -28,7 +29,8 @@ You need to tell `releaser-pleaser` which files it should update. This happens t
|
|||
|
||||
### GitHub Action
|
||||
|
||||
In the GitHub Action you can set the `extra-files` input with a list of the files. They need to be formatted as a single multi-line string with one file path per line:
|
||||
In the GitHub Action you can set the
|
||||
`extra-files` input with a list of the files. They need to be formatted as a single multi-line string with one file path per line:
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
|
|
@ -44,7 +46,8 @@ jobs:
|
|||
|
||||
### GitLab CI/CD Component
|
||||
|
||||
In the GitLab CI/CD Component you can set the `extra-files` input with a list of files. They need to be formatted as a single multi-line string with one file path per line:
|
||||
In the GitLab CI/CD Component you can set the
|
||||
`extra-files` input with a list of files. They need to be formatted as a single multi-line string with one file path per line:
|
||||
|
||||
```yaml
|
||||
include:
|
||||
|
|
@ -61,3 +64,4 @@ include:
|
|||
- **Reference**
|
||||
- [GitHub Action](../reference/github-action.md#inputs)
|
||||
- [GitLab CI/CD Component](../reference/gitlab-cicd-component.md#inputs)
|
||||
- [Updaters](../reference/updaters.md#generic-updater)
|
||||
|
|
|
|||
|
|
@ -8,18 +8,20 @@ The action is available as `apricote/releaser-pleaser` on GitHub.com.
|
|||
|
||||
The `apricote/releaser-pleaser` action is released together with `releaser-pleaser` and they share the version number.
|
||||
|
||||
The action does not support floating tags (e.g. `v1`) right now ([#31](https://github.com/apricote/releaser-pleaser/issues/31)). You have to use the full version or commit SHA instead: `apricote/releaser-pleaser@v0.2.0`.
|
||||
The action does not support floating tags (e.g.
|
||||
`v1`) right now ([#31](https://github.com/apricote/releaser-pleaser/issues/31)). You have to use the full version or commit SHA instead:
|
||||
`apricote/releaser-pleaser@v0.2.0`.
|
||||
|
||||
## Inputs
|
||||
|
||||
The following inputs are supported by the `apricote/releaser-pleaser` GitHub Action.
|
||||
|
||||
| Input | Description | Default | Example |
|
||||
| --------------------- | :------------------------------------------------------ | --------------: | -------------------------------------------------------------------: |
|
||||
| `branch` | This branch is used as the target for releases. | `main` | `master` |
|
||||
| `token` | GitHub token for creating and updating release PRs | `$GITHUB_TOKEN` | `${{secrets.RELEASER_PLEASER_TOKEN}}` |
|
||||
| `extra-files` | List of files that are scanned for version references. | `""` | <pre><code>version/version.go<br>deploy/deployment.yaml</code></pre> |
|
||||
| `update-package-json` | Update version field in package.json file. | `false` | `true` |
|
||||
| Input | Description | Default | Example |
|
||||
|---------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------:|---------------------------------------------------------------------:|
|
||||
| `branch` | This branch is used as the target for releases. | `main` | `master` |
|
||||
| `token` | GitHub token for creating and updating release PRs | `$GITHUB_TOKEN` | `${{secrets.RELEASER_PLEASER_TOKEN}}` |
|
||||
| `extra-files` | List of files that are scanned for version references by the generic updater. | `""` | <pre><code>version/version.go<br>deploy/deployment.yaml</code></pre> |
|
||||
| `updaters` | List of updaters that are run. Default updaters can be removed by specifying them as -name. Multiple updaters should be concatenated with a comma. Default Updaters: changelog,generic | `""` | `-generic,packagejson` |
|
||||
|
||||
## Outputs
|
||||
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@ The component does not support floating tags (e.g.
|
|||
|
||||
The following inputs are supported by the component.
|
||||
|
||||
| Input | Description | Default | Example |
|
||||
| ---------------------- | :-------------------------------------------------------- | ------: | -------------------------------------------------------------------: |
|
||||
| `branch` | This branch is used as the target for releases. | `main` | `master` |
|
||||
| `token` (**required**) | GitLab access token for creating and updating release PRs | | `$RELEASER_PLEASER_TOKEN` |
|
||||
| `extra-files` | List of files that are scanned for version references. | `""` | <pre><code>version/version.go<br>deploy/deployment.yaml</code></pre> |
|
||||
| `update-package-json` | Update version field in package.json file. | `false` | `true` |
|
||||
| `stage` | Stage the job runs in. Must exists. | `build` | `test` |
|
||||
| `needs` | Other jobs the releaser-pleaser job depends on. | `[]` | <pre><code>- validate-foo<br>- prepare-bar</code></pre> |
|
||||
| Input | Description | Default | Example |
|
||||
|------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------:|---------------------------------------------------------------------:|
|
||||
| `branch` | This branch is used as the target for releases. | `main` | `master` |
|
||||
| `token` (**required**) | GitLab access token for creating and updating release PRs | | `$RELEASER_PLEASER_TOKEN` |
|
||||
| `extra-files` | List of files that are scanned for version references by the generic updater. | `""` | <pre><code>version/version.go<br>deploy/deployment.yaml</code></pre> |
|
||||
| `updaters` | List of updaters that are run. Default updaters can be removed by specifying them as -name. Multiple updaters should be concatenated with a comma. Default Updaters: changelog,generic | `""` | `-generic,packagejson` |
|
||||
| `stage` | Stage the job runs in. Must exists. | `build` | `test` |
|
||||
| `needs` | Other jobs the releaser-pleaser job depends on. | `[]` | <pre><code>- validate-foo<br>- prepare-bar</code></pre> |
|
||||
|
|
|
|||
|
|
@ -2,17 +2,21 @@
|
|||
|
||||
### Changelog
|
||||
|
||||
The Changelog is a file in the repository (`CHANGELOG.md`) that contains the [Release Notes](#release-notes) for every release of that repository. Usually, new releases are added at the top of the file.
|
||||
The Changelog is a file in the repository (
|
||||
`CHANGELOG.md`) that contains the [Release Notes](#release-notes) for every release of that repository. Usually, new releases are added at the top of the file.
|
||||
|
||||
### Conventional Commits
|
||||
|
||||
[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) is a specification for commit messages. It is the only supported commit message schema in `releaser-pleaser`. Follow the link to learn more.
|
||||
[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) is a specification for commit messages. It is the only supported commit message schema in
|
||||
`releaser-pleaser`. Follow the link to learn more.
|
||||
|
||||
### Forge
|
||||
|
||||
A **forge** is a web-based collaborative software platform for both developing and sharing computer applications.[^wp-forge]
|
||||
A **forge
|
||||
** is a web-based collaborative software platform for both developing and sharing computer applications.[^wp-forge]
|
||||
|
||||
Right now only **GitHub** is supported. We plan to support **GitLab** in the future ([#4](https://github.com/apricote/releaser-pleaser/issues/4)). For other forges like Forgejo or Gitea, please open an issue and submit a pull request.
|
||||
Right now only **GitHub** is supported. We plan to support **GitLab
|
||||
** in the future ([#4](https://github.com/apricote/releaser-pleaser/issues/4)). For other forges like Forgejo or Gitea, please open an issue and submit a pull request.
|
||||
|
||||
[^wp-forge]: Quote from [Wikipedia "Forge (software)"](<https://en.wikipedia.org/wiki/Forge_(software)>)
|
||||
|
||||
|
|
@ -24,7 +28,8 @@ In `releaser-pleaser` Markdown is used for most texts.
|
|||
|
||||
### Pre-release
|
||||
|
||||
Pre-releases are a concept of [SemVer](#semantic-versioning-semver). They follow the normal versioning schema but use a suffix out of `-alpha.X`, `-beta.X` and `-rc.X`.
|
||||
Pre-releases are a concept of [SemVer](#semantic-versioning-semver). They follow the normal versioning schema but use a suffix out of
|
||||
`-alpha.X`, `-beta.X` and `-rc.X`.
|
||||
|
||||
Pre-releases are not considered "stable" and are usually not recommended for most users.
|
||||
|
||||
|
|
@ -32,7 +37,9 @@ Learn more in the [Pre-releases](../guides/pre-releases.md) guide.
|
|||
|
||||
### Release Pull Request
|
||||
|
||||
A Release Pull Request is opened by `releaser-pleaser` whenever it finds releasable commits in your project. It proposes a new version number and the Changelog. Once it is merged, `releaser-pleaser` creates a matching release.
|
||||
A Release Pull Request is opened by
|
||||
`releaser-pleaser` whenever it finds releasable commits in your project. It proposes a new version number and the Changelog. Once it is merged,
|
||||
`releaser-pleaser` creates a matching release.
|
||||
|
||||
Learn more in the [Release Pull Request](../explanation/release-pr.md) explanation.
|
||||
|
||||
|
|
@ -44,4 +51,11 @@ Learn more in the [Release Notes customization](../guides/release-notes.md) guid
|
|||
|
||||
### Semantic Versioning (SemVer)
|
||||
|
||||
[Semantic Versioning](https://semver.org/) is a specification for version numbers. It is the only supported versioning schema in `releaser-pleaser`. Follow the link to learn more.
|
||||
[Semantic Versioning](https://semver.org/) is a specification for version numbers. It is the only supported versioning schema in
|
||||
`releaser-pleaser`. Follow the link to learn more.
|
||||
|
||||
### Updater
|
||||
|
||||
Updaters can update or create files that will be included in [Release Pull Request](#release-pull-request). Examples of Updaters are
|
||||
`changelog` for `CHANGELOG.md`, `generic` that can update arbitrary files and
|
||||
`packagejson` that knows how to update Node.JS `package.json` files.
|
||||
33
docs/reference/updaters.md
Normal file
33
docs/reference/updaters.md
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# Updaters
|
||||
|
||||
There are different updater for different purposes available.
|
||||
|
||||
They each have a name and may be enabled by default. You can configure which updaters are used through the
|
||||
`updaters` input on GitHub Actions and GitLab CI/CD. This is a comma-delimited list of updaters that should be enabled, for updaters that are enabled by default you can remove them by adding a minus before its name:
|
||||
|
||||
```
|
||||
updaters: -generic,packagejson
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
- **Name**: `changelog`
|
||||
- **Default**: enabled
|
||||
|
||||
This updater creates the `CHANGELOG.md` file and adds new release notes to it.
|
||||
|
||||
## Generic Updater
|
||||
|
||||
- **Name**: `generic`
|
||||
- **Default**: enabled
|
||||
|
||||
This updater can update any file and only needs a marker on the line. It is enabled by default.
|
||||
|
||||
Learn more about this updater in ["Updating arbitrary files"](../guides/updating-arbitrary-files.md).
|
||||
|
||||
## Node.js `package.json` Updater
|
||||
|
||||
- **Name**: `packagejson`
|
||||
- **Default**: disabled
|
||||
|
||||
This updater can update the `version` field in Node.js `package.json` files. The updater is disabled by default.
|
||||
Loading…
Add table
Add a link
Reference in a new issue