github-tag-action/README.md

122 lines
4.7 KiB
Markdown
Raw Normal View History

2019-11-01 01:36:53 +08:00
# GitHub Tag Action
2020-06-27 00:48:20 +08:00
A GitHub Action to automatically bump and tag master, on merge, with the latest SemVer formatted version. Works on any platform.
2019-11-01 01:36:53 +08:00
## Usage
2019-11-01 03:02:20 +08:00
```yaml
2019-11-01 01:36:53 +08:00
name: Bump version
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
2019-11-01 03:02:20 +08:00
- name: Bump version and push tag
id: tag_version
2021-03-09 15:56:35 +08:00
uses: mathieudutour/github-tag-action@v5.3
2019-11-01 03:02:20 +08:00
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create a GitHub release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag_version.outputs.new_tag }}
release_name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
2019-11-01 01:36:53 +08:00
```
### 📥 Inputs
2019-11-01 01:36:53 +08:00
- **github_token** _(required)_ - Required for permission to tag the repo. Usually `${{ secrets.GITHUB_TOKEN }}`.
#### Filter branches
2021-01-04 17:05:54 +08:00
- **release_branches** _(optional)_ - Comma separated list of branches (JavaScript regular expression accepted) that will generate the release tags. Other branches and pull-requests generate versions postfixed with the commit hash and do not generate any repository tag. Examples: `master` or `.*` or `release.*,hotfix.*,master`... (default: `master,main`).
2020-11-12 17:30:38 +08:00
- **pre_release_branches** _(optional)_ - Comma separated list of branches (JavaScript regular expression accepted) that will generate the pre-release tags.
#### Customize the tag
2020-05-27 21:30:18 +08:00
- **default_bump** _(optional)_ - Which type of bump to use when [none is explicitly provided](#bumping) (default: `patch`). You can also set `false` to avoid generating a new tag when none is explicitly provided.
- **custom_tag** _(optional)_ - Custom tag name. If specified, it overrides bump settings.
- **create_annotated_tag** _(optional)_ - Boolean to create an annotated rather than a lightweight one (default: `false`).
- **tag_prefix** _(optional)_ - A prefix to the tag name (default: `v`).
- **append_to_pre_release_tag** _(optional)_ - A suffix to the pre-release tag name (default: `<branch>`).
2020-11-13 18:55:18 +08:00
#### Customize the conventional commit messages
- **custom_release_rules** _(optional)_ - Comma separated list of release rules. Format: `<keyword>:<release_type>`. Example: `hotfix:patch,pre-feat:preminor`.
#### Debugging
- **dry_run** _(optional)_ - Do not perform tagging, just calculate next version and changelog, then exit
2019-11-01 01:36:53 +08:00
### 📤 Outputs
2019-11-01 01:36:53 +08:00
2020-11-12 17:30:38 +08:00
- **new_tag** - The value of the newly calculated tag. Note that if there hasn't been any new commit, this will be `undefined`.
2020-01-11 00:29:30 +08:00
- **new_version** - The value of the newly created tag without the prefix. Note that if there hasn't been any new commit, this will be `undefined`.
2021-02-18 17:15:23 +08:00
- **previous_tag** - The value of the previous tag (or `v0.0.0` if none). Note that if `custom_tag` is set, this will be `undefined`.
- **previous_version** - The value of the previous tag (or `0.0.0` if none) without the prefix. Note that if `custom_tag` is set, this will be `undefined`.
2020-02-25 01:55:02 +08:00
- **changelog** - The [conventional changelog](https://github.com/conventional-changelog/conventional-changelog) since the previous tag.
2019-11-01 01:36:53 +08:00
> **_Note:_** This action creates a [lightweight tag](https://developer.github.com/v3/git/refs/#create-a-reference) by default.
2019-11-01 01:36:53 +08:00
2020-01-06 23:33:39 +08:00
### Bumping
The action will parse the new commits since the last tag using the [semantic-release](https://github.com/semantic-release/semantic-release) conventions.
semantic-release uses the commit messages to determine the type of changes in the codebase. Following formalized conventions for commit messages, semantic-release automatically determines the next [semantic version](https://semver.org) number.
By default semantic-release uses [Angular Commit Message Conventions](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines).
Here is an example of the release type that will be done based on a commit messages:
2021-02-18 17:15:23 +08:00
<table>
<tr>
<td> Commit message </td> <td> Release type </td>
</tr>
<tr>
<td>
```
fix(pencil): stop graphite breaking when too much pressure applied
```
</td>
<td>Patch Release</td>
</tr>
<tr>
<td>
```
feat(pencil): add 'graphiteWidth' option
```
</td>
<td>Minor Release</td>
</tr>
<tr>
<td>
```
perf(pencil): remove graphiteWidth option
BREAKING CHANGE: The graphiteWidth option has been removed.
The default graphite width of 10mm is always used for performance reasons.
```
</td>
<td>Major Release</td>
</tr>
</table>
2020-01-06 23:33:39 +08:00
If no commit message contains any information, then **default_bump** will be used.
2019-11-01 01:36:53 +08:00
## Credits
2020-01-06 23:33:39 +08:00
[anothrNick/github-tag-action](https://github.com/anothrNick/github-tag-action) - a similar action using a Dockerfile (hence not working on macOS)