A GitHub Action to automatically push new tag to master, on push or merge with the latest SemVer formatted version if the commit message contains specified keywords.
Note: This action creates a lightweight tag.
name: Generate tag
on:
push:
branches:
- master
jobs:
build:
name: Generate tag
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@master
with:
fetch-depth: '0'
- name: Bump version and push tag
uses: ChloePlanet/github-tag-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
NOTE: set the fetch-depth for
actions/checkout@master
to be sure you retrieve all commits to look for the semver commit message.
Use GitHub Personal Access Token ${{ secrets.REPO_ACCESS_TOKEN }}
in GITHUB_TOKEN
if you want to trigger another workflow by this workflow.
name: Another workflow on tag generated
on:
push:
tags:
- 'v*.*.*'
jobs:
myJob:
name: On tag generated
runs-on: ubuntu-latest
steps:
# Whatever you want to do on tag generated
An action in a workflow run can't trigger a new workflow run. When you use GITHUB_TOKEN in your actions, all of the interactions with the repository are on behalf of the Github-actions bot. The operations act by Github-actions bot cannot trigger a new workflow run. More details: https://help.github.com/en/actions/reference/events-that-trigger-workflows#about-workflow-events
- Add this action to your repo
- Commit some changes with message contains
#major
or#patch
or#patch
- Either push to master or open a PR
- On push (or merge) to
master
, the action will:- Get latest tag
- Generate tag if commit message contains
#major
or#patch
or#patch
Note: This action will not push the tag if the
HEAD
commit has already been tagged. If two or more keywords are present, the highest-ranking one will take precedence. - Pushes tag to GitHub
- GITHUB_TOKEN (required) - Required for permission to tag the repo.
- WITH_V (optional) - Tag version with
v
character. - RELEASE_BRANCHES (optional) - Comma separated list of branches (bash reg exp accepted) that will generate the release tags. Other branches and pull-requests generate versions postfixed with the commit hash and do not generate any tag. Examples:
master
or.*
orrelease.*,hotfix.*,master
... - CUSTOM_TAG (optional) - Set a custom tag, useful when generating tag based on f.ex FROM image in a docker image. Setting this tag will invalidate any other settings set!
- SOURCE (optional) - Operate on a relative path under $GITHUB_WORKSPACE.
- last_tag - The value of the latest tag before running this action.
- new_tag - The value of the newly created tag.
- tag_generated - 1 if new tag is generated successfully. 0 if no tag is generated
- last_major - The major part of last tag
- last_minor - The minor part of last tag
- last_patch - The patch part of last tag
- major - The major part of new tag
- minor - The minor part of new tag
- patch - The patch part of new tag
- bump_ver - The bump version string e.g.
major
,minor
orpatch
anothrNick/github-tag-action fsaintjacques/semver-tool
A list of projects using Git Tag Generator for reference.