Skip to main content
← Back to workflows

How to Automatically Bump and Tag Versions with GitHub Tag Action

mathieudutour-github-tag-action -
GitHub Action
v6.2
629
Contributors
Contributor - mathieudutourContributor - koiralakiran1
Categories
CICUBE ANALYTICS INSIGHTS
Engineering Velocity: 25% Team Time Lost to CI Issues
View Platform →
3.5h
Time Saved/Dev/Week
40%
Faster Releases
Click for next insight
Usage
name: Bump version
on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}

github-tag-action logo

github-tag-action

This action automatically bumps and tags the version on GitHub using semantic versioning.


What is GitHub Tag Action?

The GitHub Tag Action helps automate version bumping and tagging on the master branch using the latest semantic version format. It ensures that every merge to master results in a correctly tagged version.

How to Use github_token

To authorize the action to tag the repository, you need to provide the GitHub token.

with:
github_token: ${{ secrets.GITHUB_TOKEN }}

You can learn more about creating GitHub tokens in the GitHub Token Documentation.

How to Fetch All Tags

By default, this action fetches the last 100 tags. If you need all tags, use the fetch_all_tags input.

with:
fetch_all_tags: true

How to Filter Branches for Release

You can specify which branches will trigger a release using release_branches.

with:
release_branches: 'master,release/*'

How to Customize Tag Creation

To customize the tag creation process, you can use the following inputs:

  • default_bump: Specify whether to bump a patch, minor, or major version.
    Example:

    with:
    default_bump: 'minor'
  • custom_tag: Set a custom tag name instead of using the default semantic versioning.

    with:
    custom_tag: 'v1.0.0'

How to Append to Pre-Release Tags

You can add a suffix to the pre-release tag using append_to_pre_release_tag:

with:
append_to_pre_release_tag: 'beta'

How to Customize Commit Messages and Changelog Sections

You can define custom rules for the commit messages that determine the release type. Here’s an example of custom release rules:

with:
custom_release_rules: 'fix:patch,feat:minor,breaking:major'

How to Perform a Dry Run

If you want to test the action without actually tagging the repository, use the dry_run option.

with:
dry_run: true

This will calculate the next version and changelog without performing any actual tagging.

Outputs

  • new_tag: The newly created tag value.
  • new_version: The new version number without the prefix.
  • previous_tag: The previous tag value.
  • changelog: The changelog generated between the current and previous tags.